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:17 UTC
[sling-slingstart-maven-plugin] annotated tag
slingstart-maven-plugin-1.4.0 created (now 738deed)
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a change to annotated tag slingstart-maven-plugin-1.4.0
in repository https://gitbox.apache.org/repos/asf/sling-slingstart-maven-plugin.git.
at 738deed (tag)
tagging ec8ff1a920166835827c48d8c486d14869653dcb (commit)
by Carsten Ziegeler
on Mon Jan 4 15:28:44 2016 +0000
- Log -----------------------------------------------------------------
slingstart-maven-plugin-1.4.0
-----------------------------------------------------------------------
This annotated tag includes the following new commits:
new 87744a4 Add slingstart maven plugin
new d0a48e9 Add slingstart maven plugin
new 9544826 Update javadocs and rename subsystem to deliverable and run mode to feature
new 869228d Rename classes
new 5758009 Fully support Apach Felix config file format. Move from properties to getter and setter methods
new 42e2fe7 Implement txt format for reading and writing
new c348dc3 Implement txt format for reading and writing
new cb34728 Add merger utility and variable replacement
new c360a20 Cache raw and effective model and provide separate methods
new 08649e0 Adjust to new model
new 46b2387 Update to Sling Parent POM 22 with baselining enabled
new 799c129 Move io methods to helper class
new 6fa67eb Move io methods to helper class
new 9292c9f Use provisioning model
new 68bc095 Correct model caching
new 22e62c6 Rename constants
new 2b243e6 Rename artifact handlers and components
new b4cf460 Get artifacts from repositor if overlayed with a different version
new 84605ad Fix special configuration handling and effective model retrival
new 8fb99d7 Make prepare mojo subclassable
new 3aaf03c Correct extension for config files
new 85bf931 SLING-4081 - SlingStart Maven Plugin fails if the organization is not defined in pom.xml
new 3116925 Moved invocation of org.apache.sling:slingstart-maven-plugin:prepare-package to prepare-package lifecycle phase
new 90e5c8f Rename directory to use from models to provisioning
new c0ef68c Use released provisioning model
new dfabbb8 [maven-release-plugin] prepare release slingstart-maven-plugin-1.0.0
new 6c8eeeb [maven-release-plugin] prepare for next development iteration
new 968d118 Switch to snapshot until release vote is done
new 1f80af8 Use released provisioning model
new bbd3ef7 SLING-4121 : Bootstrap file is created in wrong directory for webapp
new ef15cd3 SLING-4123 : Wrong packaging used for feature
new 38be5ce [maven-release-plugin] prepare release slingstart-maven-plugin-1.0.2
new 71a346e [maven-release-plugin] prepare for next development iteration
new 194cbd8 SLING-4479 : Inherited models are processed in the wrong order
new f83d1b7 SLING-4479 : Inherited models are processed in the wrong order
new 3272ecb [maven-release-plugin] prepare release slingstart-maven-plugin-1.0.4
new 806532a [maven-release-plugin] prepare for next development iteration
new 037927e fix build (use 1.1.1-SNAPSHOT of org.apache.sling.provisioning.model)
new 8668df1 Use released provisioning model
new b0c766a SLING-4474 : Provide a way to start/stop an instance through maven mojos
new 5a664a1 SLING-4600 : Migrate launchpad/test-bundles to provisioning model
new 4e5f8e1 SLING-4598 : Migrate launchpad testing to provisioning model
new 01ce90b Remove unused code and add failing project to exception
new 7861695 Delay resolving of reactor projects until project is built
new 2cfdf79 Correct type/language of slingstart packaging
new 350917d Get dependent projects from build if build in the same build
new 93c268f Check main artifact and attached artifacts for artifacts from the same build
new e2fb051 Refactor slingstart maven plugin: resolve slingstart/slingfeature projects during setup of maven (reactor) project
new 5e423dd Implement control port option
new fd065be SLING-4620 : Slingstart plugin start goal exits even if launchpad.keep.running is set to true
new d5508d2 Use maven.skip.test as the property for skipping the start/stop goals
new 8e24720 SLING-4620 : Slingstart plugin start goal exits even if launchpad.keep.running is set to true
new a55291e [maven-release-plugin] prepare release slingstart-maven-plugin-1.1.0
new 5664925 [maven-release-plugin] prepare for next development iteration
new 265f5f4 SLING-4677 allow to start Sling in debug mode with a simple mojo parameter
new 89d49b0 SLING-4677 allow to override debug settings of all controlled Sling servers through Mojo parameter
new fbb9c15 SLING-4698 - Set parent.relativePath to empty for all modules
new 320de8f SLING-4766 Provisioning Model does not support adding variables to Sling Settings - allow escaping with \${var}
new f2865de SLING-4790 : Removal of artifacts from inherited model is not possible
new ddd4ba0 SLING-4790 : Removal of artifacts from inherited model is not possible
new 3982e2e Prepare for release
new 6cd730f [maven-release-plugin] prepare release slingstart-maven-plugin-1.2.0
new 29b2e20 [maven-release-plugin] prepare for next development iteration
new 2aa3b8f slingstart-maven-plugin: temporarily depend on SNAPSHOT version for provisioning.model
new ab60b2f Update to Sling Parent 23
new 858d446 set parent version to 24 and add empty relativePath where missing
new 72dfaf3 SLING-4879 Allow to read variables from POM
new cfa9a87 SLING-4880 Allow to get artifact versions from POM
new ce4b2b5 SLING-4880 Fix potential NPEs when resolving artifacts
new 51d72c9 SLING-4879 refactor model processing logic from ModelUtility#getEffectiveModel into separate class to make it reusable
new 55bf1b1 SLING-4879 update variables section in feature for attached artifact instead of using effective model
new f59b06d SLING-4880 apply resolved dependencies to raw model instead of attaching effective model add new optional parameter "allowUnresolvedPomDependencies" (default: false)
new b239b9c SLING-4889 : Provide a mojo to create a maven like structure of the referenced artifacts
new c2041da SLING-4889 : Provide a mojo to create a maven like structure of the referenced artifacts
new f93e40b SLING-4912 : Support inlining the model in the pom
new 34fac94 Use latest provisioning model
new 567d94e [maven-release-plugin] prepare release slingstart-maven-plugin-1.3.0
new 91768e0 [maven-release-plugin] prepare for next development iteration
new eba7ffa Switch to latest snapshot for the release vote time
new c0d83a9 Use released prov model
new 250f6a0 Use released prov model
new 0acafe1 SLING-4945 : Model files are missing from created repository SLING-4946 : Model dependencies are not followed transitively
new 9321ca4 [maven-release-plugin] prepare release slingstart-maven-plugin-1.3.2
new 0808f14 [maven-release-plugin] prepare for next development iteration
new e3c6967 SLING-4969 : Store aggregated model as artifact
new e52e8a2 SLING-4969 : Store aggregated model as artifact
new b0ca3ad [maven-release-plugin] prepare release slingstart-maven-plugin-1.3.4
new 9bd2b5e [maven-release-plugin] prepare for next development iteration
new 71a7942 SLING-4970 : Potential NPE with transitive models
new 30c2bf7 [maven-release-plugin] prepare release slingstart-maven-plugin-1.3.6
new 60c436f [maven-release-plugin] prepare for next development iteration
new 49d48b5 Update the main reactor to parent 25
new c3b709a SLING-5170 : Make dependency handling code more reusable
new b98555a SLING-5149 - Generate OSGi subsystem intermediary file in slingstart-maven-plugin
new f6075f8 SLING-5379 - support renaming of bundles in maven-slingstart-plugin. Contributed by David Bosschaert, thanks!
new fcda963 SLING-5379 - use BundleFileProcessor
new e8fd2c9 SLING-5379 - add BSNRenamer
new b703b6b Use latest prov model snapshot version
new f2ac4d9 Use provisioning model 1.4.2
new 9fb072d Switch to parent pom 26
new 16ca65a Use latest commons osgi release
new f679285 [maven-release-plugin] prepare release slingstart-maven-plugin-1.4.0
new ec8ff1a [maven-release-plugin] copy for tag slingstart-maven-plugin-1.4.0
The 103 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
--
To stop receiving notification emails like this one, please contact
['"commits@sling.apache.org" <co...@sling.apache.org>'].
[sling-slingstart-maven-plugin] 07/13: SLING-5379 - add BSNRenamer
Posted by ro...@apache.org.
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 e8fd2c9d972db939c1836fef48bc7c834be3cbc2
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Mon Dec 21 16:20:50 2015 +0000
SLING-5379 - add BSNRenamer
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/tooling/maven/slingstart-maven-plugin@1721206 13f79535-47bb-0310-9956-ffa450edef68
---
.../sling/maven/slingstart/PreparePackageMojo.java | 30 +---------------------
1 file changed, 1 insertion(+), 29 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 e68cd0d..cef9ea1 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.BundleFileProcessor;
+import org.apache.sling.commons.osgi.BSNRenamer;
import org.apache.sling.provisioning.model.ArtifactGroup;
import org.apache.sling.provisioning.model.Configuration;
import org.apache.sling.provisioning.model.Feature;
@@ -87,34 +87,6 @@ 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
*/
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-slingstart-maven-plugin] 01/13: [maven-release-plugin]
prepare for next development iteration
Posted by ro...@apache.org.
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 60c436f82da8169aaea50abd620563fbac2357b4
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon Aug 31 14:40:23 2015 +0000
[maven-release-plugin] prepare for next development iteration
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/tooling/maven/slingstart-maven-plugin@1700258 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/pom.xml b/pom.xml
index 974b67f..2afd4da 100644
--- a/pom.xml
+++ b/pom.xml
@@ -22,7 +22,7 @@
</parent>
<artifactId>slingstart-maven-plugin</artifactId>
- <version>1.3.6</version>
+ <version>1.3.7-SNAPSHOT</version>
<packaging>maven-plugin</packaging>
<name>Apache Sling SlingStart Maven Plugin</name>
@@ -36,9 +36,9 @@
</properties>
<scm>
- <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/slingstart-maven-plugin-1.3.6</connection>
- <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/slingstart-maven-plugin-1.3.6</developerConnection>
- <url>http://svn.apache.org/viewvc/sling/tags/slingstart-maven-plugin-1.3.6</url>
+ <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/tooling/maven/slingstart-maven-plugin</connection>
+ <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/tooling/maven/slingstart-maven-plugin</developerConnection>
+ <url>http://svn.apache.org/viewvc/sling/trunk/tooling/maven/slingstart-maven-plugin</url>
</scm>
<build>
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-slingstart-maven-plugin] 11/13: Use latest commons osgi
release
Posted by ro...@apache.org.
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 16ca65a79fa66943f88bfae71b1e86e69a704e42
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon Jan 4 15:27:00 2016 +0000
Use latest commons osgi release
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/tooling/maven/slingstart-maven-plugin@1722895 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index e07e686..1f208e1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -171,7 +171,7 @@
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.commons.osgi</artifactId>
- <version>2.3.1-SNAPSHOT</version>
+ <version>2.4.0</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-slingstart-maven-plugin] 06/13: SLING-5379 - use
BundleFileProcessor
Posted by ro...@apache.org.
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>.
[sling-slingstart-maven-plugin] 03/13: SLING-5170 : Make dependency
handling code more reusable
Posted by ro...@apache.org.
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 c3b709abf82653de04730f1329f3caf4bfceddbf
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon Oct 19 10:29:12 2015 +0000
SLING-5170 : Make dependency handling code more reusable
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/tooling/maven/slingstart-maven-plugin@1709384 13f79535-47bb-0310-9956-ffa450edef68
---
.../slingstart/DependencyLifecycleParticipant.java | 424 +--------------------
...ycleParticipant.java => ModelPreprocessor.java} | 98 ++---
.../sling/maven/slingstart/ProjectHelper.java | 2 +-
3 files changed, 36 insertions(+), 488 deletions(-)
diff --git a/src/main/java/org/apache/sling/maven/slingstart/DependencyLifecycleParticipant.java b/src/main/java/org/apache/sling/maven/slingstart/DependencyLifecycleParticipant.java
index 8a51986..f6993b3 100644
--- a/src/main/java/org/apache/sling/maven/slingstart/DependencyLifecycleParticipant.java
+++ b/src/main/java/org/apache/sling/maven/slingstart/DependencyLifecycleParticipant.java
@@ -16,44 +16,18 @@
*/
package org.apache.sling.maven.slingstart;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.Reader;
-import java.io.StringReader;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.commons.io.IOUtils;
import org.apache.maven.AbstractMavenLifecycleParticipant;
import org.apache.maven.MavenExecutionException;
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.DefaultArtifact;
import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
-import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
-import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.artifact.resolver.ArtifactResolver;
-import org.apache.maven.artifact.versioning.VersionRange;
import org.apache.maven.execution.MavenSession;
-import org.apache.maven.model.Dependency;
import org.apache.maven.model.Plugin;
import org.apache.maven.project.MavenProject;
-import org.apache.sling.provisioning.model.ArtifactGroup;
-import org.apache.sling.provisioning.model.Feature;
-import org.apache.sling.provisioning.model.Model;
-import org.apache.sling.provisioning.model.ModelConstants;
-import org.apache.sling.provisioning.model.ModelUtility;
-import org.apache.sling.provisioning.model.ModelUtility.ResolverOptions;
-import org.apache.sling.provisioning.model.RunMode;
-import org.apache.sling.provisioning.model.Traceable;
-import org.apache.sling.provisioning.model.io.ModelReader;
+import org.apache.sling.maven.slingstart.ModelPreprocessor.Environment;
+import org.apache.sling.maven.slingstart.ModelPreprocessor.ProjectInfo;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.logging.Logger;
-import org.codehaus.plexus.util.xml.Xpp3Dom;
/**
* Maven lifecycle participant which adds the artifacts of the model to the dependencies.
@@ -76,25 +50,6 @@ public class DependencyLifecycleParticipant extends AbstractMavenLifecyclePartic
@Requirement
private ArtifactResolver resolver;
- public static final class ProjectInfo {
-
- public MavenProject project;
- public Plugin plugin;
- public Model localModel;
- public boolean done = false;
- public Model model;
- public final Map<org.apache.sling.provisioning.model.Artifact, Model> includedModels = new HashMap<org.apache.sling.provisioning.model.Artifact, Model>();
-
- }
-
- public static final class Environment {
- public ArtifactHandlerManager artifactHandlerManager;
- public ArtifactResolver resolver;
- public MavenSession session;
- public Logger logger;
- public final Map<String, ProjectInfo> modelProjects = new HashMap<String, ProjectInfo>();
- }
-
@Override
public void afterProjectsRead(final MavenSession session) throws MavenExecutionException {
final Environment env = new Environment();
@@ -122,379 +77,6 @@ public class DependencyLifecycleParticipant extends AbstractMavenLifecyclePartic
}
}
- addDependencies(env);
- }
-
- public static void addDependencies(final Environment env) throws MavenExecutionException {
- for(final ProjectInfo info : env.modelProjects.values()) {
- addDependencies(env, info);
- }
- }
-
- private static Model addDependencies(final Environment env, final ProjectInfo info)
- throws MavenExecutionException {
- if ( info.done == true ) {
- env.logger.debug("Return prepared model for " + info.project);
- return info.model;
- }
- // prevent recursion and multiple processing
- info.done = true;
- env.logger.debug("Processing project " + info.project);
-
- // read local model
- final String directory = nodeValue(info.plugin,
- "modelDirectory",
- new File(info.project.getBasedir(), "src/main/provisioning").getAbsolutePath());
- final String inlinedModel = nodeValue(info.plugin,
- "model", null);
- try {
- info.localModel = readLocalModel(info.project, inlinedModel, new File(directory), env.logger);
- } catch ( final IOException ioe) {
- throw new MavenExecutionException(ioe.getMessage(), ioe);
- }
-
- // prepare resolver options
- ResolverOptions resolverOptions = new ResolverOptions();
- if (nodeBooleanValue(info.plugin, "usePomVariables", false)) {
- resolverOptions.variableResolver(new PomVariableResolver(info.project));
- }
- if (nodeBooleanValue(info.plugin, "usePomDependencies", false)) {
- resolverOptions.artifactVersionResolver(new PomArtifactVersionResolver(info.project,
- nodeBooleanValue(info.plugin, "allowUnresolvedPomDependencies", false)));
- }
-
- // we have to create an effective model to add the dependencies
- final Model effectiveModel = ModelUtility.getEffectiveModel(info.localModel, resolverOptions);
-
- final List<Model> dependencies = searchSlingstartDependencies(env, info, info.localModel, effectiveModel);
- info.model = new Model();
- for(final Model d : dependencies) {
- ModelUtility.merge(info.model, d);
- }
- ModelUtility.merge(info.model, info.localModel);
- info.localModel = info.model;
- info.model = ModelUtility.getEffectiveModel(info.model, resolverOptions);
-
- final Map<Traceable, String> errors = ModelUtility.validate(info.model);
- if ( errors != null ) {
- throw new MavenExecutionException("Unable to create model file for " + info.project + " : " + errors, (File)null);
- }
-
- addDependenciesFromModel(env, info);
-
- try {
- ProjectHelper.storeProjectInfo(info);
- } catch ( final IOException ioe) {
- throw new MavenExecutionException(ioe.getMessage(), ioe);
- }
- return info.model;
- }
-
- /**
- * Add all dependencies from the model
- * @param project The project
- * @param model The model
- * @param log The logger
- * @throws MavenExecutionException
- */
- private static void addDependenciesFromModel(
- final Environment env,
- final ProjectInfo info)
- throws MavenExecutionException {
- if ( info.project.getPackaging().equals(BuildConstants.PACKAGING_SLINGSTART ) ) {
- // add base artifact if defined in current model
- final org.apache.sling.provisioning.model.Artifact baseArtifact = ModelUtils.findBaseArtifact(info.model);
-
- final String[] classifiers = new String[] {null, BuildConstants.CLASSIFIER_APP, BuildConstants.CLASSIFIER_WEBAPP};
- for(final String c : classifiers) {
- final Dependency dep = new Dependency();
- dep.setGroupId(baseArtifact.getGroupId());
- dep.setArtifactId(baseArtifact.getArtifactId());
- dep.setVersion(baseArtifact.getVersion());
- dep.setType(baseArtifact.getType());
- dep.setClassifier(c);
- if ( BuildConstants.CLASSIFIER_WEBAPP.equals(c) ) {
- dep.setType(BuildConstants.TYPE_WAR);
- }
- dep.setScope(Artifact.SCOPE_PROVIDED);
-
- info.project.getDependencies().add(dep);
- env.logger.debug("- adding base dependency " + ModelUtils.toString(dep));
- }
- }
-
- for(final Feature feature : info.model.getFeatures()) {
- // skip launchpad feature
- if ( feature.getName().equals(ModelConstants.FEATURE_LAUNCHPAD) ) {
- continue;
- }
- for(final RunMode runMode : feature.getRunModes()) {
- for(final ArtifactGroup group : runMode.getArtifactGroups()) {
- for(final org.apache.sling.provisioning.model.Artifact a : group) {
- final Dependency dep = new Dependency();
- dep.setGroupId(a.getGroupId());
- dep.setArtifactId(a.getArtifactId());
- dep.setVersion(a.getVersion());
- dep.setType(a.getType());
- dep.setClassifier(a.getClassifier());
-
- dep.setScope(Artifact.SCOPE_PROVIDED);
-
- env.logger.debug("- adding dependency " + ModelUtils.toString(dep));
- info.project.getDependencies().add(dep);
- }
- }
- }
- }
- }
-
- /**
- * Search for dependent slingstart/slingfeature artifacts and remove them from the effective model.
- * @throws MavenExecutionException
- */
- private static List<Model> searchSlingstartDependencies(
- final Environment env,
- final ProjectInfo info,
- final Model rawModel,
- final Model effectiveModel)
- throws MavenExecutionException {
- // slingstart or slingfeature
- final List<Model> dependencies = new ArrayList<Model>();
-
- for(final Feature feature : effectiveModel.getFeatures()) {
- for(final RunMode runMode : feature.getRunModes()) {
- for(final ArtifactGroup group : runMode.getArtifactGroups()) {
- final List<org.apache.sling.provisioning.model.Artifact> removeList = new ArrayList<org.apache.sling.provisioning.model.Artifact>();
- for(final org.apache.sling.provisioning.model.Artifact a : group) {
- if ( a.getType().equals(BuildConstants.PACKAGING_SLINGSTART)
- || a.getType().equals(BuildConstants.PACKAGING_PARTIAL_SYSTEM)) {
-
- final Dependency dep = new Dependency();
- dep.setGroupId(a.getGroupId());
- dep.setArtifactId(a.getArtifactId());
- dep.setVersion(a.getVersion());
- dep.setType(BuildConstants.PACKAGING_PARTIAL_SYSTEM);
- if ( a.getType().equals(BuildConstants.PACKAGING_SLINGSTART) ) {
- dep.setClassifier(BuildConstants.PACKAGING_PARTIAL_SYSTEM);
- } else {
- dep.setClassifier(a.getClassifier());
- }
- dep.setScope(Artifact.SCOPE_PROVIDED);
-
- env.logger.debug("- adding dependency " + ModelUtils.toString(dep));
- info.project.getDependencies().add(dep);
-
- // if it's a project from the current reactor build, we can't resolve it right now
- final String key = a.getGroupId() + ":" + a.getArtifactId();
- final ProjectInfo depInfo = env.modelProjects.get(key);
- if ( depInfo != null ) {
- env.logger.debug("Found reactor " + a.getType() + " dependency : " + a);
- final Model model = addDependencies(env, depInfo);
- if ( model == null ) {
- throw new MavenExecutionException("Recursive model dependency list including project " + info.project, (File)null);
- }
- dependencies.add(model);
- info.includedModels.put(a, depInfo.localModel);
-
- } else {
- env.logger.debug("Found external " + a.getType() + " dependency: " + a);
-
- // "external" dependency, we can already resolve it
- final File modelFile = resolveSlingstartArtifact(env, info.project, dep);
- FileReader r = null;
- try {
- r = new FileReader(modelFile);
- final Model model = ModelReader.read(r, modelFile.getAbsolutePath());
-
- info.includedModels.put(a, model);
-
- final Map<Traceable, String> errors = ModelUtility.validate(model);
- if ( errors != null ) {
- throw new MavenExecutionException("Unable to read model file from " + modelFile + " : " + errors, modelFile);
- }
- final Model fullModel = processSlingstartDependencies(env, info, dep, model);
-
- dependencies.add(fullModel);
- } catch ( final IOException ioe) {
- throw new MavenExecutionException("Unable to read model file from " + modelFile, ioe);
- } finally {
- try {
- if ( r != null ) {
- r.close();
- }
- } catch ( final IOException io) {
- // ignore
- }
- }
- }
-
- removeList.add(a);
- }
- }
- for(final org.apache.sling.provisioning.model.Artifact r : removeList) {
- group.remove(r);
- final Feature localModelFeature = rawModel.getFeature(feature.getName());
- if ( localModelFeature != null ) {
- final RunMode localRunMode = localModelFeature.getRunMode(runMode.getNames());
- if ( localRunMode != null ) {
- final ArtifactGroup localAG = localRunMode.getArtifactGroup(group.getStartLevel());
- if ( localAG != null ) {
- localAG.remove(r);
- }
- }
- }
- }
- }
- }
- }
-
- return dependencies;
- }
-
- private static Model processSlingstartDependencies(final Environment env, final ProjectInfo info, final Dependency dep, final Model rawModel)
- throws MavenExecutionException {
- env.logger.debug("Processing dependency " + dep);
-
- // we have to create an effective model to add the dependencies
- final Model effectiveModel = ModelUtility.getEffectiveModel(rawModel, new ResolverOptions());
-
- final List<Model> dependencies = searchSlingstartDependencies(env, info, rawModel, effectiveModel);
- Model mergingModel = new Model();
- for(final Model d : dependencies) {
- ModelUtility.merge(mergingModel, d);
- }
- ModelUtility.merge(mergingModel, rawModel);
-
- final Map<Traceable, String> errors = ModelUtility.validate(ModelUtility.getEffectiveModel(mergingModel, new ResolverOptions()));
- if ( errors != null ) {
- throw new MavenExecutionException("Unable to create model file for " + dep + " : " + errors, (File)null);
- }
-
- return mergingModel;
- }
-
- /**
- * Gets plugins configuration from POM (string parameter).
- * @param plugin Plugin
- * @param name Configuration parameter.
- * @param defaultValue Default value that is returned if parameter is not set
- * @return Parameter value or default value.
- */
- private static String nodeValue(final Plugin plugin, final String name, final String defaultValue) {
- final Xpp3Dom config = plugin == null ? null : (Xpp3Dom)plugin.getConfiguration();
- final Xpp3Dom node = (config == null ? null : config.getChild(name));
- if (node != null) {
- return node.getValue();
- } else {
- return defaultValue;
- }
- }
-
- /**
- * Gets plugins configuration from POM (boolean parameter).
- * @param plugin Plugin
- * @param name Configuration parameter.
- * @param defaultValue Default value that is returned if parameter is not set
- * @return Parameter value or default value.
- */
- private static boolean nodeBooleanValue(final Plugin plugin, final String name, final boolean defaultValue) {
- String booleanValue = nodeValue(plugin, name, Boolean.toString(defaultValue));
- return "true".equals(booleanValue.toLowerCase());
- }
-
- private static File resolveSlingstartArtifact(final Environment env,
- final MavenProject project,
- final Dependency d)
- throws MavenExecutionException {
- final Artifact prjArtifact = new DefaultArtifact(d.getGroupId(),
- d.getArtifactId(),
- VersionRange.createFromVersion(d.getVersion()),
- Artifact.SCOPE_PROVIDED,
- d.getType(),
- d.getClassifier(),
- env.artifactHandlerManager.getArtifactHandler(d.getType()));
- try {
- env.resolver.resolve(prjArtifact, project.getRemoteArtifactRepositories(), env.session.getLocalRepository());
- } catch (final ArtifactResolutionException e) {
- throw new MavenExecutionException("Unable to get artifact for " + d, e);
- } catch (final ArtifactNotFoundException e) {
- throw new MavenExecutionException("Unable to get artifact for " + d, e);
- }
- return prjArtifact.getFile();
- }
-
- /**
- * Read all model files from the directory in alphabetical order.
- * Only files ending with .txt or .model are read.
- *
- * @param project The current maven project
- * @param modelDirectory The directory to scan for models
- * @param logger The logger
- */
- private static Model readLocalModel(
- final MavenProject project,
- final String inlinedModel,
- final File modelDirectory,
- final Logger logger)
- throws MavenExecutionException, IOException {
- final List<String> candidates = new ArrayList<String>();
- if ( modelDirectory != null && modelDirectory.exists() ) {
- for(final File f : modelDirectory.listFiles() ) {
- if ( f.isFile() && !f.getName().startsWith(".") ) {
- if ( f.getName().endsWith(".txt") || f.getName().endsWith(".model") ) {
- candidates.add(f.getName());
- }
- }
- }
- Collections.sort(candidates);
- }
- if ( candidates.size() == 0 && (inlinedModel == null || inlinedModel.trim().length() == 0) ) {
- throw new MavenExecutionException("No model files found in " + modelDirectory + ", and no model inlined in POM.", (File)null);
- }
- final Model result = new Model();
- if ( inlinedModel != null ) {
- logger.debug("Reading inlined model from project " + project.getId());
- try {
- final Reader reader = new StringReader(inlinedModel);
- try {
- final Model current = ModelReader.read(reader, "pom");
- final Map<Traceable, String> errors = ModelUtility.validate(current);
- if (errors != null ) {
- throw new MavenExecutionException("Invalid inlined model : " + errors, (File)null);
- }
- ModelUtility.merge(result, current, false);
- } finally {
- IOUtils.closeQuietly(reader);
- }
- } catch ( final IOException io) {
- throw new MavenExecutionException("Unable to read inlined model", io);
- }
- }
- for(final String name : candidates) {
- logger.debug("Reading model " + name + " in project " + project.getId());
- try {
- final File f = new File(modelDirectory, name);
- final FileReader reader = new FileReader(f);
- try {
- final Model current = ModelReader.read(reader, f.getAbsolutePath());
- final Map<Traceable, String> errors = ModelUtility.validate(current);
- if (errors != null ) {
- throw new MavenExecutionException("Invalid model at " + name + " : " + errors, (File)null);
- }
- ModelUtility.merge(result, current, false);
- } finally {
- IOUtils.closeQuietly(reader);
- }
- } catch ( final IOException io) {
- throw new MavenExecutionException("Unable to read model at " + name, io);
- }
- }
-
- final Map<Traceable, String> errors = ModelUtility.validate(result);
- if (errors != null ) {
- throw new MavenExecutionException("Invalid assembled model : " + errors, (File)null);
- }
-
- return result;
+ new ModelPreprocessor().addDependencies(env);
}
}
diff --git a/src/main/java/org/apache/sling/maven/slingstart/DependencyLifecycleParticipant.java b/src/main/java/org/apache/sling/maven/slingstart/ModelPreprocessor.java
similarity index 86%
copy from src/main/java/org/apache/sling/maven/slingstart/DependencyLifecycleParticipant.java
copy to src/main/java/org/apache/sling/maven/slingstart/ModelPreprocessor.java
index 8a51986..26c8b0f 100644
--- a/src/main/java/org/apache/sling/maven/slingstart/DependencyLifecycleParticipant.java
+++ b/src/main/java/org/apache/sling/maven/slingstart/ModelPreprocessor.java
@@ -28,7 +28,6 @@ import java.util.List;
import java.util.Map;
import org.apache.commons.io.IOUtils;
-import org.apache.maven.AbstractMavenLifecycleParticipant;
import org.apache.maven.MavenExecutionException;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.DefaultArtifact;
@@ -50,31 +49,10 @@ import org.apache.sling.provisioning.model.ModelUtility.ResolverOptions;
import org.apache.sling.provisioning.model.RunMode;
import org.apache.sling.provisioning.model.Traceable;
import org.apache.sling.provisioning.model.io.ModelReader;
-import org.codehaus.plexus.component.annotations.Component;
-import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.util.xml.Xpp3Dom;
-/**
- * Maven lifecycle participant which adds the artifacts of the model to the dependencies.
- */
-@Component(role = AbstractMavenLifecycleParticipant.class)
-public class DependencyLifecycleParticipant extends AbstractMavenLifecycleParticipant {
-
- private static final String PLUGIN_ID = "slingstart-maven-plugin";
-
- @Requirement
- private Logger logger;
-
- @Requirement
- private ArtifactHandlerManager artifactHandlerManager;
-
- /**
- * Used to look up Artifacts in the remote repository.
- *
- */
- @Requirement
- private ArtifactResolver resolver;
+public class ModelPreprocessor {
public static final class ProjectInfo {
@@ -95,43 +73,13 @@ public class DependencyLifecycleParticipant extends AbstractMavenLifecyclePartic
public final Map<String, ProjectInfo> modelProjects = new HashMap<String, ProjectInfo>();
}
- @Override
- public void afterProjectsRead(final MavenSession session) throws MavenExecutionException {
- final Environment env = new Environment();
- env.artifactHandlerManager = artifactHandlerManager;
- env.resolver = resolver;
- env.logger = logger;
- env.session = session;
-
- logger.debug("Searching for " + BuildConstants.PACKAGING_SLINGSTART + "/" + BuildConstants.PACKAGING_PARTIAL_SYSTEM + " projects...");
-
- for (final MavenProject project : session.getProjects()) {
- if ( project.getPackaging().equals(BuildConstants.PACKAGING_SLINGSTART)
- || project.getPackaging().equals(BuildConstants.PACKAGING_PARTIAL_SYSTEM)) {
- logger.debug("Found " + project.getPackaging() + " project: " + project);
- // search plugin configuration (optional)
- final ProjectInfo info = new ProjectInfo();
- for (Plugin plugin : project.getBuild().getPlugins()) {
- if (plugin.getArtifactId().equals(PLUGIN_ID)) {
- info.plugin = plugin;
- break;
- }
- }
- info.project = project;
- env.modelProjects.put(project.getGroupId() + ":" + project.getArtifactId(), info);
- }
- }
-
- addDependencies(env);
- }
-
- public static void addDependencies(final Environment env) throws MavenExecutionException {
+ public void addDependencies(final Environment env) throws MavenExecutionException {
for(final ProjectInfo info : env.modelProjects.values()) {
addDependencies(env, info);
}
}
- private static Model addDependencies(final Environment env, final ProjectInfo info)
+ private Model addDependencies(final Environment env, final ProjectInfo info)
throws MavenExecutionException {
if ( info.done == true ) {
env.logger.debug("Return prepared model for " + info.project);
@@ -169,9 +117,9 @@ public class DependencyLifecycleParticipant extends AbstractMavenLifecyclePartic
final List<Model> dependencies = searchSlingstartDependencies(env, info, info.localModel, effectiveModel);
info.model = new Model();
for(final Model d : dependencies) {
- ModelUtility.merge(info.model, d);
+ this.mergeModels(info.model, d);
}
- ModelUtility.merge(info.model, info.localModel);
+ this.mergeModels(info.model, info.localModel);
info.localModel = info.model;
info.model = ModelUtility.getEffectiveModel(info.model, resolverOptions);
@@ -197,7 +145,7 @@ public class DependencyLifecycleParticipant extends AbstractMavenLifecyclePartic
* @param log The logger
* @throws MavenExecutionException
*/
- private static void addDependenciesFromModel(
+ private void addDependenciesFromModel(
final Environment env,
final ProjectInfo info)
throws MavenExecutionException {
@@ -252,7 +200,7 @@ public class DependencyLifecycleParticipant extends AbstractMavenLifecyclePartic
* Search for dependent slingstart/slingfeature artifacts and remove them from the effective model.
* @throws MavenExecutionException
*/
- private static List<Model> searchSlingstartDependencies(
+ private List<Model> searchSlingstartDependencies(
final Environment env,
final ProjectInfo info,
final Model rawModel,
@@ -351,7 +299,7 @@ public class DependencyLifecycleParticipant extends AbstractMavenLifecyclePartic
return dependencies;
}
- private static Model processSlingstartDependencies(final Environment env, final ProjectInfo info, final Dependency dep, final Model rawModel)
+ private Model processSlingstartDependencies(final Environment env, final ProjectInfo info, final Dependency dep, final Model rawModel)
throws MavenExecutionException {
env.logger.debug("Processing dependency " + dep);
@@ -361,9 +309,9 @@ public class DependencyLifecycleParticipant extends AbstractMavenLifecyclePartic
final List<Model> dependencies = searchSlingstartDependencies(env, info, rawModel, effectiveModel);
Model mergingModel = new Model();
for(final Model d : dependencies) {
- ModelUtility.merge(mergingModel, d);
+ this.mergeModels(mergingModel, d);
}
- ModelUtility.merge(mergingModel, rawModel);
+ this.mergeModels(mergingModel, rawModel);
final Map<Traceable, String> errors = ModelUtility.validate(ModelUtility.getEffectiveModel(mergingModel, new ResolverOptions()));
if ( errors != null ) {
@@ -380,7 +328,7 @@ public class DependencyLifecycleParticipant extends AbstractMavenLifecyclePartic
* @param defaultValue Default value that is returned if parameter is not set
* @return Parameter value or default value.
*/
- private static String nodeValue(final Plugin plugin, final String name, final String defaultValue) {
+ private String nodeValue(final Plugin plugin, final String name, final String defaultValue) {
final Xpp3Dom config = plugin == null ? null : (Xpp3Dom)plugin.getConfiguration();
final Xpp3Dom node = (config == null ? null : config.getChild(name));
if (node != null) {
@@ -397,12 +345,12 @@ public class DependencyLifecycleParticipant extends AbstractMavenLifecyclePartic
* @param defaultValue Default value that is returned if parameter is not set
* @return Parameter value or default value.
*/
- private static boolean nodeBooleanValue(final Plugin plugin, final String name, final boolean defaultValue) {
+ private boolean nodeBooleanValue(final Plugin plugin, final String name, final boolean defaultValue) {
String booleanValue = nodeValue(plugin, name, Boolean.toString(defaultValue));
return "true".equals(booleanValue.toLowerCase());
}
- private static File resolveSlingstartArtifact(final Environment env,
+ private File resolveSlingstartArtifact(final Environment env,
final MavenProject project,
final Dependency d)
throws MavenExecutionException {
@@ -431,7 +379,7 @@ public class DependencyLifecycleParticipant extends AbstractMavenLifecyclePartic
* @param modelDirectory The directory to scan for models
* @param logger The logger
*/
- private static Model readLocalModel(
+ protected Model readLocalModel(
final MavenProject project,
final String inlinedModel,
final File modelDirectory,
@@ -495,6 +443,24 @@ public class DependencyLifecycleParticipant extends AbstractMavenLifecyclePartic
throw new MavenExecutionException("Invalid assembled model : " + errors, (File)null);
}
+ return postProcessReadModel(result);
+ }
+
+ /**
+ * Hook to post process the local model
+ * @param result The read model
+ * @return The post processed model
+ */
+ protected Model postProcessReadModel(final Model result) throws MavenExecutionException {
return result;
}
+
+ /**
+ * Hook to change the merge behavior
+ * @param base The base model
+ * @param additional The additional model
+ */
+ protected void mergeModels(final Model base, final Model additional) throws MavenExecutionException {
+ ModelUtility.merge(base, additional);
+ }
}
diff --git a/src/main/java/org/apache/sling/maven/slingstart/ProjectHelper.java b/src/main/java/org/apache/sling/maven/slingstart/ProjectHelper.java
index 35ec739..a454bd0 100644
--- a/src/main/java/org/apache/sling/maven/slingstart/ProjectHelper.java
+++ b/src/main/java/org/apache/sling/maven/slingstart/ProjectHelper.java
@@ -48,7 +48,7 @@ public abstract class ProjectHelper {
* @param info The project info
* @throws IOException If writing fails
*/
- public static void storeProjectInfo(final DependencyLifecycleParticipant.ProjectInfo info)
+ public static void storeProjectInfo(final ModelPreprocessor.ProjectInfo info)
throws IOException {
// we have to serialize as the dependency lifecycle participant uses a different class loader (!)
final StringWriter w1 = new StringWriter();
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-slingstart-maven-plugin] 04/13: SLING-5149 - Generate OSGi
subsystem intermediary file in slingstart-maven-plugin
Posted by ro...@apache.org.
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 b98555ae50014f9532229eae7d1a796a36b51f48
Author: Robert Munteanu <ro...@apache.org>
AuthorDate: Thu Nov 5 17:05:46 2015 +0000
SLING-5149 - Generate OSGi subsystem intermediary file in
slingstart-maven-plugin
Submitted-By: David Bosschaert
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/tooling/maven/slingstart-maven-plugin@1712818 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 52 ++++-
.../sling/maven/slingstart/PreparePackageMojo.java | 211 +++++++++++++++++-
src/main/resources/subsystem-base/readme.txt | 36 ++++
.../maven/slingstart/PreparePackageMojoTest.java | 239 +++++++++++++++++++++
4 files changed, 527 insertions(+), 11 deletions(-)
diff --git a/pom.xml b/pom.xml
index 554292c..1d30ec8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -86,7 +86,7 @@
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.provisioning.model</artifactId>
- <version>1.3.0</version>
+ <version>1.4.0</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
@@ -168,5 +168,55 @@
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <version>1.10.19</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- The following artifacts are purely used by the unit tests
+ so these dependencies ensures that they are in the .m2 directory -->
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.commons.classloader</artifactId>
+ <version>1.3.2</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.commons.contentdetection</artifactId>
+ <version>1.0.2</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.commons.json</artifactId>
+ <version>2.0.12</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.commons.mime</artifactId>
+ <version>2.1.8</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.commons.osgi</artifactId>
+ <version>2.3.0</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.commons.threads</artifactId>
+ <version>3.2.0</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
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 8e3d5e1..3871246 100644
--- a/src/main/java/org/apache/sling/maven/slingstart/PreparePackageMojo.java
+++ b/src/main/java/org/apache/sling/maven/slingstart/PreparePackageMojo.java
@@ -16,15 +16,25 @@
*/
package org.apache.sling.maven.slingstart;
+import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringReader;
+import java.nio.file.Files;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.TreeSet;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.jar.Attributes;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
import org.apache.commons.io.IOUtils;
import org.apache.felix.cm.file.ConfigurationHandler;
@@ -41,9 +51,11 @@ import org.apache.maven.plugins.annotations.ResolutionScope;
import org.apache.sling.provisioning.model.ArtifactGroup;
import org.apache.sling.provisioning.model.Configuration;
import org.apache.sling.provisioning.model.Feature;
+import org.apache.sling.provisioning.model.FeatureTypes;
import org.apache.sling.provisioning.model.Model;
import org.apache.sling.provisioning.model.ModelConstants;
import org.apache.sling.provisioning.model.RunMode;
+import org.apache.sling.provisioning.model.Section;
import org.codehaus.plexus.archiver.ArchiverException;
import org.codehaus.plexus.archiver.UnArchiver;
import org.codehaus.plexus.archiver.manager.ArchiverManager;
@@ -60,6 +72,7 @@ import org.codehaus.plexus.util.FileUtils;
threadSafe = true
)
public class PreparePackageMojo extends AbstractSlingStartMojo {
+ private static final String ALL_RUNMODES_KEY = "_all_";
private static final String BASE_DESTINATION = "resources";
@@ -93,6 +106,10 @@ public class PreparePackageMojo extends AbstractSlingStartMojo {
public void execute() throws MojoExecutionException, MojoFailureException {
final Model model = ProjectHelper.getEffectiveModel(this.project, getResolverOptions());
+ execute(model);
+ }
+
+ void execute(final Model model) throws MojoExecutionException {
this.prepareGlobal(model);
this.prepareStandaloneApp(model);
this.prepareWebapp(model);
@@ -177,22 +194,34 @@ public class PreparePackageMojo extends AbstractSlingStartMojo {
for(final Feature feature : model.getFeatures()) {
if ( feature.isSpecial() && !feature.getName().equals(ModelConstants.FEATURE_BOOT)) {
continue;
- }
- for(final RunMode runMode : feature.getRunModes()) {
- if ( packageRunMode == null ) {
- if ( runMode.isSpecial() ) {
- continue;
- }
- this.buildContentsMap(model, runMode, contentsMap, feature.getName().equals(ModelConstants.FEATURE_BOOT));
- } else {
- if ( runMode.isRunMode(packageRunMode) ) {
+ } else if (FeatureTypes.SUBSYSTEM_APPLICATION.equals(feature.getType()) ||
+ FeatureTypes.SUBSYSTEM_COMPOSITE.equals(feature.getType()) ||
+ FeatureTypes.SUBSYSTEM_FEATURE.equals(feature.getType())) {
+ buildSubsystemBase(contentsMap, feature);
+ } else {
+ for(final RunMode runMode : feature.getRunModes()) {
+ if ( packageRunMode == null ) {
+ if ( runMode.isSpecial() ) {
+ continue;
+ }
this.buildContentsMap(model, runMode, contentsMap, feature.getName().equals(ModelConstants.FEATURE_BOOT));
+ } else {
+ if ( runMode.isRunMode(packageRunMode) ) {
+ this.buildContentsMap(model, runMode, contentsMap, feature.getName().equals(ModelConstants.FEATURE_BOOT));
+ }
}
}
}
}
}
+ private void buildSubsystemBase(final Map<String, File> contentsMap, final Feature feature) throws MojoExecutionException {
+ AtomicInteger startLevelHolder = new AtomicInteger(); // Used as output argument
+ File subsystemFile = createSubsystemBaseFile(feature, startLevelHolder);
+ if (subsystemFile != null)
+ contentsMap.put(getPathForArtifact(startLevelHolder.get(), subsystemFile.getName()), subsystemFile);
+ }
+
/**
* Build a list of all artifacts from this run mode
*/
@@ -235,6 +264,164 @@ public class PreparePackageMojo extends AbstractSlingStartMojo {
}
}
+
+ private File createSubsystemBaseFile(Feature feature, AtomicInteger startLevelHolder) throws MojoExecutionException {
+ File subsystemFile = new File(getTmpDir(), feature.getName() + ".subsystem-base");
+ if (subsystemFile.exists()) {
+ // This subsystem has already been created
+ // TODO is there a better way to avoid calling this multiple times?
+ return null;
+ }
+
+ startLevelHolder.set(-1);
+
+ // The runmodes information has to be the first item in the archive so that we always have it available when the
+ // archive is being processed. For this reason a Jar file is used here as it's guaranteed to store the manifest
+ // first.
+ Manifest runModesManifest = getRunModesManifest(feature);
+
+ getLog().info("Creating subsystem base file: " + subsystemFile.getName());
+ subsystemFile.getParentFile().mkdirs();
+
+ try (JarOutputStream os = new JarOutputStream(new FileOutputStream(subsystemFile), runModesManifest)) {
+ Map<String, Integer> bsnStartOrderMap = new HashMap<>();
+
+ for (RunMode rm : feature.getRunModes()) {
+ for (ArtifactGroup ag : rm.getArtifactGroups()) {
+ int startOrder = ag.getStartLevel(); // For subsystems the start level on the artifact group is used as start order.
+
+ for (org.apache.sling.provisioning.model.Artifact a : ag) {
+ Artifact artifact = ModelUtils.getArtifact(this.project, this.mavenSession, this.artifactHandlerManager, this.resolver,
+ a.getGroupId(), a.getArtifactId(), a.getVersion(), a.getType(), a.getClassifier());
+ File artifactFile = artifact.getFile();
+ String entryName = getEntryName(artifactFile, startOrder);
+
+ ZipEntry ze = new ZipEntry(entryName);
+ try {
+ os.putNextEntry(ze);
+ Files.copy(artifactFile.toPath(), os);
+ } finally {
+ os.closeEntry();
+ }
+ }
+ }
+ }
+
+ int sl = createSubsystemManifest(feature, bsnStartOrderMap, os);
+ if (sl != -1)
+ startLevelHolder.set(sl);
+ addReadme(os);
+ } catch (IOException ioe) {
+ throw new MojoExecutionException("Problem creating subsystem .esa file " + subsystemFile, ioe);
+ }
+ return subsystemFile;
+ }
+
+ private Manifest getRunModesManifest(Feature feature) throws MojoExecutionException {
+ Map<String, StringBuilder> runModes = new HashMap<>();
+
+ for (RunMode rm : feature.getRunModes()) {
+ for (ArtifactGroup ag : rm.getArtifactGroups()) {
+ int startOrder = ag.getStartLevel(); // For subsystems the start level on the artifact group is used as start order.
+
+ for (org.apache.sling.provisioning.model.Artifact a : ag) {
+ Artifact artifact = ModelUtils.getArtifact(this.project, this.mavenSession, this.artifactHandlerManager, this.resolver,
+ a.getGroupId(), a.getArtifactId(), a.getVersion(), a.getType(), a.getClassifier());
+ File artifactFile = artifact.getFile();
+ String entryName = getEntryName(artifactFile, startOrder);
+
+ String [] runModeNames = rm.getNames();
+ if (runModeNames == null)
+ runModeNames = new String[] {ALL_RUNMODES_KEY};
+
+ for (String runModeName : runModeNames) {
+ StringBuilder sb = runModes.get(runModeName);
+ if (sb == null) {
+ sb = new StringBuilder();
+ runModes.put(runModeName, sb);
+ } else {
+ sb.append('|');
+ }
+
+ sb.append(entryName);
+ }
+ }
+ }
+ }
+
+ Manifest mf = new Manifest();
+ Attributes attrs = mf.getMainAttributes();
+ attrs.putValue("Manifest-Version", "1.0"); // Manifest does not work without this value
+ attrs.putValue("About-This-Manifest", "This is not a real manifest, it is used as information when this archive is transformed into a real subsystem .esa file");
+ for (Map.Entry<String, StringBuilder> entry : runModes.entrySet()) {
+ attrs.putValue(entry.getKey(), entry.getValue().toString());
+ }
+ return mf;
+ }
+
+ private String getEntryName(File artifactFile, int startOrder) {
+ return "Potential_Bundles/" + startOrder + "/" + artifactFile.getName();
+ }
+
+ // This manifest will be used as the basis for the OSGI-INF/SUBSYSTEM.MF file when the real
+ // .esa file is generated. However since some contents of that file depend on the actual
+ // runmode that is being executed, additional information will be added to the SUBSYSTEM.MF
+ // file at startup time before it's finalized (example: Subsystem-Content).
+ private int createSubsystemManifest(Feature feature,
+ Map<String, Integer> startOrderMap, ZipOutputStream os) throws IOException {
+ int subsystemStartLevel = -1;
+ ZipEntry ze = new ZipEntry("SUBSYSTEM-MANIFEST-BASE.MF");
+ try {
+ os.putNextEntry(ze);
+
+ Manifest mf = new Manifest();
+ Attributes attributes = mf.getMainAttributes();
+ attributes.putValue("Manifest-Version", "1.0"); // Manifest does not work without this value
+ attributes.putValue("Subsystem-SymbolicName", feature.getName());
+ attributes.putValue("Subsystem-Version", "1"); // Version must be an integer (cannot be a long), TODO better idea?
+ attributes.putValue("Subsystem-Type", feature.getType());
+ for (Section section : feature.getAdditionalSections("subsystem-manifest")) {
+ String sl = section.getAttributes().get("startLevel");
+ try {
+ subsystemStartLevel = Integer.parseInt(sl);
+ } catch (NumberFormatException nfe) {
+ // Not a valid start level
+ }
+
+ BufferedReader br = new BufferedReader(new StringReader(section.getContents()));
+ String line = null;
+ while ((line = br.readLine()) != null) {
+ int idx = line.indexOf(':');
+ if (idx > 0) {
+ String key = line.substring(0, idx);
+ String value;
+ idx++;
+ if (line.length() > idx)
+ value = line.substring(idx);
+ else
+ value = "";
+ attributes.putValue(key.trim(), value.trim());
+ }
+ }
+ }
+ mf.write(os);
+ } finally {
+ os.closeEntry();
+ }
+
+ return subsystemStartLevel;
+ }
+
+ private void addReadme(ZipOutputStream os) throws IOException {
+ ZipEntry ze = new ZipEntry("readme.txt");
+ try (InputStream is = getClass().getResourceAsStream("/subsystem-base/readme.txt")) {
+ os.putNextEntry(ze);
+ IOUtils.copy(is, os);
+ } finally {
+ os.closeEntry();
+ }
+ }
+
/**
* Build the settings for the given packaging run mode
*/
@@ -385,12 +572,16 @@ public class PreparePackageMojo extends AbstractSlingStartMojo {
}
}
+ private String getPathForArtifact(final int startLevel, final String artifactName) {
+ return getPathForArtifact(startLevel, artifactName, null, false);
+ }
+
/**
* Get the relative path for an artifact.
*/
private String getPathForArtifact(final int startLevel, final String artifactName, final RunMode rm, final boolean isBoot) {
final Set<String> runModesList = new TreeSet<String>();
- if (rm.getNames() != null ) {
+ if ( rm != null && rm.getNames() != null ) {
for(final String mode : rm.getNames()) {
runModesList.add(mode);
}
diff --git a/src/main/resources/subsystem-base/readme.txt b/src/main/resources/subsystem-base/readme.txt
new file mode 100644
index 0000000..29c6711
--- /dev/null
+++ b/src/main/resources/subsystem-base/readme.txt
@@ -0,0 +1,36 @@
+A .subsystem-base jar file is produced from the sling provisioning model by the sling-maven-plugin as an intermediary file that is turned into a subsystem file .esa at runtime by the org.apache.sling.installer.factory.subsystems-base bundle. The actual content of the subsystem at runtime is determined by the current run mode. The transformer creates an .esa file that contains the right resources according to the current runmode.
+
+A subsystem-base file is generated from features in the sling provisioning model of type osgi.subsystem.application, osgi.subsystem.composite or osgi.subsystem.feature. For example:
+
+[feature name=mysubsystem type=osgi.subsystem.feature]
+
+[:subsystem-manifest startLevel=20]
+ Subsystem-Description: Extra subsystem headers can go here
+ Subsystem-Copyright: (c) 2015 for example
+
+[artifacts]
+ com.foo.bar/bundle/1
+
+[artifacts startLevel=10]
+ com.foo.bar/bundle1/1.2.3
+ com.foo.bar/bundle2/1.0.0
+
+[artifacts startLevel=15 runModes=myrunmode]
+ com.foo.bar/bundle3/0.0.1
+
+The above provisioning model description will generate a mysubsystem.subsystem-base jar file. The bundles in the subsystem will *all* have start level 20, from the startLevel in the :subsystem-manifest section. The mysubsystem.subsystem-base file will be placed in the install/20/mysubsystem.subsystem-base location of the generated sling-maven-plugin generated slingstart artifact. The startLevel attribute on the artifacts section are transformed into start-order attributes on the Subsyste [...]
+The generated mysubsystem.subsystem-base file will have the following content:
+
+META-INF/MANIFEST.MF
+Potential_Bundles/0/bundle-1.jar
+Potential_Bundles/10/bundle1-1.2.3.jar
+Potential_Bundles/10/bundle2-1.0.0.jar
+Potential_Bundles/15/bundle3-0.0.1.jar
+SUBSYSTEM-MANIFEST-BASE.MF
+readme.txt (this file).
+
+The META-INF/MANIFEST.MF file contains information about which resources should be deployed based on runmode. There is a special identifier _all_ which lists resources that should be deployed in all runmodes.
+The Potential_Bundles locations hold the actual resources in directories that denote their start-order.
+The SUBSYSTEM-MANIFEST-BASE.MF file is used as the basis for the OSGI-INF/SUBSYSTEM.MF file in the .esa file. The Subsystem-SymbolicName, Subsystem-Type, Subsystem-Version and Subsystem-Content are automatically generated. Additional headers listed under the [:subsystem-manifest] section are added to the ultimate SUBSYSTEM.MF. The Subsystem-Content is generated by the SubsystemBaseTransformer based on the current runmode.
+
+This file is included in the .subsystem-base file as a readme as this is not a common file format.
diff --git a/src/test/java/org/apache/sling/maven/slingstart/PreparePackageMojoTest.java b/src/test/java/org/apache/sling/maven/slingstart/PreparePackageMojoTest.java
new file mode 100644
index 0000000..4f8a427
--- /dev/null
+++ b/src/test/java/org/apache/sling/maven/slingstart/PreparePackageMojoTest.java
@@ -0,0 +1,239 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.maven.slingstart;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringReader;
+import java.lang.reflect.Field;
+import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.jar.Attributes;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+import java.util.zip.ZipEntry;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.maven.artifact.DefaultArtifact;
+import org.apache.maven.artifact.handler.ArtifactHandler;
+import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
+import org.apache.maven.artifact.resolver.ArtifactResolver;
+import org.apache.maven.execution.MavenSession;
+import org.apache.maven.model.Build;
+import org.apache.maven.project.MavenProject;
+import org.apache.sling.provisioning.model.Model;
+import org.apache.sling.provisioning.model.io.ModelReader;
+import org.codehaus.plexus.archiver.UnArchiver;
+import org.codehaus.plexus.archiver.manager.ArchiverManager;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+
+public class PreparePackageMojoTest {
+ @Test
+ public void testSubsystemBaseGeneration1() throws Exception {
+ // Provide the system with some artifacts that are known to be in the local .m2 repo
+ // These are explicitly included in the test section of the pom.xml
+ PreparePackageMojo ppm = getMojoUnderTest(
+ "org.apache.sling/org.apache.sling.commons.classloader/1.3.2",
+ "org.apache.sling/org.apache.sling.commons.classloader/1.3.2/app",
+ "org.apache.sling/org.apache.sling.commons.contentdetection/1.0.2",
+ "org.apache.sling/org.apache.sling.commons.json/2.0.12",
+ "org.apache.sling/org.apache.sling.commons.mime/2.1.8",
+ "org.apache.sling/org.apache.sling.commons.osgi/2.3.0",
+ "org.apache.sling/org.apache.sling.commons.threads/3.2.0");
+
+ try {
+ // The launchpad feature is a prerequisite for the model
+ String modelTxt =
+ "[feature name=:launchpad]\n" +
+ "[artifacts]\n" +
+ " org.apache.sling/org.apache.sling.commons.classloader/1.3.2\n" +
+ "" +
+ "[feature name=test1 type=osgi.subsystem.composite]\n" +
+ "" +
+ "[:subsystem-manifest startLevel=123]\n" +
+ " Subsystem-Description: Extra subsystem headers can go here including very long ones that would span multiple lines in a manifest\n" +
+ " Subsystem-Copyright: (c) 2015 yeah!\n" +
+ "" +
+ "[artifacts]\n" +
+ " org.apache.sling/org.apache.sling.commons.osgi/2.3.0\n" +
+ "" +
+ "[artifacts startLevel=10]\n" +
+ " org.apache.sling/org.apache.sling.commons.json/2.0.12\n" +
+ " org.apache.sling/org.apache.sling.commons.mime/2.1.8\n" +
+ "" +
+ "[artifacts startLevel=20 runModes=foo,bar]\n" +
+ " org.apache.sling/org.apache.sling.commons.threads/3.2.0\n" +
+ "" +
+ "[artifacts startLevel=100 runModes=bar]\n" +
+ " org.apache.sling/org.apache.sling.commons.contentdetection/1.0.2\n";
+ Model model = ModelReader.read(new StringReader(modelTxt), null);
+ ppm.execute(model);
+
+ File generatedFile = new File(ppm.getTmpDir() + "/test1.subsystem-base");
+ try (JarFile jf = new JarFile(generatedFile)) {
+ // Test META-INF/MANIFEST.MF
+ Manifest mf = jf.getManifest();
+ Attributes attrs = mf.getMainAttributes();
+ String expected = "Potential_Bundles/0/org.apache.sling.commons.osgi-2.3.0.jar|"
+ + "Potential_Bundles/10/org.apache.sling.commons.json-2.0.12.jar|"
+ + "Potential_Bundles/10/org.apache.sling.commons.mime-2.1.8.jar";
+ assertEquals(expected, attrs.getValue("_all_"));
+ assertEquals("Potential_Bundles/20/org.apache.sling.commons.threads-3.2.0.jar", attrs.getValue("foo"));
+ assertEquals("Potential_Bundles/20/org.apache.sling.commons.threads-3.2.0.jar|"
+ + "Potential_Bundles/100/org.apache.sling.commons.contentdetection-1.0.2.jar", attrs.getValue("bar"));
+
+ // Test SUBSYSTEM-MANIFEST-BASE.MF
+ ZipEntry smbZE = jf.getEntry("SUBSYSTEM-MANIFEST-BASE.MF");
+ try (InputStream smbIS = jf.getInputStream(smbZE)) {
+ Manifest smbMF = new Manifest(smbIS);
+ Attributes smbAttrs = smbMF.getMainAttributes();
+ assertEquals("test1", smbAttrs.getValue("Subsystem-SymbolicName"));
+ assertEquals("osgi.subsystem.composite", smbAttrs.getValue("Subsystem-Type"));
+ assertEquals("(c) 2015 yeah!", smbAttrs.getValue("Subsystem-Copyright"));
+ assertEquals("Extra subsystem headers can go here including very long ones "
+ + "that would span multiple lines in a manifest",
+ smbAttrs.getValue("Subsystem-Description"));
+ }
+
+ // Test embedded bundles
+ File mrr = getMavenRepoRoot();
+ File soj = getMavenArtifactFile(mrr, "org.apache.sling", "org.apache.sling.commons.osgi", "2.3.0");
+ ZipEntry sojZE = jf.getEntry("Potential_Bundles/0/org.apache.sling.commons.osgi-2.3.0.jar");
+ try (InputStream is = jf.getInputStream(sojZE)) {
+ assertArtifactsEqual(soj, is);
+ }
+
+ File sjj = getMavenArtifactFile(mrr, "org.apache.sling", "org.apache.sling.commons.json", "2.0.12");
+ ZipEntry sjZE = jf.getEntry("Potential_Bundles/10/org.apache.sling.commons.json-2.0.12.jar");
+ try (InputStream is = jf.getInputStream(sjZE)) {
+ assertArtifactsEqual(sjj, is);
+ }
+
+ File smj = getMavenArtifactFile(mrr, "org.apache.sling", "org.apache.sling.commons.mime", "2.1.8");
+ ZipEntry smjZE = jf.getEntry("Potential_Bundles/10/org.apache.sling.commons.mime-2.1.8.jar");
+ try (InputStream is = jf.getInputStream(smjZE)) {
+ assertArtifactsEqual(smj, is);
+ }
+
+ File stj = getMavenArtifactFile(mrr, "org.apache.sling", "org.apache.sling.commons.threads", "3.2.0");
+ ZipEntry stjZE = jf.getEntry("Potential_Bundles/20/org.apache.sling.commons.threads-3.2.0.jar");
+ try (InputStream is = jf.getInputStream(stjZE)) {
+ assertArtifactsEqual(stj, is);
+ }
+
+ File ctj = getMavenArtifactFile(mrr, "org.apache.sling", "org.apache.sling.commons.contentdetection", "1.0.2");
+ ZipEntry ctjZE = jf.getEntry("Potential_Bundles/100/org.apache.sling.commons.contentdetection-1.0.2.jar");
+ try (InputStream is = jf.getInputStream(ctjZE)) {
+ assertArtifactsEqual(ctj, is);
+ }
+ }
+ } finally {
+ FileUtils.deleteDirectory(new File(ppm.project.getBuild().getDirectory()));
+ }
+ }
+
+ private void assertArtifactsEqual(File f, InputStream is) throws IOException {
+ byte[] bytes1 = Files.readAllBytes(f.toPath());
+ byte[] bytes2 = IOUtils.toByteArray(is);
+ assertArrayEquals("Bytes not equal on file " + f.getName(), bytes1, bytes2);
+ }
+
+ private PreparePackageMojo getMojoUnderTest(String ... knownArtifacts) throws Exception {
+ File mrr = getMavenRepoRoot();
+
+ ArtifactHandler ah = Mockito.mock(ArtifactHandler.class);
+ ArtifactHandlerManager ahm = Mockito.mock(ArtifactHandlerManager.class);
+ Mockito.when(ahm.getArtifactHandler(Mockito.anyString())).thenReturn(ah);
+
+ Set<org.apache.maven.artifact.Artifact> artifacts = new HashSet<>();
+ for (String s : knownArtifacts) {
+ String[] parts = s.split("[/]");
+ switch (parts.length) {
+ case 3:
+ artifacts.add(getMavenArtifact(mrr, ah, parts[0], parts[1], parts[2]));
+ break;
+ case 4:
+ artifacts.add(getMavenArtifact(mrr, ah, parts[0], parts[1], parts[2], parts[3]));
+ break;
+ default: throw new IllegalStateException(s);
+ }
+ }
+
+ MavenProject mavenPrj = new MavenProject();
+ Build build = new Build();
+ Path tempDir = Files.createTempDirectory(getClass().getSimpleName());
+ build.setOutputDirectory(tempDir.toString());
+ build.setDirectory(tempDir.toString());
+ mavenPrj.setBuild(build);
+ mavenPrj.setDependencyArtifacts(artifacts);
+
+ PreparePackageMojo ppm = new PreparePackageMojo();
+ ppm.mavenSession = Mockito.mock(MavenSession.class);
+ ppm.project = mavenPrj;
+ ArchiverManager am = Mockito.mock(ArchiverManager.class);
+ UnArchiver ua = Mockito.mock(UnArchiver.class);
+ Mockito.when(am.getUnArchiver(Mockito.isA(File.class))).thenReturn(ua);
+ setPrivateField(ppm, "archiverManager", am);
+ setPrivateField(ppm, "artifactHandlerManager", ahm);
+ setPrivateField(ppm, "resolver", Mockito.mock(ArtifactResolver.class));
+ return ppm;
+ }
+
+ private org.apache.maven.artifact.Artifact getMavenArtifact(File repoRoot, ArtifactHandler ah, String gid, String aid, String ver) {
+ return getMavenArtifact(repoRoot, ah, gid, aid, ver, null);
+ }
+
+ private org.apache.maven.artifact.Artifact getMavenArtifact(File repoRoot, ArtifactHandler ah, String gid, String aid, String ver, String classifier) {
+ DefaultArtifact art = new DefaultArtifact(gid, aid, ver, "compile", "jar", classifier, ah);
+ art.setFile(getMavenArtifactFile(repoRoot, gid, aid, ver));
+ return art;
+ }
+
+ private File getMavenArtifactFile(File repoRoot, String gid, String aid, String ver) {
+ return new File(repoRoot, gid.replace('.', '/') + '/' + aid + '/' + ver + '/' + aid + '-' + ver + ".jar");
+ }
+
+ private File getMavenRepoRoot() throws IOException {
+ URL res = getClass().getClassLoader().getResource(
+ Test.class.getName().replace('.', '/') + ".class");
+
+ String u = res.toExternalForm();
+ if (u.startsWith("jar:"))
+ u = u.substring(4);
+
+ int idx = u.indexOf("junit");
+ if (idx < 0)
+ throw new IllegalStateException("Cannot infer maven repo root: " + res);
+
+ return new File(new URL(u.substring(0, idx)).getFile());
+ }
+
+ private void setPrivateField(Object obj, String name, Object val) throws Exception {
+ Field f = obj.getClass().getDeclaredField(name);
+ f.setAccessible(true);
+ f.set(obj, val);
+ }
+}
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-slingstart-maven-plugin] 10/13: Switch to parent pom 26
Posted by ro...@apache.org.
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 9fb072d27ec8ccea7093c5cb04c599f63b53c129
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Sun Jan 3 14:07:46 2016 +0000
Switch to parent pom 26
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/tooling/maven/slingstart-maven-plugin@1722720 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index aa68db7..e07e686 100644
--- a/pom.xml
+++ b/pom.xml
@@ -17,7 +17,7 @@
<parent>
<groupId>org.apache.sling</groupId>
<artifactId>sling</artifactId>
- <version>25</version>
+ <version>26</version>
<relativePath />
</parent>
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-slingstart-maven-plugin] 08/13: Use latest prov model
snapshot version
Posted by ro...@apache.org.
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 b703b6b103ea1706ff0fd71d9ef287a43585095e
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Tue Dec 22 06:10:45 2015 +0000
Use latest prov model snapshot version
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/tooling/maven/slingstart-maven-plugin@1721300 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index acac9db..9dfec5e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -86,7 +86,7 @@
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.provisioning.model</artifactId>
- <version>1.4.1-SNAPSHOT</version>
+ <version>1.4.3-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-slingstart-maven-plugin] 09/13: Use provisioning model 1.4.2
Posted by ro...@apache.org.
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 f2ac4d9a0a9e166629b69d2a925b171813cc2baa
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon Dec 28 13:26:07 2015 +0000
Use provisioning model 1.4.2
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/tooling/maven/slingstart-maven-plugin@1721914 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 9dfec5e..aa68db7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -86,7 +86,7 @@
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.provisioning.model</artifactId>
- <version>1.4.3-SNAPSHOT</version>
+ <version>1.4.2</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-slingstart-maven-plugin] 05/13: SLING-5379 - support
renaming of bundles in maven-slingstart-plugin. Contributed by David
Bosschaert, thanks!
Posted by ro...@apache.org.
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 f6075f8eb62c6234fdd2b0caa9656aa1aaf92248
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Mon Dec 21 15:11:26 2015 +0000
SLING-5379 - support renaming of bundles in maven-slingstart-plugin. Contributed by David Bosschaert, thanks!
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/tooling/maven/slingstart-maven-plugin@1721185 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 13 ++--
.../sling/maven/slingstart/PreparePackageMojo.java | 17 ++++-
.../maven/slingstart/PreparePackageMojoTest.java | 87 +++++++++++++++++++++-
3 files changed, 105 insertions(+), 12 deletions(-)
diff --git a/pom.xml b/pom.xml
index 1d30ec8..acac9db 100644
--- a/pom.xml
+++ b/pom.xml
@@ -86,7 +86,7 @@
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.provisioning.model</artifactId>
- <version>1.4.0</version>
+ <version>1.4.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
@@ -169,6 +169,11 @@
</exclusions>
</dependency>
<dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.commons.osgi</artifactId>
+ <version>2.3.1-SNAPSHOT</version>
+ </dependency>
+ <dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.10.19</version>
@@ -208,12 +213,6 @@
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.commons.osgi</artifactId>
- <version>2.3.0</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.commons.threads</artifactId>
<version>3.2.0</version>
<scope>test</scope>
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 3871246..c845bab 100644
--- a/src/main/java/org/apache/sling/maven/slingstart/PreparePackageMojo.java
+++ b/src/main/java/org/apache/sling/maven/slingstart/PreparePackageMojo.java
@@ -48,6 +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.provisioning.model.ArtifactGroup;
import org.apache.sling.provisioning.model.Configuration;
import org.apache.sling.provisioning.model.Feature;
@@ -231,7 +232,18 @@ public class PreparePackageMojo extends AbstractSlingStartMojo {
for(final org.apache.sling.provisioning.model.Artifact a : group) {
final Artifact artifact = ModelUtils.getArtifact(this.project, this.mavenSession, this.artifactHandlerManager, this.resolver,
a.getGroupId(), a.getArtifactId(), a.getVersion(), a.getType(), a.getClassifier());
- final File artifactFile = artifact.getFile();
+ File artifactFile = artifact.getFile();
+
+ String newBSN = a.getMetadata().get("bundle:rename-bsn");
+ if (newBSN != null) {
+ try {
+ getTmpDir().mkdirs();
+ artifactFile = BundleUtil.renameBSN(artifactFile, newBSN, getTmpDir());
+ } catch (IOException e) {
+ throw new MojoExecutionException("Unable to rename bundle BSN to " + newBSN + " for " + artifactFile, e);
+ }
+ }
+
contentsMap.put(getPathForArtifact(group.getStartLevel(), artifactFile.getName(), runMode, isBoot), artifactFile);
}
}
@@ -264,7 +276,6 @@ public class PreparePackageMojo extends AbstractSlingStartMojo {
}
}
-
private File createSubsystemBaseFile(Feature feature, AtomicInteger startLevelHolder) throws MojoExecutionException {
File subsystemFile = new File(getTmpDir(), feature.getName() + ".subsystem-base");
if (subsystemFile.exists()) {
@@ -354,7 +365,7 @@ public class PreparePackageMojo extends AbstractSlingStartMojo {
attrs.putValue("Manifest-Version", "1.0"); // Manifest does not work without this value
attrs.putValue("About-This-Manifest", "This is not a real manifest, it is used as information when this archive is transformed into a real subsystem .esa file");
for (Map.Entry<String, StringBuilder> entry : runModes.entrySet()) {
- attrs.putValue(entry.getKey(), entry.getValue().toString());
+ attrs.putValue(entry.getKey().replace(':', '_'), entry.getValue().toString());
}
return mf;
}
diff --git a/src/test/java/org/apache/sling/maven/slingstart/PreparePackageMojoTest.java b/src/test/java/org/apache/sling/maven/slingstart/PreparePackageMojoTest.java
index 4f8a427..353f74c 100644
--- a/src/test/java/org/apache/sling/maven/slingstart/PreparePackageMojoTest.java
+++ b/src/test/java/org/apache/sling/maven/slingstart/PreparePackageMojoTest.java
@@ -17,6 +17,7 @@
package org.apache.sling.maven.slingstart;
import java.io.File;
+import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
@@ -27,7 +28,9 @@ import java.nio.file.Path;
import java.util.HashSet;
import java.util.Set;
import java.util.jar.Attributes;
+import java.util.jar.JarEntry;
import java.util.jar.JarFile;
+import java.util.jar.JarInputStream;
import java.util.jar.Manifest;
import java.util.zip.ZipEntry;
@@ -52,7 +55,87 @@ import static org.junit.Assert.assertEquals;
public class PreparePackageMojoTest {
@Test
- public void testSubsystemBaseGeneration1() throws Exception {
+ public void testBSNRenaming() throws Exception {
+ // Provide the system with some artifacts that are known to be in the local .m2 repo
+ // These are explicitly included in the test section of the pom.xml
+ PreparePackageMojo ppm = getMojoUnderTest(
+ "org.apache.sling/org.apache.sling.commons.classloader/1.3.2",
+ "org.apache.sling/org.apache.sling.commons.classloader/1.3.2/app",
+ "org.apache.sling/org.apache.sling.commons.json/2.0.12");
+ try {
+ String modelTxt = "[feature name=:launchpad]\n" +
+ "[artifacts]\n" +
+ " org.apache.sling/org.apache.sling.commons.classloader/1.3.2\n" +
+ "" +
+ "[feature name=rename_test]\n" +
+ " org.apache.sling/org.apache.sling.commons.json/2.0.12 [bundle:rename-bsn=r-foo.bar.renamed.sling.commons.json]\n";
+
+ Model model = ModelReader.read(new StringReader(modelTxt), null);
+ ppm.execute(model);
+
+ File orgJar = getMavenArtifactFile(getMavenRepoRoot(), "org.apache.sling", "org.apache.sling.commons.json", "2.0.12");
+ File generatedJar = new File(ppm.getTmpDir() + "/r-foo.bar.renamed.sling.commons.json-2.0.12.jar");
+
+ compareJarContents(orgJar, generatedJar);
+
+ try (JarFile jfOrg = new JarFile(orgJar);
+ JarFile jfNew = new JarFile(generatedJar)) {
+ Manifest mfOrg = jfOrg.getManifest();
+ Manifest mfNew = jfNew.getManifest();
+
+ Attributes orgAttrs = mfOrg.getMainAttributes();
+ Attributes newAttrs = mfNew.getMainAttributes();
+ for (Object key : orgAttrs.keySet()) {
+ String orgVal = orgAttrs.getValue(key.toString());
+ String newVal = newAttrs.getValue(key.toString());
+
+ if ("Bundle-SymbolicName".equals(key.toString())) {
+ assertEquals("Should have recorded the original Bundle-SymbolicName",
+ orgVal, newAttrs.getValue("X-Original-Bundle-SymbolicName"));
+
+ assertEquals("r-foo.bar.renamed.sling.commons.json", newVal);
+ } else {
+ assertEquals("Different keys: " + key, orgVal, newVal);
+ }
+ }
+ }
+ } finally {
+ FileUtils.deleteDirectory(new File(ppm.project.getBuild().getDirectory()));
+ }
+ }
+
+ private static void compareJarContents(File orgJar, File actualJar) throws IOException {
+ try (JarInputStream jis1 = new JarInputStream(new FileInputStream(orgJar));
+ JarInputStream jis2 = new JarInputStream(new FileInputStream(actualJar))) {
+ JarEntry je1 = null;
+ while ((je1 = jis1.getNextJarEntry()) != null) {
+ if (je1.isDirectory())
+ continue;
+
+ JarEntry je2 = null;
+ while((je2 = jis2.getNextJarEntry()) != null) {
+ if (!je2.isDirectory())
+ break;
+ }
+
+ assertEquals(je1.getName(), je2.getName());
+ assertEquals(je1.getSize(), je2.getSize());
+
+ try {
+ byte[] buf1 = IOUtils.toByteArray(jis1);
+ byte[] buf2 = IOUtils.toByteArray(jis2);
+
+ assertArrayEquals("Contents not equal: " + je1.getName(), buf1, buf2);
+ } finally {
+ jis1.closeEntry();
+ jis2.closeEntry();
+ }
+ }
+ }
+ }
+
+ @Test
+ public void testSubsystemBaseGeneration() throws Exception {
// Provide the system with some artifacts that are known to be in the local .m2 repo
// These are explicitly included in the test section of the pom.xml
PreparePackageMojo ppm = getMojoUnderTest(
@@ -84,7 +167,7 @@ public class PreparePackageMojoTest {
" org.apache.sling/org.apache.sling.commons.json/2.0.12\n" +
" org.apache.sling/org.apache.sling.commons.mime/2.1.8\n" +
"" +
- "[artifacts startLevel=20 runModes=foo,bar]\n" +
+ "[artifacts startLevel=20 runModes=foo,bar,:blah]\n" +
" org.apache.sling/org.apache.sling.commons.threads/3.2.0\n" +
"" +
"[artifacts startLevel=100 runModes=bar]\n" +
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-slingstart-maven-plugin] 02/13: Update the main reactor to
parent 25
Posted by ro...@apache.org.
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 49d48b56c60b9b8787f0400103e62a19ea34f1cc
Author: Robert Munteanu <ro...@apache.org>
AuthorDate: Mon Oct 5 10:03:45 2015 +0000
Update the main reactor to parent 25
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/tooling/maven/slingstart-maven-plugin@1706780 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 2afd4da..554292c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -17,7 +17,7 @@
<parent>
<groupId>org.apache.sling</groupId>
<artifactId>sling</artifactId>
- <version>24</version>
+ <version>25</version>
<relativePath />
</parent>
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-slingstart-maven-plugin] 13/13: [maven-release-plugin] copy
for tag slingstart-maven-plugin-1.4.0
Posted by ro...@apache.org.
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 ec8ff1a920166835827c48d8c486d14869653dcb
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon Jan 4 15:28:44 2016 +0000
[maven-release-plugin] copy for tag slingstart-maven-plugin-1.4.0
git-svn-id: https://svn.apache.org/repos/asf/sling/tags/slingstart-maven-plugin-1.4.0@1722897 13f79535-47bb-0310-9956-ffa450edef68
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-slingstart-maven-plugin] 12/13: [maven-release-plugin]
prepare release slingstart-maven-plugin-1.4.0
Posted by ro...@apache.org.
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 f679285db1452dbf30376ea7cc382d75c3324e3b
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon Jan 4 15:28:30 2016 +0000
[maven-release-plugin] prepare release slingstart-maven-plugin-1.4.0
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/tooling/maven/slingstart-maven-plugin@1722896 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/pom.xml b/pom.xml
index 1f208e1..0abf975 100644
--- a/pom.xml
+++ b/pom.xml
@@ -22,7 +22,7 @@
</parent>
<artifactId>slingstart-maven-plugin</artifactId>
- <version>1.3.7-SNAPSHOT</version>
+ <version>1.4.0</version>
<packaging>maven-plugin</packaging>
<name>Apache Sling SlingStart Maven Plugin</name>
@@ -36,9 +36,9 @@
</properties>
<scm>
- <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/tooling/maven/slingstart-maven-plugin</connection>
- <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/tooling/maven/slingstart-maven-plugin</developerConnection>
- <url>http://svn.apache.org/viewvc/sling/trunk/tooling/maven/slingstart-maven-plugin</url>
+ <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/slingstart-maven-plugin-1.4.0</connection>
+ <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/slingstart-maven-plugin-1.4.0</developerConnection>
+ <url>http://svn.apache.org/viewvc/sling/tags/slingstart-maven-plugin-1.4.0</url>
</scm>
<build>
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.