diff --git a/jetty-documentation/src/main/asciidoc/administration/startup/start-jar.adoc b/jetty-documentation/src/main/asciidoc/administration/startup/start-jar.adoc index 03b51c7554b..668cd15b089 100644 --- a/jetty-documentation/src/main/asciidoc/administration/startup/start-jar.adoc +++ b/jetty-documentation/src/main/asciidoc/administration/startup/start-jar.adoc @@ -282,7 +282,7 @@ This allows for some complex hierarchies of configuration details. --download=|:: If the file does not exist at the given location, download it from the given http URI. Note: location is always relative to `${jetty.base}`. -You might need to escape the slash "\|" to use this on some environments. +You might need to escape the pipe "\|" to use this on some environments. maven.repo.uri=[url]:: The url to use to download Maven dependencies. @@ -321,4 +321,4 @@ Alternatively to create an args file for java: ---- $ java -jar start.jar --dry-run=opts,path,main,args > /tmp/args $ java @/tmp/args ----- \ No newline at end of file +---- diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/StartArgs.java b/jetty-start/src/main/java/org/eclipse/jetty/start/StartArgs.java index 7161387a288..51b1a298917 100644 --- a/jetty-start/src/main/java/org/eclipse/jetty/start/StartArgs.java +++ b/jetty-start/src/main/java/org/eclipse/jetty/start/StartArgs.java @@ -245,9 +245,9 @@ public class StartArgs private void addFile(Module module, String uriLocation) { - if (module.isSkipFilesValidation()) + if (module != null && module.isSkipFilesValidation()) { - StartLog.debug("Not validating %s [files] for %s", module, uriLocation); + StartLog.debug("Not validating module %s [files] for %s", module, uriLocation); return; } diff --git a/jetty-start/src/main/resources/org/eclipse/jetty/start/usage.txt b/jetty-start/src/main/resources/org/eclipse/jetty/start/usage.txt index 530eecc55ea..bd28e85feb0 100644 --- a/jetty-start/src/main/resources/org/eclipse/jetty/start/usage.txt +++ b/jetty-start/src/main/resources/org/eclipse/jetty/start/usage.txt @@ -184,7 +184,7 @@ Advanced Commands: Advanced usage, If the file does not exist at the given location, download it from the given http URI. Notes: location is always relative to ${jetty.base}. - you might need to escape the slash "\|" to use + you might need to escape the pipe "\|" to use this on some environments. maven.repo.uri=[url] The url to use to download Maven dependencies. diff --git a/jetty-start/src/test/java/org/eclipse/jetty/start/MainTest.java b/jetty-start/src/test/java/org/eclipse/jetty/start/MainTest.java index 3c58faabcb0..8a041abec0d 100644 --- a/jetty-start/src/test/java/org/eclipse/jetty/start/MainTest.java +++ b/jetty-start/src/test/java/org/eclipse/jetty/start/MainTest.java @@ -56,7 +56,7 @@ public class MainTest // cmdLineArgs.add("jetty.http.port=9090"); Main main = new Main(); - StartArgs args = main.processCommandLine(cmdLineArgs.toArray(new String[cmdLineArgs.size()])); + StartArgs args = main.processCommandLine(cmdLineArgs.toArray(new String[0])); BaseHome baseHome = main.getBaseHome(); // System.err.println(args); @@ -92,7 +92,7 @@ public class MainTest cmdLineArgs.add("STOP.WAIT=300"); Main main = new Main(); - StartArgs args = main.processCommandLine(cmdLineArgs.toArray(new String[cmdLineArgs.size()])); + StartArgs args = main.processCommandLine(cmdLineArgs.toArray(new String[0])); // System.err.println(args); // assertEquals(0, args.getEnabledModules().size(), "--stop should not build module tree"); @@ -113,7 +113,7 @@ public class MainTest // cmdLineArgs.add("--debug"); Main main = new Main(); - StartArgs args = main.processCommandLine(cmdLineArgs.toArray(new String[cmdLineArgs.size()])); + StartArgs args = main.processCommandLine(cmdLineArgs.toArray(new String[0])); main.listConfig(args); } @@ -131,8 +131,8 @@ public class MainTest List cmdLineArgs = new ArrayList<>(); Path homePath = MavenTestingUtils.getTestResourceDir("dist-home").toPath().toRealPath(); - cmdLineArgs.add("jetty.home=" + homePath.toString()); - cmdLineArgs.add("user.dir=" + homePath.toString()); + cmdLineArgs.add("jetty.home=" + homePath); + cmdLineArgs.add("user.dir=" + homePath); // JVM args cmdLineArgs.add("--exec"); @@ -146,13 +146,8 @@ public class MainTest assertThat("Extra Jar exists: " + extraJar, Files.exists(extraJar), is(true)); assertThat("Extra Dir exists: " + extraDir, Files.exists(extraDir), is(true)); - StringBuilder lib = new StringBuilder(); - lib.append("--lib="); - lib.append(extraJar.toString()); - lib.append(File.pathSeparator); - lib.append(extraDir.toString()); - - cmdLineArgs.add(lib.toString()); + String lib = "--lib=" + extraJar + File.pathSeparator + extraDir; + cmdLineArgs.add(lib); // Arbitrary XMLs cmdLineArgs.add("config.xml"); @@ -161,7 +156,7 @@ public class MainTest Main main = new Main(); - StartArgs args = main.processCommandLine(cmdLineArgs.toArray(new String[cmdLineArgs.size()])); + StartArgs args = main.processCommandLine(cmdLineArgs.toArray(new String[0])); BaseHome baseHome = main.getBaseHome(); assertThat("jetty.home", baseHome.getHome(), is(homePath.toString())); @@ -176,8 +171,8 @@ public class MainTest List cmdLineArgs = new ArrayList<>(); Path homePath = MavenTestingUtils.getTestResourceDir("dist-home").toPath().toRealPath(); - cmdLineArgs.add("jetty.home=" + homePath.toString()); - cmdLineArgs.add("user.dir=" + homePath.toString()); + cmdLineArgs.add("jetty.home=" + homePath); + cmdLineArgs.add("user.dir=" + homePath); // JVM args cmdLineArgs.add("--exec"); @@ -187,7 +182,7 @@ public class MainTest Main main = new Main(); - StartArgs args = main.processCommandLine(cmdLineArgs.toArray(new String[cmdLineArgs.size()])); + StartArgs args = main.processCommandLine(cmdLineArgs.toArray(new String[0])); BaseHome baseHome = main.getBaseHome(); assertThat("jetty.home", baseHome.getHome(), is(homePath.toString())); @@ -216,7 +211,7 @@ public class MainTest Main main = new Main(); - StartArgs args = main.processCommandLine(cmdLineArgs.toArray(new String[cmdLineArgs.size()])); + StartArgs args = main.processCommandLine(cmdLineArgs.toArray(new String[0])); BaseHome baseHome = main.getBaseHome(); assertThat("jetty.home", baseHome.getHome(), is(homePath.toString())); @@ -231,7 +226,7 @@ public class MainTest Path distPath = MavenTestingUtils.getTestResourceDir("dist-home").toPath().toRealPath(); Path homePath = MavenTestingUtils.getTargetTestingPath().resolve("dist home with spaces"); IO.copy(distPath.toFile(), homePath.toFile()); - homePath.resolve("lib/a library.jar").toFile().createNewFile(); + Files.createFile(homePath.resolve("lib/a library.jar")); List cmdLineArgs = new ArrayList<>(); cmdLineArgs.add("user.dir=" + homePath); @@ -239,7 +234,7 @@ public class MainTest cmdLineArgs.add("--lib=lib/a library.jar"); Main main = new Main(); - StartArgs args = main.processCommandLine(cmdLineArgs.toArray(new String[cmdLineArgs.size()])); + StartArgs args = main.processCommandLine(cmdLineArgs.toArray(new String[0])); BaseHome baseHome = main.getBaseHome(); assertThat("jetty.home", baseHome.getHome(), is(homePath.toString())); diff --git a/tests/test-distribution/src/test/java/org/eclipse/jetty/tests/distribution/DistributionTests.java b/tests/test-distribution/src/test/java/org/eclipse/jetty/tests/distribution/DistributionTests.java index d89185bda5d..277e8ad31d0 100644 --- a/tests/test-distribution/src/test/java/org/eclipse/jetty/tests/distribution/DistributionTests.java +++ b/tests/test-distribution/src/test/java/org/eclipse/jetty/tests/distribution/DistributionTests.java @@ -35,6 +35,7 @@ import org.eclipse.jetty.unixsocket.client.HttpClientTransportOverUnixSockets; import org.eclipse.jetty.util.IO; import org.eclipse.jetty.util.StringUtil; import org.eclipse.jetty.util.ssl.SslContextFactory; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.DisabledOnJre; import org.junit.jupiter.api.condition.DisabledOnOs; @@ -406,4 +407,28 @@ public class DistributionTests extends AbstractDistributionTest } } } + + @Test + @Tag("external") + public void testDownload() throws Exception + { + Path jettyBase = Files.createTempDirectory("jetty_base"); + String jettyVersion = System.getProperty("jettyVersion"); + DistributionTester distribution = DistributionTester.Builder.newInstance() + .jettyVersion(jettyVersion) + .jettyBase(jettyBase) + .mavenLocalRepository(System.getProperty("mavenRepoPath")) + .build(); + + String outPath = "etc/maven-metadata.xml"; + String[] args1 = { + "--download=https://repo1.maven.org/maven2/org/eclipse/jetty/maven-metadata.xml|" + outPath + }; + try (DistributionTester.Run run = distribution.start(args1)) + { + assertTrue(run.awaitConsoleLogsFor("Base directory was modified", 15, TimeUnit.SECONDS)); + Path target = jettyBase.resolve(outPath); + assertTrue(Files.exists(target), "could not create " + target); + } + } }