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 fea445b SLING-9551 : Allow to ignore artifacts/packages for javadoc
generation
fea445b is described below
commit fea445b8ef082b4df24be0c28fff4ca35c9cfeba
Author: Carsten Ziegeler <[email protected]>
AuthorDate: Fri Jun 26 08:22:31 2020 +0200
SLING-9551 : Allow to ignore artifacts/packages for javadoc generation
---
.../sling/feature/maven/mojos/ApisJarMojo.java | 33 +++++++++++++---------
.../sling/feature/maven/mojos/apis/ApisUtil.java | 15 ++++++++++
2 files changed, 34 insertions(+), 14 deletions(-)
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 5cf326e..fbb91e5 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
@@ -762,11 +762,8 @@ public class ApisJarMojo extends
AbstractIncludingFeatureMojo {
final Clause[] exportedPackageClauses =
this.getExportedPackages(manifest);
if (exportedPackageClauses.length > 0) {
- // calculate the exported versioned packages in the manifest file
for each
- // region
- // and calculate the exported versioned packages in the manifest
file for each
- // region
- final Set<String> usedExportedPackages =
computeUsedExportPackages(ctx.getApiRegions(), exportedPackageClauses,
artifact.getId());
+ // calculate the exported packages in the manifest file for all
regions
+ final Set<String> usedExportedPackages =
computeUsedExportPackages(ctx.getApiRegions(), exportedPackageClauses,
artifact);
if ( !usedExportedPackages.isEmpty()) {
final ArtifactInfo info = ctx.addArtifactInfo(artifact);
@@ -774,7 +771,7 @@ public class ApisJarMojo extends
AbstractIncludingFeatureMojo {
// calculate per region packages
for(final ApiRegion region :
ctx.getApiRegions().listRegions()) {
- final Set<Clause> usedExportedPackagesPerRegion =
computeUsedExportPackages(region, exportedPackageClauses, artifact.getId());
+ 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;
@@ -1482,23 +1479,28 @@ public class ApisJarMojo extends
AbstractIncludingFeatureMojo {
}
/**
- * Compute exports based on all api regions
+ * Compute exports based on a single region
*
* @return List of packages exported by this bundle and used in the region
*/
private Set<Clause> computeUsedExportPackages(final ApiRegion apiRegion,
final Clause[] exportedPackages,
- final ArtifactId bundle)
+ final Artifact bundle)
throws MojoExecutionException {
+
final Set<Clause> result = new HashSet<>();
+ final Set<String> ignoredPackages =
ApisUtil.getIgnoredPackages(bundle);
+
// filter for each region
for (final Clause exportedPackage : exportedPackages) {
final String packageName = exportedPackage.getName();
- final ApiExport exp = apiRegion.getExportByName(packageName);
- if (exp != null) {
- result.add(exportedPackage);
+ if ( !ignoredPackages.contains(packageName)) {
+ final ApiExport exp = apiRegion.getExportByName(packageName);
+ if (exp != null) {
+ result.add(exportedPackage);
+ }
}
}
@@ -1506,13 +1508,13 @@ public class ApisJarMojo extends
AbstractIncludingFeatureMojo {
}
/**
- * Compute exports based on a single api region
+ * Compute exports based on all regions
*
- * @return List of packages exported by this bundle and used in the region
+ * @return List of packages exported by this bundle and used in any region
*/
private Set<String> computeUsedExportPackages(final ApiRegions apiRegions,
final Clause[] exportedPackages,
- final ArtifactId bundle)
+ final Artifact bundle)
throws MojoExecutionException {
final Set<String> result = new HashSet<>();
@@ -1528,6 +1530,9 @@ public class ApisJarMojo extends
AbstractIncludingFeatureMojo {
}
}
+ // check ignored packages configuration
+ result.removeAll(ApisUtil.getIgnoredPackages(bundle));
+
return result;
}
diff --git
a/src/main/java/org/apache/sling/feature/maven/mojos/apis/ApisUtil.java
b/src/main/java/org/apache/sling/feature/maven/mojos/apis/ApisUtil.java
index ee55849..24f5b6d 100644
--- a/src/main/java/org/apache/sling/feature/maven/mojos/apis/ApisUtil.java
+++ b/src/main/java/org/apache/sling/feature/maven/mojos/apis/ApisUtil.java
@@ -54,6 +54,9 @@ public class ApisUtil {
/** Links for javadocs. */
public static final String JAVADOC_LINKS = "javadoc-links";
+ /** Ignore packages for api generation */
+ public static final String IGNORE_PACKAGES = "apis-ignore";
+
public static List<ArtifactId> getSourceIds(final Artifact artifact)
throws MojoExecutionException {
final String val = artifact.getMetadata().get(SCM_IDS);
if ( val != null ) {
@@ -127,4 +130,16 @@ public class ApisUtil {
}
result.stream().forEach(v -> linkedPackages.add(v));
}
+
+ public static Set<String> getIgnoredPackages(final Artifact bundle) {
+ final Set<String> result = new HashSet<>();
+ final String ignore =
bundle.getMetadata().get(ApisUtil.IGNORE_PACKAGES);
+ if (ignore != null) {
+ for(final String p : ignore.split(",")) {
+ result.add(p.trim());
+ }
+ }
+ return result;
+ }
+
}