You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ss...@apache.org on 2024/11/29 13:40:46 UTC
(sling-project-archetype) branch master updated: SLING-12511 Use latest Sling Starter release when creating a new project (#16)
This is an automated email from the ASF dual-hosted git repository.
sseifert 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 17fcda5 SLING-12511 Use latest Sling Starter release when creating a new project (#16)
17fcda5 is described below
commit 17fcda54b8c61388a2b656f9ed34e5afb23de73c
Author: Stefan Seifert <st...@users.noreply.github.com>
AuthorDate: Fri Nov 29 14:40:42 2024 +0100
SLING-12511 Use latest Sling Starter release when creating a new project (#16)
---
README.md | 2 +-
.../resources/META-INF/archetype-post-generate.groovy | 18 ++++++++++++++++++
src/main/resources/archetype-resources/pom.xml | 2 +-
3 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index bb0181d..54674db 100644
--- a/README.md
+++ b/README.md
@@ -16,7 +16,7 @@
#### Introduction
-This archetype will create a Sling project that can be deployed on the Sling 12. In contrast to
+This archetype will create a Sling project that can be deployed on the Sling. In contrast to
the Apache Sling Maven Archetypes this one is geared towards creating a full project and not
just a single module.
diff --git a/src/main/resources/META-INF/archetype-post-generate.groovy b/src/main/resources/META-INF/archetype-post-generate.groovy
index e8d3975..d17f54d 100644
--- a/src/main/resources/META-INF/archetype-post-generate.groovy
+++ b/src/main/resources/META-INF/archetype-post-generate.groovy
@@ -14,9 +14,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+@Grab(group="org.apache.groovy", module="groovy-xml", version="4.0.24")
import java.util.regex.Pattern
import org.apache.commons.io.FileUtils
+import groovy.xml.XmlSlurper
def rootDir = new File(request.getOutputDirectory() + "/" + request.getArtifactId())
@@ -86,6 +88,22 @@ def removeTags(pomFile, forAll) {
}
}
+// Use latest Sling Starter version from Maven Central
+def useLatestSlingStarterVersion(pomFile) {
+ def metadata = new XmlSlurper().parse("https://repo1.maven.org/maven2/org/apache/sling/org.apache.sling.starter/maven-metadata.xml")
+ def latestVersion = metadata.versioning.latest.toString()
+ assert latestVersion != null && latestVersion != ""
+ def pomContent = pomFile.getText("UTF-8")
+ pomContent = pomContent.replaceAll("@SLING_STARTER_LATEST_VERSION@", latestVersion)
+ pomFile.newWriter("UTF-8").withWriter { w ->
+ w << pomContent
+ }
+}
+
+
+// use latest sling starter version
+useLatestSlingStarterVersion(rootPom)
+
if(optionAll == "n") {
// Remove All Package / Module
assert allPackage.deleteDir()
diff --git a/src/main/resources/archetype-resources/pom.xml b/src/main/resources/archetype-resources/pom.xml
index e8b3998..611faf9 100644
--- a/src/main/resources/archetype-resources/pom.xml
+++ b/src/main/resources/archetype-resources/pom.xml
@@ -95,7 +95,7 @@
<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>
+ <sling.starter.version>@SLING_STARTER_LATEST_VERSION@</sling.starter.version>
</properties>
<build>