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 2022/02/25 16:22:46 UTC

[sling-project-archetype] branch master updated: SLING-10601 - Add a launcher module to the project archetype (#5)

This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-project-archetype.git


The following commit(s) were added to refs/heads/master by this push:
     new 4521919  SLING-10601 - Add a launcher module to the project archetype (#5)
4521919 is described below

commit 452191942b80e90e07bfb23c9c3c111b8ded32f8
Author: Robert Munteanu <ro...@apache.org>
AuthorDate: Fri Feb 25 17:22:42 2022 +0100

    SLING-10601 - Add a launcher module to the project archetype (#5)
    
    Add a launcher module, always generated.
---
 pom.xml                                            |   1 -
 .../META-INF/maven/archetype-metadata.xml          |  16 +++
 .../resources/archetype-resources/README.All.md    |   7 +-
 .../resources/archetype-resources/README.NotAll.md |   7 +-
 .../archetype-resources/launcher/launch.sh         |  24 +++++
 .../resources/archetype-resources/launcher/pom.xml | 120 +++++++++++++++++++++
 .../launcher/src/main/features/launcher.json       |  13 +++
 src/main/resources/archetype-resources/pom.xml     |  17 +++
 src/test/resources/projects/all/verify.groovy      |  25 +++++
 src/test/resources/settings.xml                    |  37 +++++++
 10 files changed, 262 insertions(+), 5 deletions(-)

diff --git a/pom.xml b/pom.xml
index abcbdb3..4a69d7b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -67,7 +67,6 @@
             <plugins>
                 <plugin>
                     <artifactId>maven-archetype-plugin</artifactId>
-                    <version>3.1.2</version>
                 </plugin>
             </plugins>
         </pluginManagement>
diff --git a/src/main/resources/META-INF/maven/archetype-metadata.xml b/src/main/resources/META-INF/maven/archetype-metadata.xml
index a864e0b..ef08d1b 100644
--- a/src/main/resources/META-INF/maven/archetype-metadata.xml
+++ b/src/main/resources/META-INF/maven/archetype-metadata.xml
@@ -159,6 +159,22 @@
                 </fileSet>
             </fileSets>
         </module>
+        <module id="launcher" dir="launcher" name="launcher">
+            <fileSets>
+                <fileSet filtered="true" encoding="UTF-8">
+                    <directory>src/main/features</directory>
+                    <includes>
+                        <include>**/*.json</include>
+                    </includes>
+                </fileSet>
+                <fileSet encoding="UTF-8">
+                    <directory></directory>
+                    <includes>
+                        <include>*.sh</include>
+                    </includes>
+                </fileSet>
+            </fileSets>
+        </module>
         <module id="all" dir="all" name="all">
             <!--<fileSets>-->
                 <!--<fileSet filtered="true" encoding="UTF-8">-->
diff --git a/src/main/resources/archetype-resources/README.All.md b/src/main/resources/archetype-resources/README.All.md
index 56a33ea..e20dcbf 100644
--- a/src/main/resources/archetype-resources/README.All.md
+++ b/src/main/resources/archetype-resources/README.All.md
@@ -22,7 +22,7 @@
 #### Introduction
 
 This project was created by the Full Project Sling Maven Archetype which created
-three modules:
+four modules:
 
 1. **core**: OSGi Bundle which is deployed as OSGi Bundle to Sling which includes your
              Servlets, Filters, Sling Models and much more. This module is **not intended**
@@ -30,7 +30,9 @@ three modules:
 2. **ui.apps**: JCR Content Module which is used to install a JCR Package into Sling
                 by using **Composum**. For that it must be installed and the Composum
                 Package Manager must be whitelisted.
-3. **all**: This is another JCR Content Module but it is only used to install the
+3. **launcher**: Feature model module which assembles a full application from the project
+                 which can then be launched using the included `./launch.sh` script
+4. **all**: This is another JCR Content Module but it is only used to install the
             other two modules. 
 
 There are also two more modules that provide some examples with the same name plus
@@ -101,6 +103,7 @@ with **core.example** and **ui.apps.example**.
         <module>core.example</module>
         <module>ui.apps</module>
         <module>ui.apps.example</module>
+        <module>launcher</module>
         <module>all</module>
     </modules>
 
diff --git a/src/main/resources/archetype-resources/README.NotAll.md b/src/main/resources/archetype-resources/README.NotAll.md
index 3e69d10..31b40b6 100644
--- a/src/main/resources/archetype-resources/README.NotAll.md
+++ b/src/main/resources/archetype-resources/README.NotAll.md
@@ -22,12 +22,14 @@
 #### Introduction
 
 This project was created by the Sling Project Maven Archetype which created
-two modules:
+three modules:
 
 1. **core**: OSGi Bundle which is deployed as OSGi Bundle to Sling which includes your
              Servlets, Filters, Sling Models and much more. This module is **not intended**
              to contain Sling Content.
-2. **ui.apps**: JCR Content Module which is used to install a JCR Package into Sling
+2. **launcher**: Feature model module which assembles a full application from the project
+                 which can then be launched using the included `./launch.sh` script
+3. **ui.apps**: JCR Content Module which is used to install a JCR Package into Sling
                 by using **Composum**. For that it must be installed and the Composum
                 Package Manager must be whitelisted.
 
@@ -50,6 +52,7 @@ with **core.example** and **ui.apps.example**.
         <module>core.example</module>
         <module>ui.apps</module>
         <module>ui.apps.example</module>
+        <module>launcher</module>
     </modules>
 
 #### Why a JCR Package instead of a Content Bundle
diff --git a/src/main/resources/archetype-resources/launcher/launch.sh b/src/main/resources/archetype-resources/launcher/launch.sh
new file mode 100755
index 0000000..79c5771
--- /dev/null
+++ b/src/main/resources/archetype-resources/launcher/launch.sh
@@ -0,0 +1,24 @@
+#!/bin/sh -eu
+#
+# 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.
+#
+
+echo '-------------------------------------------------------------------------------------------'
+echo '[NOTE] Launching application, this will fail if you did not build the project at least once'
+echo '[NOTE] Remove the launcher folder to throw away local changes'
+echo '-------------------------------------------------------------------------------------------'
+
+java -jar target/dependency/org.apache.sling.feature.launcher.jar -f target/slingfeature-tmp/feature-app.json 
diff --git a/src/main/resources/archetype-resources/launcher/pom.xml b/src/main/resources/archetype-resources/launcher/pom.xml
new file mode 100644
index 0000000..5d1c0f5
--- /dev/null
+++ b/src/main/resources/archetype-resources/launcher/pom.xml
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!-- 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. -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <artifactId>\${rootArtifactId}</artifactId>
+        <groupId>\${groupId}</groupId>
+        <version>\${version}</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <artifactId>\${artifactId}</artifactId>
+
+    <name>\${artifactName} - Launcher</name>
+    <description>
+        This is a Module which contains a sample feature model build, built on
+        top of the Sling Starter and adding this project's artifacts.
+    </description>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.sling</groupId>
+                <artifactId>slingfeature-maven-plugin</artifactId>
+                <extensions>true</extensions>
+
+                <configuration>
+                    <skipAddFeatureDependencies>true</skipAddFeatureDependencies>
+                    <framework>
+                        <groupId>org.apache.felix</groupId>
+                        <artifactId>org.apache.felix.framework</artifactId>
+                        <version>\${org.apache.felix.framework.version}</version>
+                    </framework>
+
+                    <!--
+                        Prepares a feature model aggregate that takes the following features from
+                        the Sling Starter:
+                        - nosample_base - the base Sling Starter
+                        - oak_persistence_sns - SegmentNodeStore persistence for Oak
+                        - composum - The Composum Nodes administration tool
+
+                        Notably missing are the slingshot and starter samples
+                     -->
+                    <aggregates>
+                        <aggregate>
+                            <classifier>app</classifier>
+                            <filesInclude>*.json</filesInclude>
+                            <includeArtifact>
+                                <groupId>org.apache.sling</groupId>
+                                <artifactId>org.apache.sling.starter</artifactId>
+                                <classifier>nosample_base</classifier>
+                                <version>\${sling.starter.version}</version>
+                                <type>slingosgifeature</type>
+                            </includeArtifact>
+                            <includeArtifact>
+                                <groupId>org.apache.sling</groupId>
+                                <artifactId>org.apache.sling.starter</artifactId>
+                                <classifier>oak_persistence_sns</classifier>
+                                <version>\${sling.starter.version}</version>
+                                <type>slingosgifeature</type>
+                            </includeArtifact>
+                            <includeArtifact>
+                                <groupId>org.apache.sling</groupId>
+                                <artifactId>org.apache.sling.starter</artifactId>
+                                <classifier>composum</classifier>
+                                <version>\${sling.starter.version}</version>
+                                <type>slingosgifeature</type>
+                            </includeArtifact>
+                        </aggregate>
+                    </aggregates>
+                    <scans>
+                        <scan>
+                            <includeClassifier>app</includeClassifier>
+                        </scan>
+                    </scans>
+                </configuration>
+                <executions>
+                    <execution>
+                        <id>prepare-features</id>
+                        <phase>prepare-package</phase>
+                        <goals>
+                            <goal>aggregate-features</goal>
+                            <goal>analyse-features</goal>
+                            <goal>attach-features</goal>
+                        </goals>
+                    </execution>
+               </executions>
+            </plugin>
+            <plugin>
+                <artifactId>maven-dependency-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>prepare-feature-launcher</id>
+                        <goals>
+                            <goal>get</goal>
+                            <goal>copy</goal>
+                        </goals>
+                        <phase>package</phase>
+                        <configuration>
+                            <artifact>org.apache.sling:org.apache.sling.feature.launcher:\${org.apache.sling.feature.launcher.version}</artifact>
+                            <stripVersion>true</stripVersion>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+</project>
diff --git a/src/main/resources/archetype-resources/launcher/src/main/features/launcher.json b/src/main/resources/archetype-resources/launcher/src/main/features/launcher.json
new file mode 100644
index 0000000..78bd13b
--- /dev/null
+++ b/src/main/resources/archetype-resources/launcher/src/main/features/launcher.json
@@ -0,0 +1,13 @@
+{
+  "bundles": [
+    {
+        "id": "${groupId}/core/${version}",
+        "start-order": 20
+    }
+  ],
+  "content-packages:ARTIFACTS|required": [
+    {
+        "id":"${groupId}/ui.apps/${version}/zip"
+    }
+  ]
+}
\ No newline at end of file
diff --git a/src/main/resources/archetype-resources/pom.xml b/src/main/resources/archetype-resources/pom.xml
index 67f453c..bb61600 100644
--- a/src/main/resources/archetype-resources/pom.xml
+++ b/src/main/resources/archetype-resources/pom.xml
@@ -75,6 +75,7 @@
         <wcmio.plugin.version>1.7.6</wcmio.plugin.version>
         <!-- TODO: Could not upgrade to 1.1.x as some tests prevent the creation of All packages -->
         <filevault-package.plugin.version>1.0.4</filevault-package.plugin.version>
+        <slingfeature.plugin.version>1.5.10</slingfeature.plugin.version>
 
         <osgi.core.version>7.0.0</osgi.core.version>
         <osgi.annotation.version>7.0.0</osgi.annotation.version>
@@ -84,14 +85,17 @@
         <javax.servlet-api.version>3.1.0</javax.servlet-api.version>
         <javax.inject.version>1</javax.inject.version>
         <jcr.version>2.0</jcr.version>
+        <org.apache.felix.framework.version>7.0.1</org.apache.felix.framework.version>
         <org.apache.sling.api.version>2.22.0</org.apache.sling.api.version>
         <org.apache.sling.models.api.version>1.3.8</org.apache.sling.models.api.version>
+        <org.apache.sling.feature.launcher.version>1.1.20</org.apache.sling.feature.launcher.version>
         <jetbrains.annotations.version>19.0.0</jetbrains.annotations.version>
         <org.apache.sling.settings.version>1.3.10</org.apache.sling.settings.version>
         <org.apache.sling.commons.osgi.version>2.4.0</org.apache.sling.commons.osgi.version>
         <jackrabbit-api.version>2.19.3</jackrabbit-api.version>
         <commons-lang3.version>3.9</commons-lang3.version>
         <jmock-junit4.version>2.8.2</jmock-junit4.version>
+        <sling.starter.version>12</sling.starter.version>
     </properties>
 
     <build>
@@ -276,6 +280,19 @@
                     <artifactId>build-helper-maven-plugin</artifactId>
                     <version>${build.helper.plugin.version}</version>
                 </plugin>
+                <!-- SlingFeature Plugin -->
+                <plugin>
+                    <groupId>org.apache.sling</groupId>
+                    <artifactId>slingfeature-maven-plugin</artifactId>
+                    <version>\${slingfeature.plugin.version}</version>
+                    <dependencies>
+                        <dependency>
+                            <groupId>org.apache.sling</groupId>
+                            <artifactId>org.apache.sling.feature.launcher</artifactId>
+                            <version>\${org.apache.sling.feature.launcher.version}</version>
+                        </dependency>
+                    </dependencies>
+                </plugin>
             </plugins>
         </pluginManagement>
     </build>
diff --git a/src/test/resources/projects/all/verify.groovy b/src/test/resources/projects/all/verify.groovy
new file mode 100644
index 0000000..5fd2c84
--- /dev/null
+++ b/src/test/resources/projects/all/verify.groovy
@@ -0,0 +1,25 @@
+/*
+ * 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.
+ */
+
+def fileNames = ["pom.xml", "launcher/pom.xml", "launcher/launch.sh"]
+
+fileNames.each { fileName ->
+    def file = new File(context.projectDir, fileName);
+    assert file.exists() : "File ${file} does not exist"
+}
+
+return true
\ No newline at end of file
diff --git a/src/test/resources/settings.xml b/src/test/resources/settings.xml
new file mode 100644
index 0000000..6983442
--- /dev/null
+++ b/src/test/resources/settings.xml
@@ -0,0 +1,37 @@
+<!--
+    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.
+-->
+<settings xmlns="http://maven.apache.org/SETTINGS/1.2.0"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 http://maven.apache.org/xsd/settings-1.2.0.xsd">
+    <profiles>
+        <profile>
+            <id>asf</id>
+            <repositories>
+                <repository>
+                    <id>apache-snapshots</id>
+                    <name>Apache Snapshots</name>
+                    <url>https://repository.apache.org/content/groups/snapshots/</url>
+                </repository>
+            </repositories>
+        </profile>
+    </profiles>
+    <activeProfiles>
+        <activeProfile>asf</activeProfile>
+    </activeProfiles>
+</settings>
\ No newline at end of file