[java-idp-plugin-jetty] 02/02: JJETTY-52 Allow downloadjetty.bat and downloadprocrun.bat to use Jetty and Procrun archives from a local folder

Codeberg noreply at shibboleth.net
Tue Oct 27 13:53:28 UTC 2026


This is an automated email from the git hooks/post-receive script.

codeberg pushed a commit to branch main
in repository java-idp-plugin-jetty.

View the commit online:
https://codeberg.org/Shibboleth/java-idp-plugin-jetty/commit/33ee690488d3930f9358e3d0b2242bc40f8d73e8

commit 33ee690488d3930f9358e3d0b2242bc40f8d73e8
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Tue Oct 27 13:31:31 2026 +0000

    JJETTY-52 Allow downloadjetty.bat and downloadprocrun.bat to use Jetty and Procrun archives from a local folder
    
    https://shibboleth.atlassian.net/browse/JJETTY-52
    
    add --sourceDir parameter.  Plus tests
---
 .../jetty/cli/impl/JettyDownloadArguments.java     | 33 ++++++++++++--
 .../plugin/jetty/cli/impl/JettyDownloadCLI.java    | 45 ++++++++++++++++---
 .../jetty/cli/impl/JettyDownloadCLITest.java       | 50 +++++++++++++++++++++-
 jetty-cli/src/test/resources/logback-test.xml      |  2 +-
 4 files changed, 117 insertions(+), 13 deletions(-)

diff --git a/jetty-cli/src/main/java/net/shibboleth/idp/plugin/jetty/cli/impl/JettyDownloadArguments.java b/jetty-cli/src/main/java/net/shibboleth/idp/plugin/jetty/cli/impl/JettyDownloadArguments.java
index 1340869..39d05cf 100644
--- a/jetty-cli/src/main/java/net/shibboleth/idp/plugin/jetty/cli/impl/JettyDownloadArguments.java
+++ b/jetty-cli/src/main/java/net/shibboleth/idp/plugin/jetty/cli/impl/JettyDownloadArguments.java
@@ -54,9 +54,15 @@ public class JettyDownloadArguments extends AbstractIdPHomeAwareCommandLineArgum
     @Parameter(names= {"--classifier"})
     @Nonnull private String classifier="";
 
+    /** Default base of the repo. */
+    @Nonnull final private static String DEFAULT_MAVEN_BASE="https://repo1.maven.org/maven2";
     /** Base of the repo. */
     @Parameter(names= {"--mavenbase"})
-    @Nonnull private String mavenbase="https://repo1.maven.org/maven2";
+    @Nonnull private String mavenbase=DEFAULT_MAVEN_BASE;
+
+    /** Alternative source for downloads */
+    @Parameter(names= {"--sourceDir"})
+    @Nullable private String sourceDir=null;
 
     /** keystore Location. */
     @Parameter(names= {"--keystore"})
@@ -91,8 +97,12 @@ public class JettyDownloadArguments extends AbstractIdPHomeAwareCommandLineArgum
         out.println(String.format("  %-22s %s", "--artifactId", "(Maven) ArtifactId to download. Defaults to \"jetty-home\"."));
         out.println(String.format("  %-22s %s", "--type", "File type to download. Defaults to \"tar.gz\"."));
         out.println(String.format("  %-22s %s", "--classifier", "(Maven) classifier to download. Optional."));
-        out.println(String.format("  %-22s %s", "--mavenbase", "Root URL for the Maven Repository to download from. Defaults to \"https://repo1.maven.org/maven2\""));
-        out.println(String.format("  %-22s %s", "--keystore", "Keystore to check signatures against.  Defaults to \"credentials/jetty-base-download-keystore.gpg\"."));
+        out.println(String.format("  %-22s %s", "--mavenbase", "Root URL for the Maven Repository to download from."));
+        out.println(String.format("  %-22s %s", "", "Defaults to \"" + DEFAULT_MAVEN_BASE + "\""));
+        out.println(String.format("  %-22s %s", "--sourceDir\"", "Path to a directory where artfacts and their signature have already been downloaded"));
+       
+        out.println(String.format("  %-22s %s", "--keystore", "Keystore to check signatures against."));
+        out.println(String.format("  %-22s %s", "", "Defaults to \"credentials/jetty-base-download-keystore.gpg\"."));
     }
 
 
@@ -195,10 +205,27 @@ public class JettyDownloadArguments extends AbstractIdPHomeAwareCommandLineArgum
         return baseURL;
     }
 
+    /** Get the location where the already-downloaded artifacts are.
+     * @return As specified by the user.
+     */
+    @Nullable public String getSourceDir() {
+        return sourceDir;
+    }
+
     /** get keystore location (relative to idp home).
      * @return the location
      */
     public String getKeystore() {
         return keystore;
     }
+
+    @Override
+    public void validate() throws IllegalArgumentException {
+
+        if ((sourceDir != null) &&
+            (!DEFAULT_MAVEN_BASE.equals(mavenbase) ||
+             baseURL != null)) {
+            throw new IllegalArgumentException("--sourceDir specified as well as --mavenbase or --baseURL");
+        }
+    }
 }
diff --git a/jetty-cli/src/main/java/net/shibboleth/idp/plugin/jetty/cli/impl/JettyDownloadCLI.java b/jetty-cli/src/main/java/net/shibboleth/idp/plugin/jetty/cli/impl/JettyDownloadCLI.java
index 6b7722c..f12f5b4 100644
--- a/jetty-cli/src/main/java/net/shibboleth/idp/plugin/jetty/cli/impl/JettyDownloadCLI.java
+++ b/jetty-cli/src/main/java/net/shibboleth/idp/plugin/jetty/cli/impl/JettyDownloadCLI.java
@@ -181,14 +181,14 @@ public class JettyDownloadCLI extends AbstractIdPHomeAwareCommandLine<JettyDownl
             .append(args.getType())
             .toString();
 
-        final String pathString = Constraint.isNotNull(
-                                                       getApplicationContext().getEnvironment().getProperty("idp.home"), "idp home must be specified");
+        final String pathString =
+                 Constraint.isNotNull(getApplicationContext().getEnvironment().getProperty("idp.home"), "idp home must be specified");
         final Path idpHome;
         try {
             idpHome = Path.of(pathString);
         } catch (final Exception ex) {
             log.error("Could not find idp home at {}", pathString, ex);
-	    return RC_IO;
+            return RC_IO;
         }
 
         if (!args.isNoSigCheck()) {
@@ -208,14 +208,19 @@ public class JettyDownloadCLI extends AbstractIdPHomeAwareCommandLine<JettyDownl
             }
         } else {
             try {
-		Files.createDirectory(downloadsDir);
+                Files.createDirectory(downloadsDir);
             } catch (final IOException e) {
                 log.error("Could not create {}", downloadsDir, e);
-		return RC_IO;
+                return RC_IO;
             }
         }
 
-        int result = download(args);
+        int result;
+        if (args.getSourceDir() != null) {
+            result = copy(args);
+        } else {
+            result = download(args);
+        }
         if (result != RC_OK) {
             return result;
         }
@@ -250,7 +255,7 @@ public class JettyDownloadCLI extends AbstractIdPHomeAwareCommandLine<JettyDownl
                 Files.deleteIfExists(downloadsDir.resolve(downloadFileName));
                 Files.deleteIfExists(downloadsDir.resolve(downloadFileName+".asc"));
             } catch (IOException e1) {
-                // If we couldn't delete its not a big deal.
+                // If we couldn't delete it's not a big deal.
             }
             log.error("Download failed", e);
             return RC_IO;
@@ -258,6 +263,32 @@ public class JettyDownloadCLI extends AbstractIdPHomeAwareCommandLine<JettyDownl
         return RC_OK;
     }
 
+    /** Copy the files from the provided directory
+     * @param args the {@link JettyDownloadArguments} we were given.
+     * @return an RC result
+     */
+    private int copy(JettyDownloadArguments args) {
+        final Path fromTgz = Path.of(args.getSourceDir(), downloadFileName);
+        final Path fromTgzAsc = Path.of(args.getSourceDir(), downloadFileName + ".asc");
+        final Path toTgz = downloadsDir.resolve(downloadFileName);
+        final Path toTgzAsc = downloadsDir.resolve(downloadFileName + ".asc");
+
+        try {
+            Files.copy(fromTgz, toTgz);
+            Files.copy(fromTgzAsc, toTgzAsc);
+        } catch (IOException e) {
+            try {
+                Files.deleteIfExists(toTgz);
+                Files.deleteIfExists(toTgzAsc);
+            } catch (IOException e1) {
+                // If we couldn't delete it's not a big deal.
+            }
+            log.error("Copy failed", e);
+            return RC_IO;
+        }
+        return RC_OK;
+    }
+
     /** Check the signature on the downloaded files.
      * @param args the {@link JettyDownloadArguments} we were given.
      * @return an RC result
diff --git a/jetty-cli/src/test/java/net/shibboleth/idp/plugin/jetty/cli/impl/JettyDownloadCLITest.java b/jetty-cli/src/test/java/net/shibboleth/idp/plugin/jetty/cli/impl/JettyDownloadCLITest.java
index a516464..7162c08 100644
--- a/jetty-cli/src/test/java/net/shibboleth/idp/plugin/jetty/cli/impl/JettyDownloadCLITest.java
+++ b/jetty-cli/src/test/java/net/shibboleth/idp/plugin/jetty/cli/impl/JettyDownloadCLITest.java
@@ -15,6 +15,8 @@
 package net.shibboleth.idp.plugin.jetty.cli.impl;
 
 import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotEquals;
 import static org.testng.Assert.assertTrue;
 
 import java.io.IOException;
@@ -40,6 +42,8 @@ public class JettyDownloadCLITest {
 
     private static Path idpHome;
     
+    private static final String JETTY_VERSION="12.1.14";
+
     @Nonnull private final Logger log = LoggerFactory.getLogger(JettyDownloadCLITest.class);
 
     @BeforeSuite public void setupIdpHome() throws IOException {
@@ -78,8 +82,50 @@ public class JettyDownloadCLITest {
     }
    
     @Test public void TestDownloadJetty() {
-        assertEquals(JettyDownloadCLI.runMain(new String[] {"-v", "12.0.23"}), AbstractCommandLine.RC_OK);
-        assertTrue(idpHome.resolve("jetty-dist/jetty-home-12.0.23/jetty-home-12.0.23-cyclonedx.json").toFile().exists());
+        assertEquals(JettyDownloadCLI.runMain(new String[] {"-v", JETTY_VERSION}), AbstractCommandLine.RC_OK);
+        assertTrue(idpHome.resolve("jetty-dist/jetty-home-"+JETTY_VERSION +"/jetty-home-"+JETTY_VERSION+"-cyclonedx.json").toFile().exists());
+    }
+
+    @Test(dependsOnMethods = "TestDownloadJetty") public void TestJettyFromDir() throws IOException {
+        final String tgzName = "jetty-home-"+JETTY_VERSION +".tar.gz";
+        final Path fromTgz = idpHome.resolve("jetty-dist/" + tgzName);
+        final Path fromAsc = idpHome.resolve("jetty-dist/" +  tgzName + ".asc");
+        final Path toDir = idpHome.resolve("XFR");
+        final Path toTgz = toDir.resolve(tgzName); 
+        final Path toAsc = toDir.resolve(tgzName+  ".asc");
+
+        assertTrue(Files.exists(fromTgz));
+        assertTrue(Files.exists(fromAsc));
+
+        Files.createDirectory(toDir);
+        Files.move(fromTgz, toTgz);
+        Files.move(fromAsc, toAsc);
+
+        assertFalse(Files.exists(fromTgz));
+        assertFalse(Files.exists(fromAsc));
+        assertTrue(Files.exists(toTgz));
+        assertTrue(Files.exists(toAsc));
+
+        assertEquals(JettyDownloadCLI.runMain(new String[] {"-v", JETTY_VERSION,
+        		                                            "--sourceDir", toDir.toFile().getAbsolutePath()}),
+        		     AbstractCommandLine.RC_OK);
+        assertTrue(idpHome.resolve("jetty-dist/jetty-home-"+JETTY_VERSION +"/jetty-home-"+JETTY_VERSION+"-cyclonedx.json").toFile().exists());
+
+    }
+    
+    @Test public void TestBadQualifiers() {
+    	
+        assertNotEquals(JettyDownloadCLI.runMain(
+        		new String[] {"-v", JETTY_VERSION,
+				              "--sourceDir", "foobar",
+				              "--mavenbase", "barfoo"}),
+   		     AbstractCommandLine.RC_OK);
+        assertNotEquals(JettyDownloadCLI.runMain(
+        		new String[] {"-v", JETTY_VERSION,
+				              "--sourceDir", "foobar",
+				              "--baseURL", "http://example.org/"}),
+   		     AbstractCommandLine.RC_OK);
+    	
     }
     
     @Test public void TestDownloadProcrun() {
diff --git a/jetty-cli/src/test/resources/logback-test.xml b/jetty-cli/src/test/resources/logback-test.xml
index bcd3ac1..25afcdc 100644
--- a/jetty-cli/src/test/resources/logback-test.xml
+++ b/jetty-cli/src/test/resources/logback-test.xml
@@ -16,7 +16,7 @@
         <appender-ref ref="STDOUT" />
     </root>
     
-    <logger name="net.shibboleth.idp.plugin.jetty" level="TRACE" />
+    <logger name="net.shibboleth.idp.plugin.jetty" level="DEBUG" />
     <logger name="net.shibboleth.idp.installer" level="DEBUG" />
 
 </configuration>

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list