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

pauls 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 a0f4a34  SLING-8970 - adding test & fixing logic to consider inherited 
exports in region checks
a0f4a34 is described below

commit a0f4a34dcf0d4a23ade0b00faf1e3336622ffab1
Author: Karl Pauls <[email protected]>
AuthorDate: Mon Jan 20 18:31:23 2020 +0100

    SLING-8970 - adding test & fixing logic to consider inherited exports in 
region checks
---
 pom.xml                                                 |  6 +++---
 .../apache/sling/feature/maven/mojos/ApisJarMojo.java   | 17 +++++++----------
 2 files changed, 10 insertions(+), 13 deletions(-)

diff --git a/pom.xml b/pom.xml
index fc25a78..914fab5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -160,12 +160,12 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.feature</artifactId>
-            <version>1.1.0</version>
+            <version>1.1.1-SNAPSHOT</version>
         </dependency>
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.feature.io</artifactId>
-            <version>1.1.0</version>
+            <version>1.1.1-SNAPSHOT</version>
         </dependency>
         <dependency>
             <groupId>org.apache.sling</groupId>
@@ -175,7 +175,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             
<artifactId>org.apache.sling.feature.extension.apiregions</artifactId>
-            <version>1.1.0</version>
+            <version>1.1.1-SNAPSHOT</version>
         </dependency>
         <!-- aux dependencies for Content-Package check -->
         <dependency>
diff --git 
a/src/main/java/org/apache/sling/feature/maven/mojos/ApisJarMojo.java 
b/src/main/java/org/apache/sling/feature/maven/mojos/ApisJarMojo.java
index 0694de8..acebe7e 100644
--- a/src/main/java/org/apache/sling/feature/maven/mojos/ApisJarMojo.java
+++ b/src/main/java/org/apache/sling/feature/maven/mojos/ApisJarMojo.java
@@ -363,7 +363,7 @@ public class ApisJarMojo extends 
AbstractIncludingFeatureMojo implements Artifac
      * @throws MojoExecutionException If an error occurs
      */
     private ApiRegions getApiRegions(final Feature feature) throws 
MojoExecutionException {
-        ApiRegions regions = null;
+        ApiRegions regions = new ApiRegions();
 
         Extensions extensions = feature.getExtensions();
         Extension apiRegionsExtension = 
extensions.getByName(ApiRegions.EXTENSION_NAME);
@@ -372,31 +372,29 @@ public class ApisJarMojo extends 
AbstractIncludingFeatureMojo implements Artifac
                 getLog().info(
                         "Feature file " + feature.getId().toMvnId() + " 
declares an empty '" + ApiRegions.EXTENSION_NAME
                     + "' extension, no API JAR will be created");
+                regions = null;
             } else {
+                ApiRegions sourceRegions;
                 try {
-                    regions = ApiRegions
+                    sourceRegions = ApiRegions
                             .parse((JsonArray) 
apiRegionsExtension.getJSONStructure());
                 } catch (final IOException ioe) {
                     throw new MojoExecutionException(ioe.getMessage(), ioe);
                 }
 
                 // calculate all api-regions first, taking the inheritance in 
account
-                final List<ApiRegion> toBeRemoved = new ArrayList<>();
-                for (final ApiRegion r : regions.listRegions()) {
+                for (final ApiRegion r : sourceRegions.listRegions()) {
                     if (r.getParent() != null && !this.incrementalApis) {
                         for (final ApiExport exp : 
r.getParent().listExports()) {
                             r.add(exp);
                         }
                     }
-                    if (!isRegionIncluded(r.getName())) {
+                    if (isRegionIncluded(r.getName())) {
                         getLog().debug("API Region " + r.getName()
                                     + " will not processed due to the 
configured include/exclude list");
-                        toBeRemoved.add(r);
+                        regions.add(r);
                     }
                 }
-                for (final ApiRegion r : toBeRemoved) {
-                    regions.remove(r);
-                }
 
                 // prepare filter
                 for (final ApiRegion r : regions.listRegions()) {
@@ -412,7 +410,6 @@ public class ApisJarMojo extends 
AbstractIncludingFeatureMojo implements Artifac
                 }
             }
         } else {
-            regions = new ApiRegions();
             // create exports on the fly
             regions.add(new ApiRegion(ApiRegion.GLOBAL) {
 

Reply via email to