You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2021/06/08 14:42:37 UTC

[sling-slingfeature-maven-plugin] branch master updated: SLING-10470 : Add configuration for defining bundle metadata like symbolic name in manifest file

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 528a1d9  SLING-10470 : Add configuration for defining bundle metadata like symbolic name in manifest file
528a1d9 is described below

commit 528a1d9231ab69114c315bbf5d605df6f5de021c
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Tue Jun 8 16:42:27 2021 +0200

    SLING-10470 : Add configuration for defining bundle metadata like symbolic name in manifest file
---
 .../apache/sling/feature/maven/mojos/ApisJarMojo.java    | 13 ++++++++++++-
 .../feature/maven/mojos/apis/ApisConfiguration.java      | 16 ++++++++++++++++
 2 files changed, 28 insertions(+), 1 deletion(-)

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 58c4f86..9397e21 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
@@ -412,6 +412,15 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
     @Parameter
     private List<String> javadocAdditionalExtensions;
 
+    /**
+     * Optional artifact name which is used instead of the generated artifact name
+     * to set some headers in the manifest.
+     * 
+     * @since 1.5.6
+     */
+    @Parameter 
+    private String apiName;
+
     @Parameter(defaultValue = "${project.build.directory}/apis-jars", readonly = true)
     private File mainOutputDir;
 
@@ -478,6 +487,7 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
         ctx.getConfig().setJavadocClasspathHighestVersions(this.javadocClasspathHighestVersions);
         ctx.getConfig().setJavadocClasspathTops(this.javadocClasspathTops);
         ctx.getConfig().setApiVersion(this.apiVersion);
+        ctx.getConfig().setApiName(this.apiName);
         ctx.getConfig().setJavadocSourceLevel(this.javadocSourceLevel);
         ctx.getConfig().setBundleResourceFolders(this.resourceFolders);
         ctx.getConfig().setBundleResources(this.includeResources);
@@ -1595,7 +1605,8 @@ public class ApisJarMojo extends AbstractIncludingFeatureMojo {
         }
 
         final ArtifactId targetId = this.buildArtifactId(ctx, apiRegion, archiveType);
-        final String artifactName = String.format("%s-%s", targetId.getArtifactId(), targetId.getClassifier());
+        final String artifactName = ctx.getConfig().getApiName() != null ? ctx.getConfig().getApiName() :
+                String.format("%s-%s", targetId.getArtifactId(), targetId.getClassifier());
 
         MavenArchiveConfiguration archiveConfiguration = new MavenArchiveConfiguration();
         archiveConfiguration.setAddMavenDescriptor(false);
diff --git a/src/main/java/org/apache/sling/feature/maven/mojos/apis/ApisConfiguration.java b/src/main/java/org/apache/sling/feature/maven/mojos/apis/ApisConfiguration.java
index 8818ec2..e0d94ea 100644
--- a/src/main/java/org/apache/sling/feature/maven/mojos/apis/ApisConfiguration.java
+++ b/src/main/java/org/apache/sling/feature/maven/mojos/apis/ApisConfiguration.java
@@ -92,6 +92,8 @@ public class ApisConfiguration {
 
     private static final String PROP_API_VERSION = "api-version";
 
+    private static final String PROP_API_NAME = "api-name";
+
     private static final String PROP_JAVADOC_SOURCE_LEVEL = "javadoc-source-level";
 
     private static final String PROP_JAVADOC_CLASSPATH_TOPS = "javadoc-classpath-tops";
@@ -130,6 +132,8 @@ public class ApisConfiguration {
 
     private String apiVersion;
 
+    private String apiName;
+
     private final List<String> bundleResourceFolders = new ArrayList<>();
 
     private final List<String> bundleResources = new ArrayList<>();
@@ -179,6 +183,7 @@ public class ApisConfiguration {
 
             this.javadocSourceLevel = json.getString(PROP_JAVADOC_SOURCE_LEVEL, null);
             this.apiVersion = json.getString(PROP_API_VERSION, null);
+            this.apiName = json.getString(PROP_API_NAME, null);
 
             add(this.bundleResourceFolders, json, PROP_BUNDLE_RESOURCE_FOLDERS);
             add(this.bundleResources, json, PROP_BUNDLE_RESOURCES);
@@ -206,6 +211,7 @@ public class ApisConfiguration {
             log.info("- " + PROP_JAVADOC_SOURCE_LEVEL + " : " + this.javadocSourceLevel);
             log.info("- " + PROP_JAVADOC_LINKS + " : " + this.javadocLinks);
             log.info("- " + PROP_API_VERSION + " : " + this.apiVersion);
+            log.info("- " + PROP_API_NAME + " : " + this.apiName);
             log.info("- " + PROP_BUNDLE_RESOURCE_FOLDERS + " : " + this.bundleResourceFolders);
             log.info("- " + PROP_BUNDLE_RESOURCES + " : " + this.bundleResources);
             log.info("- " + PROP_REGION_MAPPINGS + " : " + this.regionMappings);
@@ -274,6 +280,10 @@ public class ApisConfiguration {
         return apiVersion;
     }
 
+    public String getApiName() {
+        return apiName;
+    }
+
     public List<String> getBundleResourceFolders() {
         return bundleResourceFolders;
     }
@@ -543,4 +553,10 @@ public class ApisConfiguration {
             }
         }
     }
+
+    public void setApiName(final String value) {
+        if ( this.apiName == null ) {
+            this.apiName = value;
+        }
+    }
 }