This is an automated email from the ASF dual-hosted git repository. rombert pushed a commit to annotated tag slingstart-maven-plugin-1.0.0 in repository https://gitbox.apache.org/repos/asf/sling-slingstart-maven-plugin.git
commit 08649e0f70808dc0de6f672a90eaf2ac6ab593fb Author: Carsten Ziegeler <[email protected]> AuthorDate: Tue Sep 30 14:28:35 2014 +0000 Adjust to new model git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/tooling/maven/slingstart-maven-plugin@1628456 13f79535-47bb-0310-9956-ffa450edef68 --- .../maven/slingstart/AbstractSlingStartMojo.java | 14 +- .../maven/slingstart/AttachSlingStartModel.java | 8 +- .../sling/maven/slingstart/BuildConstants.java | 6 +- .../slingstart/DependencyLifecycleParticipant.java | 50 +++--- .../apache/sling/maven/slingstart/ModelUtils.java | 92 +++++------ .../sling/maven/slingstart/PreparePackageMojo.java | 175 +++++++++++---------- 6 files changed, 180 insertions(+), 165 deletions(-) diff --git a/src/main/java/org/apache/sling/maven/slingstart/AbstractSlingStartMojo.java b/src/main/java/org/apache/sling/maven/slingstart/AbstractSlingStartMojo.java index 0a48c1c..0e8057c 100644 --- a/src/main/java/org/apache/sling/maven/slingstart/AbstractSlingStartMojo.java +++ b/src/main/java/org/apache/sling/maven/slingstart/AbstractSlingStartMojo.java @@ -26,7 +26,7 @@ import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; import org.apache.maven.project.MavenProjectHelper; -import org.apache.sling.slingstart.model.SSMDeliverable; +import org.apache.sling.provisioning.model.Model; public abstract class AbstractSlingStartMojo extends AbstractMojo { @@ -45,15 +45,15 @@ public abstract class AbstractSlingStartMojo extends AbstractMojo { @Parameter(defaultValue="false") protected boolean createWebapp; - private static final String CTX_RAW = SSMDeliverable.class.getName() + "/r"; - private static final String CTX_EFFECTIVE = SSMDeliverable.class.getName() + "/e"; + private static final String CTX_RAW = Model.class.getName() + "/r"; + private static final String CTX_EFFECTIVE = Model.class.getName() + "/e"; /** * Read the model prepared by the lifecycle plugin */ - protected SSMDeliverable readRawModel() + protected Model readRawModel() throws MojoExecutionException { - SSMDeliverable result = (SSMDeliverable)this.project.getContextValue(CTX_RAW); + Model result = (Model)this.project.getContextValue(CTX_RAW); if ( result == null ) { try { result = ModelUtils.getRawModel(this.project); @@ -69,9 +69,9 @@ public abstract class AbstractSlingStartMojo extends AbstractMojo { /** * Read the model prepared by the lifecycle plugin */ - protected SSMDeliverable readEffectiveModel() + protected Model readEffectiveModel() throws MojoExecutionException { - SSMDeliverable result = (SSMDeliverable)this.project.getContextValue(CTX_EFFECTIVE); + Model result = (Model)this.project.getContextValue(CTX_EFFECTIVE); if ( result == null ) { try { result = ModelUtils.getEffectiveModel(this.project); diff --git a/src/main/java/org/apache/sling/maven/slingstart/AttachSlingStartModel.java b/src/main/java/org/apache/sling/maven/slingstart/AttachSlingStartModel.java index be35ad5..2bdefbe 100644 --- a/src/main/java/org/apache/sling/maven/slingstart/AttachSlingStartModel.java +++ b/src/main/java/org/apache/sling/maven/slingstart/AttachSlingStartModel.java @@ -27,8 +27,8 @@ import org.apache.maven.plugin.MojoFailureException; 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.slingstart.model.SSMDeliverable; -import org.apache.sling.slingstart.model.txt.TXTSSMModelWriter; +import org.apache.sling.provisioning.model.Model; +import org.apache.sling.provisioning.model.io.ModelWriter; /** * Attaches the subsystem as a project artifact. @@ -44,14 +44,14 @@ public class AttachSlingStartModel extends AbstractSlingStartMojo { @Override public void execute() throws MojoExecutionException, MojoFailureException { - final SSMDeliverable model = this.readRawModel(); + final Model model = this.readRawModel(); final File outputFile = new File(this.project.getBuild().getDirectory() + File.separatorChar + "slingstart.txt"); outputFile.getParentFile().mkdirs(); Writer writer = null; try { writer = new FileWriter(outputFile); - TXTSSMModelWriter.write(writer, model); + ModelWriter.write(writer, model); } catch (IOException e) { throw new MojoExecutionException("Unable to write model to " + outputFile, e); } finally { diff --git a/src/main/java/org/apache/sling/maven/slingstart/BuildConstants.java b/src/main/java/org/apache/sling/maven/slingstart/BuildConstants.java index 265aea5..49699d6 100644 --- a/src/main/java/org/apache/sling/maven/slingstart/BuildConstants.java +++ b/src/main/java/org/apache/sling/maven/slingstart/BuildConstants.java @@ -19,14 +19,14 @@ package org.apache.sling.maven.slingstart; import java.util.ArrayList; import java.util.List; -import org.apache.sling.slingstart.model.SSMConstants; +import org.apache.sling.provisioning.model.ModelConstants; public abstract class BuildConstants { // CONTEXTS public static final String CONTEXT_GLOBAL = "slingstart:global"; - public static final String CONTEXT_STANDALONE = "slingstart" + SSMConstants.RUN_MODE_STANDALONE; - public static final String CONTEXT_WEBAPP = "slingstart" + SSMConstants.RUN_MODE_WEBAPP; + public static final String CONTEXT_STANDALONE = "slingstart" + ModelConstants.RUN_MODE_STANDALONE; + public static final String CONTEXT_WEBAPP = "slingstart" + ModelConstants.RUN_MODE_WEBAPP; // Types 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 09140c6..a2ee354 100644 --- a/src/main/java/org/apache/sling/maven/slingstart/DependencyLifecycleParticipant.java +++ b/src/main/java/org/apache/sling/maven/slingstart/DependencyLifecycleParticipant.java @@ -35,12 +35,12 @@ 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.slingstart.model.SSMArtifact; -import org.apache.sling.slingstart.model.SSMConstants; -import org.apache.sling.slingstart.model.SSMDeliverable; -import org.apache.sling.slingstart.model.SSMFeature; -import org.apache.sling.slingstart.model.SSMStartLevel; -import org.apache.sling.slingstart.model.SSMUtil; +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.RunMode; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.logging.Logger; @@ -109,16 +109,16 @@ public class DependencyLifecycleParticipant extends AbstractMavenLifecyclePartic final String directory = nodeValue((Xpp3Dom) plugin.getConfiguration(), "systemsDirectory", new File(project.getBasedir(), "src/main/systems").getAbsolutePath()); - final SSMDeliverable model = ModelUtils.readFullModel(new File(directory), dependencies, project, session, log); + final Model model = ModelUtils.readFullModel(new File(directory), dependencies, project, session, log); ModelUtils.storeRawModel(project, model); - final SSMDeliverable effectiveModel = SSMUtil.getEffectiveModel(model, null); + final Model effectiveModel = ModelUtility.getEffectiveModel(model, null); ModelUtils.storeEffectiveModel(project, effectiveModel); // start with base artifact - final SSMArtifact base = ModelUtils.getBaseArtifact(effectiveModel); + final org.apache.sling.provisioning.model.Artifact base = ModelUtils.getBaseArtifact(effectiveModel); final String[] classifiers = new String[] {null, BuildConstants.CLASSIFIER_APP, BuildConstants.CLASSIFIER_WEBAPP}; for(final String c : classifiers) { final Dependency dep = new Dependency(); @@ -139,24 +139,26 @@ public class DependencyLifecycleParticipant extends AbstractMavenLifecyclePartic addDependencies(effectiveModel, log, project); } - private static void addDependencies(final SSMDeliverable model, final Logger log, final MavenProject project) { - for(final SSMFeature feature : model.getFeatures()) { + private static void addDependencies(final Model model, final Logger log, final MavenProject project) { + for(final Feature feature : model.getFeatures()) { // skip base - if ( feature.isRunMode(SSMConstants.RUN_MODE_BASE) ) { + if ( feature.getName().equals(ModelConstants.FEATURE_LAUNCHPAD) ) { continue; } - for(final SSMStartLevel sl : feature.getStartLevels()) { - for(final SSMArtifact a : sl.getArtifacts()) { - 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(PROVIDED); - - log.debug("- adding dependency " + dep); - project.getDependencies().add(dep); + for(final RunMode runMode : feature.getRunModes()) { + for(final ArtifactGroup sl : runMode.getArtifactGroups()) { + for(final org.apache.sling.provisioning.model.Artifact a : sl.getArtifacts()) { + 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(PROVIDED); + + log.debug("- adding dependency " + dep); + project.getDependencies().add(dep); + } } } } diff --git a/src/main/java/org/apache/sling/maven/slingstart/ModelUtils.java b/src/main/java/org/apache/sling/maven/slingstart/ModelUtils.java index 7fa192c..f1a4a15 100644 --- a/src/main/java/org/apache/sling/maven/slingstart/ModelUtils.java +++ b/src/main/java/org/apache/sling/maven/slingstart/ModelUtils.java @@ -32,15 +32,14 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.project.MavenProject; -import org.apache.sling.slingstart.model.SSMArtifact; -import org.apache.sling.slingstart.model.SSMConstants; -import org.apache.sling.slingstart.model.SSMDeliverable; -import org.apache.sling.slingstart.model.SSMFeature; -import org.apache.sling.slingstart.model.SSMMerger; -import org.apache.sling.slingstart.model.SSMTraceable; -import org.apache.sling.slingstart.model.SSMValidator; -import org.apache.sling.slingstart.model.txt.TXTSSMModelReader; -import org.apache.sling.slingstart.model.txt.TXTSSMModelWriter; +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.RunMode; +import org.apache.sling.provisioning.model.Traceable; +import org.apache.sling.provisioning.model.io.ModelReader; +import org.apache.sling.provisioning.model.io.ModelWriter; import org.codehaus.plexus.logging.Logger; public abstract class ModelUtils { @@ -49,9 +48,9 @@ public abstract class ModelUtils { * Read all model files from the directory in alphabetical order * @param logger */ - private static SSMDeliverable readLocalModel(final File systemsDirectory, final MavenProject project, final MavenSession session, final Logger logger) + private static Model readLocalModel(final File systemsDirectory, final MavenProject project, final MavenSession session, final Logger logger) throws MojoExecutionException { - final SSMDeliverable result = new SSMDeliverable(); + final Model result = new Model(); final List<String> candidates = new ArrayList<String>(); if ( systemsDirectory != null && systemsDirectory.exists() ) { for(final File f : systemsDirectory.listFiles() ) { @@ -70,12 +69,12 @@ public abstract class ModelUtils { final File f = new File(systemsDirectory, name); final FileReader reader = new FileReader(f); try { - final SSMDeliverable current = TXTSSMModelReader.read(reader, f.getAbsolutePath()); - final Map<SSMTraceable, String> errors = SSMValidator.validate(current); + final Model current = ModelReader.read(reader, f.getAbsolutePath()); + final Map<Traceable, String> errors = ModelUtility.validate(current); if (errors != null ) { throw new MojoExecutionException("Invalid model at " + name + " : " + errors); } - SSMMerger.merge(result, current); + ModelUtility.merge(result, current); } finally { IOUtils.closeQuietly(reader); } @@ -84,7 +83,7 @@ public abstract class ModelUtils { } } - final Map<SSMTraceable, String> errors = SSMValidator.validate(result); + final Map<Traceable, String> errors = ModelUtility.validate(result); if (errors != null ) { throw new MojoExecutionException("Invalid assembled model : " + errors); } @@ -95,42 +94,42 @@ public abstract class ModelUtils { /** * Read the full model */ - public static SSMDeliverable readFullModel(final File systemsDirectory, + public static Model readFullModel(final File systemsDirectory, final List<File> dependentModels, final MavenProject project, final MavenSession session, final Logger logger) throws MojoExecutionException { try { - final SSMDeliverable localModel = readLocalModel(systemsDirectory, project, session, logger); + final Model localModel = readLocalModel(systemsDirectory, project, session, logger); // check dependent models - SSMDeliverable depModel = null; + Model depModel = null; for(final File file : dependentModels) { FileReader r = null; try { r = new FileReader(file); if ( depModel == null ) { - depModel = new SSMDeliverable(); + depModel = new Model(); } - final SSMDeliverable readModel = TXTSSMModelReader.read(r, file.getAbsolutePath()); - final Map<SSMTraceable, String> errors = SSMValidator.validate(readModel); + final Model readModel = ModelReader.read(r, file.getAbsolutePath()); + final Map<Traceable, String> errors = ModelUtility.validate(readModel); if (errors != null ) { throw new MojoExecutionException("Invalid model at " + file + " : " + errors); } - SSMMerger.merge(depModel, readModel); + ModelUtility.merge(depModel, readModel); } finally { IOUtils.closeQuietly(r); } } - final SSMDeliverable result; + final Model result; if ( depModel != null ) { - Map<SSMTraceable, String> errors = SSMValidator.validate(depModel); + Map<Traceable, String> errors = ModelUtility.validate(depModel); if (errors != null ) { throw new MojoExecutionException("Invalid model : " + errors); } - SSMMerger.merge(depModel, localModel); - errors = SSMValidator.validate(depModel); + ModelUtility.merge(depModel, localModel); + errors = ModelUtility.validate(depModel); if (errors != null ) { throw new MojoExecutionException("Invalid model : " + errors); } @@ -145,23 +144,26 @@ public abstract class ModelUtils { } } - public static SSMArtifact getBaseArtifact(final SSMDeliverable model) throws MojoExecutionException { - // get base run mode - final SSMFeature base = model.getRunMode(SSMConstants.RUN_MODE_BASE); + public static org.apache.sling.provisioning.model.Artifact getBaseArtifact(final Model model) throws MojoExecutionException { + final Feature base = model.findFeature(ModelConstants.FEATURE_LAUNCHPAD); if ( base == null ) { - throw new MojoExecutionException("No base run mode found."); + throw new MojoExecutionException("No launchpad feature found."); } - if ( base.getStartLevels().size() == 0 ) { + // get global run mode + final RunMode runMode = base.getRunMode(null); + if ( runMode == null ) { + throw new MojoExecutionException("No global run mode found in launchpad feature."); + } + if ( runMode.getArtifactGroups().isEmpty() ) { throw new MojoExecutionException("No base artifacts defined."); } - if ( base.getStartLevels().size() > 1 ) { + if ( runMode.getArtifactGroups().size() > 1 ) { throw new MojoExecutionException("Base run mode should only have a single start level."); } - if ( base.getStartLevels().get(0).getArtifacts().size() != 1 ) { + if ( runMode.getArtifactGroups().get(0).getArtifacts().size() != 1 ) { throw new MojoExecutionException("Base run mode should contain exactly one artifact."); } - - return base.getStartLevels().get(0).getArtifacts().get(0); + return runMode.getArtifactGroups().get(0).getArtifacts().get(0); } /** @@ -186,8 +188,8 @@ public abstract class ModelUtils { return null; } - private static final String RAW_MODEL = SSMDeliverable.class.getName() + "/raw"; - private static final String EFFECTIVE_MODEL = SSMDeliverable.class.getName() + "/effective"; + private static final String RAW_MODEL = Model.class.getName() + "/raw"; + private static final String EFFECTIVE_MODEL = Model.class.getName() + "/effective"; /** * Store the raw model in the project. @@ -195,10 +197,10 @@ public abstract class ModelUtils { * @param model The model * @throws IOException If writing fails */ - public static void storeRawModel(final MavenProject project, final SSMDeliverable model) + public static void storeRawModel(final MavenProject project, final Model model) throws IOException { final StringWriter w = new StringWriter(); - TXTSSMModelWriter.write(w, model); + ModelWriter.write(w, model); project.setContextValue(RAW_MODEL, w.toString()); } @@ -208,9 +210,9 @@ public abstract class ModelUtils { * @return The raw model * @throws IOException If reading fails */ - public static SSMDeliverable getRawModel(final MavenProject project) throws IOException { + public static Model getRawModel(final MavenProject project) throws IOException { final String contents = (String)project.getContextValue(RAW_MODEL); - return TXTSSMModelReader.read(new StringReader(contents), null); + return ModelReader.read(new StringReader(contents), null); } /** @@ -219,10 +221,10 @@ public abstract class ModelUtils { * @param model The model * @throws IOException If writing fails */ - public static void storeEffectiveModel(final MavenProject project, final SSMDeliverable model) + public static void storeEffectiveModel(final MavenProject project, final Model model) throws IOException { final StringWriter w = new StringWriter(); - TXTSSMModelWriter.write(w, model); + ModelWriter.write(w, model); project.setContextValue(EFFECTIVE_MODEL, w.toString()); } @@ -232,8 +234,8 @@ public abstract class ModelUtils { * @return The raw model * @throws IOException If reading fails */ - public static SSMDeliverable getEffectiveModel(final MavenProject project) throws IOException { + public static Model getEffectiveModel(final MavenProject project) throws IOException { final String contents = (String)project.getContextValue(EFFECTIVE_MODEL); - return TXTSSMModelReader.read(new StringReader(contents), null); + return ModelReader.read(new StringReader(contents), null); } } 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 e9b5277..e05a27f 100644 --- a/src/main/java/org/apache/sling/maven/slingstart/PreparePackageMojo.java +++ b/src/main/java/org/apache/sling/maven/slingstart/PreparePackageMojo.java @@ -35,12 +35,12 @@ 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.slingstart.model.SSMArtifact; -import org.apache.sling.slingstart.model.SSMConfiguration; -import org.apache.sling.slingstart.model.SSMConstants; -import org.apache.sling.slingstart.model.SSMDeliverable; -import org.apache.sling.slingstart.model.SSMFeature; -import org.apache.sling.slingstart.model.SSMStartLevel; +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.Model; +import org.apache.sling.provisioning.model.ModelConstants; +import org.apache.sling.provisioning.model.RunMode; import org.codehaus.plexus.archiver.ArchiverException; import org.codehaus.plexus.archiver.UnArchiver; import org.codehaus.plexus.archiver.manager.ArchiverManager; @@ -78,7 +78,7 @@ public class PreparePackageMojo extends AbstractSlingStartMojo { @Override public void execute() throws MojoExecutionException, MojoFailureException { - final SSMDeliverable model = this.readEffectiveModel(); + final Model model = this.readEffectiveModel(); this.prepareGlobal(model); this.prepareStandaloneApp(model); @@ -88,7 +88,7 @@ public class PreparePackageMojo extends AbstractSlingStartMojo { /** * Prepare the global map for the artifacts. */ - private void prepareGlobal(final SSMDeliverable model) throws MojoExecutionException { + private void prepareGlobal(final Model model) throws MojoExecutionException { final Map<String, File> globalContentsMap = new HashMap<String, File>(); this.buildContentsMap(model, (String)null, globalContentsMap); @@ -98,23 +98,23 @@ public class PreparePackageMojo extends AbstractSlingStartMojo { /** * Prepare the standalone application. */ - private void prepareStandaloneApp(final SSMDeliverable model) throws MojoExecutionException { + private void prepareStandaloneApp(final Model model) throws MojoExecutionException { final Map<String, File> contentsMap = new HashMap<String, File>(); this.project.setContextValue(BuildConstants.CONTEXT_STANDALONE, contentsMap); // unpack base artifact and create settings final File outputDir = new File(this.project.getBuild().getOutputDirectory()); - unpackBaseArtifact(model, outputDir, SSMConstants.RUN_MODE_STANDALONE); - this.buildSettings(model, SSMConstants.RUN_MODE_STANDALONE, outputDir); - this.buildBootstrapFile(model, SSMConstants.RUN_MODE_STANDALONE, outputDir); + unpackBaseArtifact(model, outputDir, ModelConstants.RUN_MODE_STANDALONE); + this.buildSettings(model, ModelConstants.RUN_MODE_STANDALONE, outputDir); + this.buildBootstrapFile(model, ModelConstants.RUN_MODE_STANDALONE, outputDir); - this.buildContentsMap(model, SSMConstants.RUN_MODE_STANDALONE, contentsMap); + this.buildContentsMap(model, ModelConstants.RUN_MODE_STANDALONE, contentsMap); } /** * Prepare the web application. */ - private void prepareWebapp(final SSMDeliverable model) throws MojoExecutionException { + private void prepareWebapp(final Model model) throws MojoExecutionException { if ( this.createWebapp ) { final Map<String, File> contentsMap = new HashMap<String, File>(); this.project.setContextValue(BuildConstants.CONTEXT_WEBAPP, contentsMap); @@ -122,48 +122,55 @@ public class PreparePackageMojo extends AbstractSlingStartMojo { // unpack base artifact and create settings final File outputDir = new File(this.project.getBuild().getDirectory(), BuildConstants.WEBAPP_OUTDIR); final File webappDir = new File(outputDir, "WEB-INF"); - unpackBaseArtifact(model, outputDir, SSMConstants.RUN_MODE_WEBAPP); + unpackBaseArtifact(model, outputDir, ModelConstants.RUN_MODE_WEBAPP); // check for web.xml - final SSMFeature webappRM = model.getRunMode(SSMConstants.RUN_MODE_WEBAPP); - if ( webappRM != null ) { - final SSMConfiguration webConfig = webappRM.getConfiguration(SSMConstants.CFG_WEB_XML); - if ( webConfig != null ) { - final File webXML = new File(webappDir, "web.xml"); - try { - FileUtils.fileWrite(webXML, webConfig.getProperties().get(SSMConstants.CFG_WEB_XML).toString()); - } catch (final IOException e) { - throw new MojoExecutionException("Unable to write configuration to " + webXML, e); + final Feature webappF = model.findFeature(ModelConstants.FEATURE_LAUNCHPAD); + if ( webappF != null ) { + final RunMode webappRM = webappF.getRunMode(null); + if ( webappRM != null ) { + final Configuration webConfig = webappRM.getConfiguration(ModelConstants.CFG_LAUNCHPAD_WEB_XML); + if ( webConfig != null ) { + final File webXML = new File(webappDir, "web.xml"); + try { + FileUtils.fileWrite(webXML, webConfig.getProperties().get(ModelConstants.CFG_LAUNCHPAD_WEB_XML).toString()); + } catch (final IOException e) { + throw new MojoExecutionException("Unable to write configuration to " + webXML, e); + } } } } - this.buildSettings(model, SSMConstants.RUN_MODE_WEBAPP, webappDir); - this.buildBootstrapFile(model, SSMConstants.RUN_MODE_WEBAPP, outputDir); + this.buildSettings(model, ModelConstants.RUN_MODE_WEBAPP, webappDir); + this.buildBootstrapFile(model, ModelConstants.RUN_MODE_WEBAPP, outputDir); - this.buildContentsMap(model, SSMConstants.RUN_MODE_WEBAPP, contentsMap); + this.buildContentsMap(model, ModelConstants.RUN_MODE_WEBAPP, contentsMap); } } /** * Build a list of all artifacts. */ - private void buildContentsMap(final SSMDeliverable model, final String packageRunMode, final Map<String, File> contentsMap) + private void buildContentsMap(final Model model, final String packageRunMode, final Map<String, File> contentsMap) throws MojoExecutionException { if ( packageRunMode == null ) { // add base jar final Artifact artifact = getBaseArtifact(model, null, BuildConstants.TYPE_JAR); contentsMap.put(BASE_DESTINATION + "/"+ artifact.getArtifactId() + "." + artifact.getArtifactHandler().getExtension(), artifact.getFile()); } - for(final SSMFeature feature : model.getFeatures()) { - if ( packageRunMode == null ) { - if ( feature.isSpecial() - && !feature.isRunMode(SSMConstants.RUN_MODE_BOOT)) { - continue; - } - this.buildContentsMap(model, feature, contentsMap); - } else { - if ( feature.isRunMode(packageRunMode) ) { - this.buildContentsMap(model, feature, contentsMap); + 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) ) { + this.buildContentsMap(model, runMode, contentsMap, feature.getName().equals(ModelConstants.FEATURE_BOOT)); + } } } } @@ -172,19 +179,19 @@ public class PreparePackageMojo extends AbstractSlingStartMojo { /** * Build a list of all artifacts from this run mode */ - private void buildContentsMap(final SSMDeliverable model, final SSMFeature runMode, final Map<String, File> contentsMap) + private void buildContentsMap(final Model model, final RunMode runMode, final Map<String, File> contentsMap, final boolean isBoot) throws MojoExecutionException{ - for(final SSMStartLevel sl : runMode.getStartLevels()) { - for(final SSMArtifact a : sl.getArtifacts()) { + for(final ArtifactGroup sl : runMode.getArtifactGroups()) { + for(final org.apache.sling.provisioning.model.Artifact a : sl.getArtifacts()) { final Artifact artifact = ModelUtils.getArtifact(this.project, a.getGroupId(), a.getArtifactId(), a.getVersion(), a.getType(), a.getClassifier()); final File artifactFile = artifact.getFile(); - contentsMap.put(getPathForArtifact(sl.getLevel(), artifactFile.getName(), runMode), artifactFile); + contentsMap.put(getPathForArtifact(sl.getLevel(), artifactFile.getName(), runMode, isBoot), artifactFile); } } final File rootConfDir = new File(this.getTmpDir(), "global-config"); boolean hasConfig = false; - for(final SSMConfiguration config : runMode.getConfigurations()) { + for(final Configuration config : runMode.getConfigurations()) { // skip special configurations if ( config.isSpecial() ) { continue; @@ -213,20 +220,28 @@ public class PreparePackageMojo extends AbstractSlingStartMojo { /** * Build the settings for the given packaging run mode */ - private void buildSettings(final SSMDeliverable model, final String packageRunMode, final File outputDir) + private void buildSettings(final Model model, final String packageRunMode, final File outputDir) throws MojoExecutionException { final Properties settings = new Properties(); - final SSMFeature baseRM = model.getRunMode(SSMConstants.RUN_MODE_BASE); - if ( baseRM != null ) { - settings.putAll(baseRM.getSettings()); + final Feature launchpadFeature = model.findFeature(ModelConstants.FEATURE_LAUNCHPAD); + if ( launchpadFeature != null ) { + final RunMode launchpadRunMode = launchpadFeature.getRunMode(null); + if ( launchpadRunMode != null ) { + settings.putAll(launchpadRunMode.getSettings()); + } } - final SSMFeature bootRM = model.getRunMode(SSMConstants.RUN_MODE_BOOT); - if ( bootRM != null ) { - settings.putAll(bootRM.getSettings()); + final Feature bootFeature = model.findFeature(ModelConstants.FEATURE_BOOT); + if ( bootFeature != null ) { + final RunMode bootRunMode = bootFeature.getRunMode(null); + if ( bootRunMode != null ) { + settings.putAll(bootRunMode.getSettings()); + } } - final SSMFeature packageRM = model.getRunMode(packageRunMode); - if ( packageRM != null ) { - settings.putAll(packageRM.getSettings()); + for(final Feature f : model.getFeatures()) { + final RunMode packageRM = f.getRunMode(new String[] {packageRunMode}); + if ( packageRM != null ) { + settings.putAll(packageRM.getSettings()); + } } if ( settings.size() > 0 ) { @@ -247,31 +262,27 @@ public class PreparePackageMojo extends AbstractSlingStartMojo { /** * Build the bootstrap file for the given packaging run mode */ - private void buildBootstrapFile(final SSMDeliverable model, final String packageRunMode, final File outputDir) + private void buildBootstrapFile(final Model model, final String packageRunMode, final File outputDir) throws MojoExecutionException { final StringBuilder sb = new StringBuilder(); - final SSMFeature baseRM = model.getRunMode(SSMConstants.RUN_MODE_BASE); - if ( baseRM != null ) { - final SSMConfiguration c = baseRM.getConfiguration(SSMConstants.CFG_BOOTSTRAP); - if ( c != null ) { - sb.append(c.getProperties().get(c.getPid())); - sb.append('\n'); - } - } - final SSMFeature bootRM = model.getRunMode(SSMConstants.RUN_MODE_BOOT); - if ( bootRM != null ) { - final SSMConfiguration c = bootRM.getConfiguration(SSMConstants.CFG_BOOTSTRAP); - if ( c != null ) { - sb.append(c.getProperties().get(c.getPid())); - sb.append('\n'); + + final Feature launchpadFeature = model.findFeature(ModelConstants.FEATURE_LAUNCHPAD); + if ( launchpadFeature != null ) { + final RunMode launchpadRunMode = launchpadFeature.getRunMode(null); + if ( launchpadRunMode != null ) { + final Configuration c = launchpadRunMode.getConfiguration(ModelConstants.CFG_LAUNCHPAD_BOOTSTRAP); + if ( c != null ) { + sb.append(c.getProperties().get(c.getPid())); + sb.append('\n'); + } } - } - final SSMFeature packageRM = model.getRunMode(packageRunMode); - if ( packageRM != null ) { - final SSMConfiguration c = packageRM.getConfiguration(SSMConstants.CFG_BOOTSTRAP); - if ( c != null ) { - sb.append(c.getProperties().get(c.getPid())); - sb.append('\n'); + final RunMode packageRM = launchpadFeature.getRunMode(new String[] {packageRunMode}); + if ( packageRM != null ) { + final Configuration c = packageRM.getConfiguration(ModelConstants.CFG_LAUNCHPAD_BOOTSTRAP); + if ( c != null ) { + sb.append(c.getProperties().get(c.getPid())); + sb.append('\n'); + } } } @@ -289,8 +300,8 @@ public class PreparePackageMojo extends AbstractSlingStartMojo { /** * Return the base artifact */ - private Artifact getBaseArtifact(final SSMDeliverable model, final String classifier, final String type) throws MojoExecutionException { - final SSMArtifact baseArtifact = ModelUtils.getBaseArtifact(model); + private Artifact getBaseArtifact(final Model model, final String classifier, final String type) throws MojoExecutionException { + final org.apache.sling.provisioning.model.Artifact baseArtifact = ModelUtils.getBaseArtifact(model); final Artifact a = ModelUtils.getArtifact(this.project, baseArtifact.getGroupId(), baseArtifact.getArtifactId(), @@ -308,11 +319,11 @@ public class PreparePackageMojo extends AbstractSlingStartMojo { /** * Unpack the base artifact */ - private void unpackBaseArtifact(final SSMDeliverable model, final File outputDirectory, final String packageRunMode) + private void unpackBaseArtifact(final Model model, final File outputDirectory, final String packageRunMode) throws MojoExecutionException { final String classifier; final String type; - if ( SSMConstants.RUN_MODE_STANDALONE.equals(packageRunMode) ) { + if ( ModelConstants.RUN_MODE_STANDALONE.equals(packageRunMode) ) { classifier = BuildConstants.CLASSIFIER_APP; type = BuildConstants.TYPE_JAR; } else { @@ -348,7 +359,7 @@ public class PreparePackageMojo extends AbstractSlingStartMojo { /** * Get the relative path for an artifact. */ - private String getPathForArtifact(final int startLevel, final String artifactName, final SSMFeature rm) { + private String getPathForArtifact(final int startLevel, final String artifactName, final RunMode rm, final boolean isBoot) { final Set<String> runModesList = new TreeSet<String>(); if (rm.getRunModes() != null ) { for(final String mode : rm.getRunModes()) { @@ -367,7 +378,7 @@ public class PreparePackageMojo extends AbstractSlingStartMojo { runModeExt = sb.toString(); } - if ( rm.isRunMode(SSMConstants.RUN_MODE_BOOT) ) { + if ( isBoot ) { return String.format("%s/%s/1/%s", BASE_DESTINATION, BOOT_DIRECTORY, artifactName); } @@ -380,7 +391,7 @@ public class PreparePackageMojo extends AbstractSlingStartMojo { /** * Get the relative path for a configuration */ - private String getPathForConfiguration(final SSMConfiguration config, final SSMFeature rm) { + private String getPathForConfiguration(final Configuration config, final RunMode rm) { final Set<String> runModesList = new TreeSet<String>(); if (rm.getRunModes() != null ) { for(final String mode : rm.getRunModes()) { -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
