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:34 UTC
[sling-slingstart-maven-plugin] 03/08: SLING-5414 - embed the full
text of the provisioning model in the Sling jar,
under /resources/provisioning/model.txt
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag slingstart-maven-plugin-1.4.2
in repository https://gitbox.apache.org/repos/asf/sling-slingstart-maven-plugin.git
commit 590bd42c0c493f0651f0970eb7051a8c6f57d27f
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Fri Jan 8 15:31:20 2016 +0000
SLING-5414 - embed the full text of the provisioning model in the Sling jar, under /resources/provisioning/model.txt
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/tooling/maven/slingstart-maven-plugin@1723740 13f79535-47bb-0310-9956-ffa450edef68
---
.../sling/maven/slingstart/PreparePackageMojo.java | 28 +++++++++++++++++++++-
1 file changed, 27 insertions(+), 1 deletion(-)
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 cef9ea1..fb4ad2f 100644
--- a/src/main/java/org/apache/sling/maven/slingstart/PreparePackageMojo.java
+++ b/src/main/java/org/apache/sling/maven/slingstart/PreparePackageMojo.java
@@ -57,6 +57,7 @@ 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.apache.sling.provisioning.model.io.ModelWriter;
import org.codehaus.plexus.archiver.ArchiverException;
import org.codehaus.plexus.archiver.UnArchiver;
import org.codehaus.plexus.archiver.manager.ArchiverManager;
@@ -83,6 +84,10 @@ public class PreparePackageMojo extends AbstractSlingStartMojo {
private static final String CONFIG_DIRECTORY = "config";
+ private static final String PROVISIONING_DIRECTORY = "provisioning";
+
+ private static final String EMBEDDED_MODEL_FILENAME = "model.txt";
+
private static final String BOOTSTRAP_FILE = "sling_bootstrap.txt";
private static final String PROPERTIES_FILE = "sling_install.properties";
@@ -142,9 +147,29 @@ public class PreparePackageMojo extends AbstractSlingStartMojo {
unpackBaseArtifact(model, outputDir, ModelConstants.RUN_MODE_STANDALONE);
this.buildSettings(model, ModelConstants.RUN_MODE_STANDALONE, outputDir);
this.buildBootstrapFile(model, ModelConstants.RUN_MODE_STANDALONE, outputDir);
+ this.embedModel(model, outputDir);
this.buildContentsMap(model, ModelConstants.RUN_MODE_STANDALONE, contentsMap);
}
+
+ /** Embed our model in the created jar file */
+ private void embedModel(Model model, File outputDir) throws MojoExecutionException {
+ final File modelDir = new File(new File(outputDir, BASE_DESTINATION), PROVISIONING_DIRECTORY);
+ modelDir.mkdirs();
+ final File modelFile = new File(modelDir, EMBEDDED_MODEL_FILENAME);
+ try {
+ final FileWriter w = new FileWriter(modelFile);
+ try {
+ w.write("# Aggregated provisioning model embedded by " + getClass().getName() + "\n");
+ ModelWriter.write(w, model);
+ } finally {
+ w.flush();
+ w.close();
+ }
+ } catch(IOException ioe) {
+ throw new MojoExecutionException("Failed to create model file " + modelFile.getAbsolutePath(), ioe);
+ }
+ }
/**
* Prepare the web application.
@@ -177,6 +202,7 @@ public class PreparePackageMojo extends AbstractSlingStartMojo {
}
this.buildSettings(model, ModelConstants.RUN_MODE_WEBAPP, webappDir);
this.buildBootstrapFile(model, ModelConstants.RUN_MODE_WEBAPP, webappDir);
+ this.embedModel(model, webappDir);
this.buildContentsMap(model, ModelConstants.RUN_MODE_WEBAPP, contentsMap);
}
@@ -667,4 +693,4 @@ public class PreparePackageMojo extends AbstractSlingStartMojo {
return text.replaceAll("\\\\\\$", "\\$");
}
-}
+}
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.