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/03/31 13:47:12 UTC

[sling-org-apache-sling-feature-launcher] branch master updated: SLING-11814: Add support for the -CO / --cacheOnly flag which only downloads the required dependency artifacts and does not actually start the framework

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-org-apache-sling-feature-launcher.git


The following commit(s) were added to refs/heads/master by this push:
     new a9ed0c1  SLING-11814: Add support for the -CO / --cacheOnly flag which only downloads the required dependency artifacts and does not actually start the framework
a9ed0c1 is described below

commit a9ed0c1f0251ca017d63a4cf6f6169706740e3b6
Author: Michael Lescisin <mi...@uhn.ca>
AuthorDate: Tue Mar 28 11:56:17 2023 -0400

    SLING-11814: Add support for the -CO / --cacheOnly flag which only downloads the required dependency artifacts and does not actually start the framework
---
 .../org/apache/sling/feature/launcher/impl/Bootstrap.java  |  5 +++++
 .../apache/sling/feature/launcher/impl/LauncherConfig.java | 10 ++++++++++
 .../java/org/apache/sling/feature/launcher/impl/Main.java  | 14 ++++++++++++++
 3 files changed, 29 insertions(+)

diff --git a/src/main/java/org/apache/sling/feature/launcher/impl/Bootstrap.java b/src/main/java/org/apache/sling/feature/launcher/impl/Bootstrap.java
index 8e9201b..e094748 100644
--- a/src/main/java/org/apache/sling/feature/launcher/impl/Bootstrap.java
+++ b/src/main/java/org/apache/sling/feature/launcher/impl/Bootstrap.java
@@ -160,6 +160,11 @@ public class Bootstrap {
                         this.config.getLocalArtifacts(), this.config.getCachedArtifacts(),
                         this.config.getDownloadedArtifacts());
 
+                if (this.config.getCacheOnly()) {
+                    this.logger.info("Finished downloading any requirements...exiting!");
+                    System.exit(0);
+                }
+
                 if (restart) {
                     this.config.getInstallation().getInstallableArtifacts().clear();
                     this.config.getInstallation().getConfigurations().clear();
diff --git a/src/main/java/org/apache/sling/feature/launcher/impl/LauncherConfig.java b/src/main/java/org/apache/sling/feature/launcher/impl/LauncherConfig.java
index 29bd393..64b5af6 100644
--- a/src/main/java/org/apache/sling/feature/launcher/impl/LauncherConfig.java
+++ b/src/main/java/org/apache/sling/feature/launcher/impl/LauncherConfig.java
@@ -60,6 +60,8 @@ public class LauncherConfig
 
     private volatile ArtifactId launchFeatureId;
 
+    private volatile boolean cacheOnly = false;
+
     /**
      * Create a new configuration object.
      * Set the default values
@@ -149,4 +151,12 @@ public class LauncherConfig
     public ArtifactId getLaunchFeatureId() {
         return this.launchFeatureId;
     }
+
+    public boolean getCacheOnly() {
+        return this.cacheOnly;
+    }
+
+    public void setCacheOnly(final boolean value) {
+        this.cacheOnly = value;
+    }
 }
diff --git a/src/main/java/org/apache/sling/feature/launcher/impl/Main.java b/src/main/java/org/apache/sling/feature/launcher/impl/Main.java
index 1756774..478f8c0 100644
--- a/src/main/java/org/apache/sling/feature/launcher/impl/Main.java
+++ b/src/main/java/org/apache/sling/feature/launcher/impl/Main.java
@@ -75,6 +75,8 @@ public class Main {
 
     public static final String OPT_LAUNCH_FEATURE_ID = "i";
 
+    public static final String OPT_CACHE_ONLY = "CO";
+
     private static Logger LOGGER;
 
     private static Options options;
@@ -208,6 +210,12 @@ public class Main {
                 .numberOfArgs(1)
                 .build();
 
+        final Option cacheOnlyOption = Option.builder(OPT_CACHE_ONLY)
+                .longOpt("cacheOnly")
+                .desc("Cache only the required dependencies. Don't start the framework.")
+                .optionalArg(true)
+                .build();
+
         final Option cacheOption = Option.builder(OPT_CACHE_DIR)
                 .longOpt("cache_dir")
                 .desc("Set cache dir")
@@ -258,6 +266,7 @@ public class Main {
                 .addOption(fwkProperties)
                 .addOption(varValue)
                 .addOption(debugOption)
+                .addOption(cacheOnlyOption)
                 .addOption(cacheOption)
                 .addOption(homeOption)
                 .addOption(extensionConfiguration)
@@ -267,6 +276,7 @@ public class Main {
 
         
         final CommandLineParser clp = new DefaultParser();
+
         try {
             final CommandLine cl = clp.parse(options, args);
 
@@ -303,6 +313,10 @@ public class Main {
                 });
             } // if not the `org.slf4j.simpleLogger.defaultLogLevel` is by default `info`
 
+            if (cl.hasOption(OPT_CACHE_ONLY)) {
+                    config.setCacheOnly(true);
+            }
+
             extractValuesFromOption(cl, OPT_FEATURE_FILES).orElseGet(ArrayList::new)
                     .forEach(config::addFeatureFiles);