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 2023/07/12 14:13:07 UTC
[sling-project-archetype] 01/01: SLING-11922 - Create a fully expanded feature model when generating the archetype
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to branch issue/SLING-11922
in repository https://gitbox.apache.org/repos/asf/sling-project-archetype.git
commit 7e8822f96db4ca7c6d7f483cee104157ae6bec12
Author: Robert Munteanu <ro...@apache.org>
AuthorDate: Wed Jul 12 17:12:38 2023 +0300
SLING-11922 - Create a fully expanded feature model when generating the archetype
WIP
---
.../META-INF/archetype-post-generate.groovy | 36 ++++++++++++++++++
.../META-INF/maven/archetype-metadata.xml | 13 +++++--
.../resources/archetype-resources/launcher/pom.xml | 43 ++++------------------
.../resources/projects/all/archetype.properties | 3 +-
.../projects/allDeleted/archetype.properties | 3 +-
.../projects/allMerged/archetype.properties | 3 +-
.../resources/projects/notAll/archetype.properties | 3 +-
.../projects/notAllDeleted/archetype.properties | 3 +-
.../projects/notAllMerged/archetype.properties | 3 +-
9 files changed, 64 insertions(+), 46 deletions(-)
diff --git a/src/main/resources/META-INF/archetype-post-generate.groovy b/src/main/resources/META-INF/archetype-post-generate.groovy
index e8d3975..6340a5d 100644
--- a/src/main/resources/META-INF/archetype-post-generate.groovy
+++ b/src/main/resources/META-INF/archetype-post-generate.groovy
@@ -16,6 +16,8 @@
*/
import java.util.regex.Pattern
+import java.util.zip.ZipFile
+
import org.apache.commons.io.FileUtils
def rootDir = new File(request.getOutputDirectory() + "/" + request.getArtifactId())
@@ -40,6 +42,7 @@ def readmeNotAll = new File(rootDir, "README.NotAll.md")
def optionAll = request.getProperties().get("optionAll")
def optionExample = request.getProperties().get("optionExample")
+def starterRef = request.getProperties().get("slingStarterBaseRef")
// helper methods
@@ -53,6 +56,37 @@ def removeModule(pomFile, moduleName) {
}
}
+def downloadStarter(rootDir, ref) {
+ def url = new URL("https://github.com/apache/sling-org-apache-sling-starter/archive/" + ref + ".zip")
+ println("Downloading Sling Starter from ${url}")
+ def localFile = new File(rootDir, "sling-starter.zip")
+ localFile << url.getBytes()
+ def starterZip = new ZipFile(localFile)
+ def launcherDir = new File(rootDir, "launcher")
+ starterZip.entries().each { entry ->
+ println "Extracting ${entry.name}"
+ if ( entry.name.startsWith("sling-org-apache-sling-starter-master/src/main/features/") ) {
+ // remove first segment from entry.name
+ def entryName = entry.name.substring(entry.name.indexOf("/") + 1)
+ // ignore samples which are not needed (or a security risk)
+ if ( entryName.endsWith("htl_repl.json") || entryName.endsWith("starter.json") || entryName.contains("slingshot") ) {
+ return
+ }
+ // ignore test content
+ if ( entryName.contains("test") ) {
+ return
+ }
+
+ def targetFile = new File(launcherDir, entryName)
+ if(entry.isDirectory()) {
+ targetFile.mkdirs()
+ } else {
+ targetFile << starterZip.getInputStream(entry)
+ }
+ }
+ }
+}
+
// Either remove the tag lines or the line plus the content in between
// forAll = true: removes all content between @startForNotAll@ and @endForNotAll@
// forAll = false: emoves all content between @startForAll@ and @endForAll@
@@ -138,3 +172,5 @@ if(optionExample == "m") {
}
removeModule(rootPom, "ui.apps.example")
}
+
+downloadStarter(rootDir, starterRef)
\ No newline at end of file
diff --git a/src/main/resources/META-INF/maven/archetype-metadata.xml b/src/main/resources/META-INF/maven/archetype-metadata.xml
index ef08d1b..ac35ef8 100644
--- a/src/main/resources/META-INF/maven/archetype-metadata.xml
+++ b/src/main/resources/META-INF/maven/archetype-metadata.xml
@@ -17,11 +17,12 @@
specific language governing permissions and limitations
under the License.
-->
+
<archetype-descriptor
- xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0 http://maven.apache.org/xsd/archetype-descriptor-1.0.0.xsd"
- name="sling-project-archetype"
- xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="https://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="https://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.1.0 http://maven.apache.org/xsd/archetype-descriptor-1.1.0.xsd"
+ name="sling-project-archetype"
>
<requiredProperties>
<!-- <requiredProperty key="version">-->
@@ -90,6 +91,10 @@
<!-- <defaultValue>s</defaultValue>-->
<validationRegex>^(s|m|d)$</validationRegex>
</requiredProperty>
+ <!-- Git reference from the Sling Starter project use to bootstrap the launcher -->
+ <requiredProperty key="slingStarterBaseRef">
+ <defaultValue>master</defaultValue>
+ </requiredProperty>
</requiredProperties>
<fileSets>
<fileSet encoding="UTF-8">
diff --git a/src/main/resources/archetype-resources/launcher/pom.xml b/src/main/resources/archetype-resources/launcher/pom.xml
index 5d1c0f5..fa24edd 100644
--- a/src/main/resources/archetype-resources/launcher/pom.xml
+++ b/src/main/resources/archetype-resources/launcher/pom.xml
@@ -29,6 +29,11 @@
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>
+
+ <properties>
+ <!-- TODO - read from starter pom -->
+ <asm.version>9.5</asm.version>
+ </properties>
<build>
<plugins>
<plugin>
@@ -37,47 +42,13 @@
<extensions>true</extensions>
<configuration>
+ <!-- TODO - read from starter pom -->
+ <replacePropertyVariables>asm.version,jackrabbit.version,groovy.version,oak.version,slf4j.version,composum.nodes.version,jackson.version</replacePropertyVariables>
<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>
diff --git a/src/test/resources/projects/all/archetype.properties b/src/test/resources/projects/all/archetype.properties
index 31b7c30..45b5ee3 100644
--- a/src/test/resources/projects/all/archetype.properties
+++ b/src/test/resources/projects/all/archetype.properties
@@ -32,4 +32,5 @@ slingModelSubPackage=testModelAllSep
slingHostName=localhost
slingPort=8080
optionAll=y
-optionExample=s
\ No newline at end of file
+optionExample=s
+slingStarterBaseRef=master
\ No newline at end of file
diff --git a/src/test/resources/projects/allDeleted/archetype.properties b/src/test/resources/projects/allDeleted/archetype.properties
index 9b2e2e7..e4336e4 100644
--- a/src/test/resources/projects/allDeleted/archetype.properties
+++ b/src/test/resources/projects/allDeleted/archetype.properties
@@ -32,4 +32,5 @@ slingModelSubPackage=testModelAllDel
slingHostName=localhost
slingPort=8080
optionAll=y
-optionExample=d
\ No newline at end of file
+optionExample=d
+slingStarterBaseRef=master
\ No newline at end of file
diff --git a/src/test/resources/projects/allMerged/archetype.properties b/src/test/resources/projects/allMerged/archetype.properties
index 3d0baaa..8e64754 100644
--- a/src/test/resources/projects/allMerged/archetype.properties
+++ b/src/test/resources/projects/allMerged/archetype.properties
@@ -32,4 +32,5 @@ slingModelSubPackage=testModelAllMer
slingHostName=localhost
slingPort=8080
optionAll=y
-optionExample=m
\ No newline at end of file
+optionExample=m
+slingStarterBaseRef=master
\ No newline at end of file
diff --git a/src/test/resources/projects/notAll/archetype.properties b/src/test/resources/projects/notAll/archetype.properties
index 9c18001..eac0c30 100644
--- a/src/test/resources/projects/notAll/archetype.properties
+++ b/src/test/resources/projects/notAll/archetype.properties
@@ -32,4 +32,5 @@ slingModelSubPackage=testModelUISep
slingHostName=localhost
slingPort=8080
optionAll=n
-optionExample=s
\ No newline at end of file
+optionExample=s
+slingStarterBaseRef=master
\ No newline at end of file
diff --git a/src/test/resources/projects/notAllDeleted/archetype.properties b/src/test/resources/projects/notAllDeleted/archetype.properties
index 84b0362..98f0c5d 100644
--- a/src/test/resources/projects/notAllDeleted/archetype.properties
+++ b/src/test/resources/projects/notAllDeleted/archetype.properties
@@ -32,4 +32,5 @@ slingModelSubPackage=testModelUIDel
slingHostName=localhost
slingPort=8080
optionAll=n
-optionExample=d
\ No newline at end of file
+optionExample=d
+slingStarterBaseRef=master
\ No newline at end of file
diff --git a/src/test/resources/projects/notAllMerged/archetype.properties b/src/test/resources/projects/notAllMerged/archetype.properties
index 878671e..fc7ae64 100644
--- a/src/test/resources/projects/notAllMerged/archetype.properties
+++ b/src/test/resources/projects/notAllMerged/archetype.properties
@@ -32,4 +32,5 @@ slingModelSubPackage=testModelUIMer
slingHostName=localhost
slingPort=8080
optionAll=n
-optionExample=m
\ No newline at end of file
+optionExample=m
+slingStarterBaseRef=master
\ No newline at end of file