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

cziegeler 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 2806514  SLING-9778 : Handle deprecation info when creating api jars
2806514 is described below

commit 2806514528214f76da7abd61b220df86f7838802
Author: Carsten Ziegeler <[email protected]>
AuthorDate: Thu Oct 1 07:29:22 2020 +0200

    SLING-9778 : Handle deprecation info when creating api jars
---
 .gitignore                                                 |  1 +
 .../org/apache/sling/feature/maven/mojos/ApisJarMojo.java  | 14 ++++++++++----
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/.gitignore b/.gitignore
index 5b783ed..0ddae23 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,4 +14,5 @@ maven-eclipse.xml
 .vlt
 .DS_Store
 jcr.log
+.factorypath
 atlassian-ide-plugin.xml
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 53754cc..ad12b56 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
@@ -369,12 +369,12 @@ public class ApisJarMojo extends 
AbstractIncludingFeatureMojo {
     public void execute() throws MojoExecutionException, MojoFailureException {
         checkPreconditions();
 
-        getLog().debug("Retrieving Feature files...");
+        getLog().debug("Retrieving feature files...");
         final Collection<Feature> features = 
this.getSelectedFeatures(selection).values();
 
         if (features.isEmpty()) {
             getLog().info(
-                    "There are no assciated Feature files in the current 
project, plugin execution will be skipped");
+                    "There are no associated feature files in the current 
project, plugin execution will be skipped");
         } else {
             getLog().debug("Starting APIs JARs creation...");
 
@@ -697,7 +697,7 @@ public class ApisJarMojo extends 
AbstractIncludingFeatureMojo {
         }
     }
 
-    private boolean calculateOmitDependenciesFlag(final Clause[] 
exportedPackageClauses, final Set<Clause> usedExportedPackagesPerRegion) {
+    private boolean calculateOmitDependenciesFlag(final ApiRegion region, 
final Clause[] exportedPackageClauses, final Set<Clause> 
usedExportedPackagesPerRegion) {
         // check whether all packages are exported in this region
         boolean fullUsage = true;
         for(final Clause c : exportedPackageClauses) {
@@ -713,6 +713,12 @@ public class ApisJarMojo extends 
AbstractIncludingFeatureMojo {
                 fullUsage = false;
                 break;
             }
+            // check deprecation - if deprecation is set, artifact can't be 
used as a dependency
+            final ApiExport exp = region.getAllExportByName(c.getName());
+            if (  exp != null && exp.getDeprecation() != null ) {
+                fullUsage = false;
+                break;
+            }
         }
 
         return fullUsage;
@@ -747,7 +753,7 @@ public class ApisJarMojo extends 
AbstractIncludingFeatureMojo {
                     final Set<Clause> usedExportedPackagesPerRegion = 
computeUsedExportPackages(region, exportedPackageClauses, artifact);
 
                     // check whether packages are included in api jars - or 
added as a dependency
-                    boolean useAsDependency = this.useApiDependencies ? 
calculateOmitDependenciesFlag(exportedPackageClauses, 
usedExportedPackagesPerRegion) : false;
+                    boolean useAsDependency = this.useApiDependencies ? 
calculateOmitDependenciesFlag(region, exportedPackageClauses, 
usedExportedPackagesPerRegion) : false;
                     if ( useAsDependency ) {
                         useAsDependency = ctx.findDependencyArtifact(getLog(), 
info);
                         if ( useAsDependency ) {

Reply via email to