You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by bd...@apache.org on 2016/01/08 16:31:20 UTC
svn commit: r1723740 - in /sling/trunk: launchpad/builder/
launchpad/integration-tests/
launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/provisioning/
launchpad/testing/ tooling/maven/slingstart-maven-plugin/s...
Author: bdelacretaz
Date: Fri Jan 8 15:31:20 2016
New Revision: 1723740
URL: http://svn.apache.org/viewvc?rev=1723740&view=rev
Log:
SLING-5414 - embed the full text of the provisioning model in the Sling jar, under /resources/provisioning/model.txt
Added:
sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/provisioning/
sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/provisioning/EmbeddedModelTest.java
Modified:
sling/trunk/launchpad/builder/pom.xml
sling/trunk/launchpad/integration-tests/pom.xml
sling/trunk/launchpad/testing/pom.xml
sling/trunk/tooling/maven/slingstart-maven-plugin/src/main/java/org/apache/sling/maven/slingstart/PreparePackageMojo.java
Modified: sling/trunk/launchpad/builder/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/builder/pom.xml?rev=1723740&r1=1723739&r2=1723740&view=diff
==============================================================================
--- sling/trunk/launchpad/builder/pom.xml (original)
+++ sling/trunk/launchpad/builder/pom.xml Fri Jan 8 15:31:20 2016
@@ -79,7 +79,7 @@
<plugin>
<groupId>org.apache.sling</groupId>
<artifactId>slingstart-maven-plugin</artifactId>
- <version>1.4.0</version>
+ <version>1.4.1-SNAPSHOT</version>
<extensions>true</extensions>
<configuration>
<createWebapp>true</createWebapp>
Modified: sling/trunk/launchpad/integration-tests/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/pom.xml?rev=1723740&r1=1723739&r2=1723740&view=diff
==============================================================================
--- sling/trunk/launchpad/integration-tests/pom.xml (original)
+++ sling/trunk/launchpad/integration-tests/pom.xml Fri Jan 8 15:31:20 2016
@@ -288,6 +288,11 @@
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.launchpad.api</artifactId>
+ <version>1.2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.installer.core</artifactId>
<version>3.6.6</version>
</dependency>
Added: sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/provisioning/EmbeddedModelTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/provisioning/EmbeddedModelTest.java?rev=1723740&view=auto
==============================================================================
--- sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/provisioning/EmbeddedModelTest.java (added)
+++ sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/provisioning/EmbeddedModelTest.java Fri Jan 8 15:31:20 2016
@@ -0,0 +1,67 @@
+/*
+ * 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.launchpad.webapp.integrationtest.provisioning;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.io.output.ByteArrayOutputStream;
+import org.apache.sling.junit.rules.TeleporterRule;
+import org.apache.sling.launchpad.api.LaunchpadContentProvider;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+/** Verify that the provisioning model used to build this instance is available
+ * as a Launchpad resource.
+ */
+public class EmbeddedModelTest {
+ @Rule
+ public final TeleporterRule teleporter = TeleporterRule.forClass(getClass(), "Launchpad");
+
+ public static final String MODEL_RESOURCE_PATH = "/resources/provisioning/model.txt";
+
+ private String modelContent;
+
+ @Before
+ public void setup() throws IOException {
+ final InputStream modelStream = teleporter.getService(LaunchpadContentProvider.class).getResourceAsStream(MODEL_RESOURCE_PATH);
+ assertNotNull("Expecting embedded model resource at " + MODEL_RESOURCE_PATH, modelStream);
+ final ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ try {
+ IOUtils.copy(modelStream, bos);
+ modelContent = new String(bos.toByteArray());
+ } finally {
+ bos.close();
+ modelStream.close();
+ }
+ }
+
+ @Test
+ public void testLaunchpadFeature() {
+ assertTrue(modelContent.contains("[feature name=:launchpad]"));
+ }
+
+ @Test
+ public void testBootFeature() {
+ assertTrue(modelContent.contains("[feature name=:boot]"));
+ }
+}
Modified: sling/trunk/launchpad/testing/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/testing/pom.xml?rev=1723740&r1=1723739&r2=1723740&view=diff
==============================================================================
--- sling/trunk/launchpad/testing/pom.xml (original)
+++ sling/trunk/launchpad/testing/pom.xml Fri Jan 8 15:31:20 2016
@@ -93,7 +93,7 @@
<plugin>
<groupId>org.apache.sling</groupId>
<artifactId>slingstart-maven-plugin</artifactId>
- <version>1.2.0</version>
+ <version>1.4.1-SNAPSHOT</version>
<extensions>true</extensions>
<executions>
<execution>
Modified: sling/trunk/tooling/maven/slingstart-maven-plugin/src/main/java/org/apache/sling/maven/slingstart/PreparePackageMojo.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/maven/slingstart-maven-plugin/src/main/java/org/apache/sling/maven/slingstart/PreparePackageMojo.java?rev=1723740&r1=1723739&r2=1723740&view=diff
==============================================================================
--- sling/trunk/tooling/maven/slingstart-maven-plugin/src/main/java/org/apache/sling/maven/slingstart/PreparePackageMojo.java (original)
+++ sling/trunk/tooling/maven/slingstart-maven-plugin/src/main/java/org/apache/sling/maven/slingstart/PreparePackageMojo.java Fri Jan 8 15:31:20 2016
@@ -57,6 +57,7 @@ import org.apache.sling.provisioning.mod
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
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
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
}
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
return text.replaceAll("\\\\\\$", "\\$");
}
-}
+}
\ No newline at end of file