This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository 
https://gitbox.apache.org/repos/asf/sling-slingfeature-maven-plugin.git


The following commit(s) were added to refs/heads/master by this push:
     new 79ed803  SLING-12598 - Register project expression for sling feature 
output location (#94)
79ed803 is described below

commit 79ed803d1d983c3704a54ae9723a933f81e058e7
Author: Robert Munteanu <[email protected]>
AuthorDate: Sat Mar 29 21:42:17 2025 +0100

    SLING-12598 - Register project expression for sling feature output location 
(#94)
---
 README.md                                          |  2 +
 .../apache/sling/feature/maven/ProjectHelper.java  |  5 ++
 .../sling/feature/maven/ProjectHelperTest.java     | 60 ++++++++++++++++++++++
 3 files changed, 67 insertions(+)

diff --git a/README.md b/README.md
index f1f47d5..8e99f72 100644
--- a/README.md
+++ b/README.md
@@ -110,6 +110,8 @@ There might be other plugins involved which generate 
feature files are part of t
 * generatedFeaturesIncludes : The include pattern for feature files from the 
above directory. Default is `**/*.json`, therefore all files with the extension 
`.json` are read including sub directories.
 * generatedFeaturesExcludes : The exclude pattern for feature files from the 
above directory. Empty by default.
 
+For interoperability with other plugins, the location where this plug-in 
stores generated feature files is indicated by the expression 
`${project.slingfeature.outputDirectory}`.
+
 # Supported goals
 
 Most of the plugin goals take a selection of features as input, for example to 
aggregate a set of features to a new feature or to analyse a specific set of 
features according to some rules.
diff --git a/src/main/java/org/apache/sling/feature/maven/ProjectHelper.java 
b/src/main/java/org/apache/sling/feature/maven/ProjectHelper.java
index bf73042..2691407 100644
--- a/src/main/java/org/apache/sling/feature/maven/ProjectHelper.java
+++ b/src/main/java/org/apache/sling/feature/maven/ProjectHelper.java
@@ -150,6 +150,11 @@ public abstract class ProjectHelper {
         store(info.project, ASSEMBLED_FEATURE_JSON, info.assembledFeatures);
         store(info.project, ASSEMBLED_TEST_FEATURE_JSON, 
info.assembledTestFeatures);
         info.project.setContextValue(Preprocessor.class.getName(), 
Boolean.TRUE);
+        info.project
+                .getProperties()
+                .put(
+                        "project.slingfeature.outputDirectory",
+                        getTmpDir(info.project).getAbsolutePath());
     }
 
     /**
diff --git 
a/src/test/java/org/apache/sling/feature/maven/ProjectHelperTest.java 
b/src/test/java/org/apache/sling/feature/maven/ProjectHelperTest.java
new file mode 100644
index 0000000..4e3af1a
--- /dev/null
+++ b/src/test/java/org/apache/sling/feature/maven/ProjectHelperTest.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.feature.maven;
+
+import java.io.IOException;
+import java.nio.file.Paths;
+
+import org.apache.maven.model.Build;
+import org.apache.maven.project.MavenProject;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+public class ProjectHelperTest {
+
+    @Rule
+    public TemporaryFolder tmp = new TemporaryFolder();
+
+    @Test
+    public void storeProjectInfoSetsOutputDirectory() throws IOException {
+
+        String buildDirectory = tmp.newFolder().getAbsolutePath();
+        String expectedSlingfeatureOutputDirectory =
+                Paths.get(buildDirectory, "slingfeature-tmp").toString();
+
+        FeatureProjectInfo info = new FeatureProjectInfo();
+        MavenProject project = new MavenProject();
+        Build build = new Build();
+        build.setDirectory(buildDirectory);
+        project.setBuild(build);
+
+        info.project = project;
+
+        ProjectHelper.storeProjectInfo(info);
+
+        assertThat(
+                "Slingfeature output directory",
+                
project.getProperties().get("project.slingfeature.outputDirectory"),
+                equalTo(expectedSlingfeatureOutputDirectory));
+    }
+}

Reply via email to