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 2022/03/22 16:12:27 UTC
[sling-whiteboard] branch master updated: Prototype JBang SlingStarter script
This is an automated email from the ASF dual-hosted git repository.
bdelacretaz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-whiteboard.git
The following commit(s) were added to refs/heads/master by this push:
new 2bfed6b Prototype JBang SlingStarter script
2bfed6b is described below
commit 2bfed6b475b6cc4986165b2c0128e9cc7c6c6bb2
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Tue Mar 22 17:08:21 2022 +0100
Prototype JBang SlingStarter script
---
jbang-catalog.json | 2 +-
jbang/SlingStarter.java | 70 +++++++++++++++++++++++++++++++++++++++++++++++++
start.java | 40 ----------------------------
3 files changed, 71 insertions(+), 41 deletions(-)
diff --git a/jbang-catalog.json b/jbang-catalog.json
index d955459..f99c4d4 100644
--- a/jbang-catalog.json
+++ b/jbang-catalog.json
@@ -2,7 +2,7 @@
"catalogs": {},
"aliases": {
"start": {
- "script-ref": "start.java",
+ "script-ref": "jbang/SlingStarter.java",
"description": "Start Apache Sling"
},
"repoinitValidator": {
diff --git a/jbang/SlingStarter.java b/jbang/SlingStarter.java
new file mode 100644
index 0000000..9e6d2ad
--- /dev/null
+++ b/jbang/SlingStarter.java
@@ -0,0 +1,70 @@
+///usr/bin/env jbang "$0" "$@" ; exit $?
+
+/*
+ * 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.
+ */
+
+//DEPS org.apache.sling:org.apache.sling.feature.launcher:1.2.0
+//DEPS commons-cli:commons-cli:1.4
+//DEPS org.apache.commons:commons-lang3:3.12.0
+//DEPS org.apache.commons:commons-text:1.9
+//DEPS org.apache.felix:org.apache.felix.cm.json:1.0.6
+//DEPS org.apache.felix:org.apache.felix.converter:1.0.18
+//DEPS org.apache.sling:org.apache.sling.commons.johnzon:1.2.14
+//DEPS org.apache.sling:org.apache.sling.feature:1.2.30
+//DEPS org.apache.sling:org.apache.sling.feature.launcher:1.2.0
+//DEPS org.osgi:org.osgi.annotation.versioning:1.1.1
+//DEPS org.osgi:org.osgi.util.function:1.0.0
+//DEPS org.osgi:osgi.core:7.0.0
+//DEPS org.slf4j:slf4j-api:1.7.25
+//DEPS org.slf4j:slf4j-simple:1.7.25
+
+import org.apache.sling.feature.launcher.impl.Main;
+
+/** Thanks to the JBang catalog found at https://github.com/apache/sling-whiteboard/blob/master/jbang-catalog.json
+ * this can be started using
+ *
+ * jbang start@apache/sling-whiteboard
+ *
+ * After installing JBang from https://www.jbang.dev/
+ *
+ */
+class SlingStarter {
+
+ public static void main(String[] args) {
+
+ // Starter 12 is the only version that we distribute like
+ // this, so there's no other version to switch to. Not yet.
+ final int defaultVersion = 12;
+ final int version = args == null || args.length == 0 ? defaultVersion : Integer.valueOf(args[0]);
+ final String farURL = String.format(
+ "https://repo1.maven.org/maven2/org/apache/sling/org.apache.sling.starter/%d/org.apache.sling.starter-%d-oak_tar_far.far",
+ version,
+ version
+ );
+
+ System.err.println(String.format("Starting Apache Sling %d using the Feature Launcher", version));
+ System.err.println("The first run of this script is slower, as it downloads the Sling starter feature file and dependencies");
+ System.err.println("Starter feature file: " + farURL);
+ System.err.println("TODO: need to handle arguments such as Sling server port number etc.");
+
+ final String [] starterArgs = {
+ "-f",
+ farURL
+ };
+ Main.main(starterArgs);
+ }
+}
\ No newline at end of file
diff --git a/start.java b/start.java
deleted file mode 100644
index 2d37531..0000000
--- a/start.java
+++ /dev/null
@@ -1,40 +0,0 @@
-//usr/bin/env jbang "$0" "$@" ; exit $?
-// //DEPS <dependency1> <dependency2>
-
-/*
- * 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.
- */
-
-import java.util.Arrays;
-
-/* Minimal example that can be started from jbang using
- * jbang start@apache/sling-whiteboard
- */
-public class start {
-
- public static void main(String... args) {
- System.out.print("This is just a stub for now but could start Apache Sling");
- if(args.length > 0) {
- System.out.print(
- String.format(
- " with the following arguments: %s",
- Arrays.asList(args)
- )
- );
- }
- System.out.println();
- }
-}