You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 10:27:23 UTC
[sling-slingstart-maven-plugin] 06/13: SLING-5379 - use
BundleFileProcessor
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag slingstart-maven-plugin-1.4.0
in repository https://gitbox.apache.org/repos/asf/sling-slingstart-maven-plugin.git
commit fcda963b2360b630b35210685dffa58eeb33bb4a
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Mon Dec 21 15:52:15 2015 +0000
SLING-5379 - use BundleFileProcessor
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/tooling/maven/slingstart-maven-plugin@1721201 13f79535-47bb-0310-9956-ffa450edef68
---
.../sling/maven/slingstart/PreparePackageMojo.java | 32 ++++++++++++++++++++--
1 file changed, 30 insertions(+), 2 deletions(-)
diff --git a/src/main/java/org/apache/sling/maven/slingstart/PreparePackageMojo.java b/src/main/java/org/apache/sling/maven/slingstart/PreparePackageMojo.java
index c845bab..e68cd0d 100644
--- a/src/main/java/org/apache/sling/maven/slingstart/PreparePackageMojo.java
+++ b/src/main/java/org/apache/sling/maven/slingstart/PreparePackageMojo.java
@@ -48,7 +48,7 @@ import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.ResolutionScope;
-import org.apache.sling.commons.osgi.BundleUtil;
+import org.apache.sling.commons.osgi.BundleFileProcessor;
import org.apache.sling.provisioning.model.ArtifactGroup;
import org.apache.sling.provisioning.model.Configuration;
import org.apache.sling.provisioning.model.Feature;
@@ -87,6 +87,34 @@ public class PreparePackageMojo extends AbstractSlingStartMojo {
private static final String PROPERTIES_FILE = "sling_install.properties";
+ /** BundleFileProcessor that can change the bundle symbolic name */
+ static class BSNRenamer extends BundleFileProcessor {
+ private final String newBSN;
+
+ BSNRenamer(File input, File outputFolder, String newBSN) {
+ super(input, outputFolder);
+ this.newBSN = newBSN;
+ }
+
+ protected Manifest processManifest(Manifest inputMF) {
+ Attributes inputAttrs = inputMF.getMainAttributes();
+ String orgBSN = inputAttrs.getValue("Bundle-SymbolicName");
+ Manifest newMF = new Manifest(inputMF);
+ Attributes outputAttrs = newMF.getMainAttributes();
+ outputAttrs.putValue("Bundle-SymbolicName", newBSN);
+ outputAttrs.putValue("X-Original-Bundle-SymbolicName", orgBSN);
+ return newMF;
+ }
+
+ protected String getTargetFilename(Manifest inputJarManifest) {
+ String bver = inputJarManifest.getMainAttributes().getValue("Bundle-Version");
+ if (bver == null) {
+ bver = "0.0.0";
+ }
+ return newBSN + "-" + bver + ".jar";
+ }
+ }
+
/**
* To look up Archiver/UnArchiver implementations
*/
@@ -238,7 +266,7 @@ public class PreparePackageMojo extends AbstractSlingStartMojo {
if (newBSN != null) {
try {
getTmpDir().mkdirs();
- artifactFile = BundleUtil.renameBSN(artifactFile, newBSN, getTmpDir());
+ artifactFile = new BSNRenamer(artifactFile, getTmpDir(), newBSN).process();
} catch (IOException e) {
throw new MojoExecutionException("Unable to rename bundle BSN to " + newBSN + " for " + artifactFile, e);
}
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.