diff --git a/documentation/jetty-documentation/src/main/asciidoc/programming-guide/maven/jetty-maven-plugin.adoc b/documentation/jetty-documentation/src/main/asciidoc/programming-guide/maven/jetty-maven-plugin.adoc index 90fa86d804ef..c9e9ebc55425 100644 --- a/documentation/jetty-documentation/src/main/asciidoc/programming-guide/maven/jetty-maven-plugin.adoc +++ b/documentation/jetty-documentation/src/main/asciidoc/programming-guide/maven/jetty-maven-plugin.adoc @@ -189,7 +189,7 @@ Optional. Map of key/value pairs to pass as environment to the forked JVM. jvmArgs:: Optional. -A string representing arbitrary arguments to pass to the forked JVM. +A space separated string representing arbitrary arguments to pass to the forked JVM. forkWebXml:: Optional. Defaults to `target/fork-web.xml`. @@ -218,9 +218,13 @@ jettyHome:: Optional. The location of an existing unpacked jetty distribution. If one does not exist, a fresh jetty distribution will be downloaded from maven and installed to the `target` directory. +jettyOptions:: +Optional. +A space separated string representing extra arguments to the synthesized jetty command line. +Values for these arguments can be found in the section titled "Options" in the output of `java -jar $jetty.home/start.jar --help`. jvmArgs:: Optional. -A string representing arguments that should be passed to the jvm of the child process running the distro. +A space separated string representing arguments that should be passed to the jvm of the child process running the distro. modules:: Optional. An array of names of additional jetty modules that the jetty child process will activate. diff --git a/jetty-maven-plugin/src/it/jetty-start-distro-mojo-it/jetty-simple-webapp/pom.xml b/jetty-maven-plugin/src/it/jetty-start-distro-mojo-it/jetty-simple-webapp/pom.xml index 2be511dcb4ab..4c57f13200ca 100644 --- a/jetty-maven-plugin/src/it/jetty-start-distro-mojo-it/jetty-simple-webapp/pom.xml +++ b/jetty-maven-plugin/src/it/jetty-start-distro-mojo-it/jetty-simple-webapp/pom.xml @@ -103,6 +103,7 @@ 0 jsp,jstl,testmod + --debug diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/AbstractWebAppMojo.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/AbstractWebAppMojo.java index 989455b11f73..2cb2dc308c2a 100644 --- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/AbstractWebAppMojo.java +++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/AbstractWebAppMojo.java @@ -290,7 +290,6 @@ public enum DeploymentMode @Parameter protected int stopPort; - /** * Key to provide when stopping jetty on executing java -DSTOP.KEY=<stopKey> * -DSTOP.PORT=<stopPort> -jar start.jar --stop @@ -319,6 +318,13 @@ public enum DeploymentMode */ @Parameter protected String[] modules; + + /** + * Extra options that can be passed to the jetty command line + */ + @Parameter (property = "jetty.options") + protected String jettyOptions; + //End of EXTERNAL only parameters //Start of parameters only valid for FORK @@ -511,6 +517,7 @@ protected JettyHomeForker newJettyHomeForker() jetty.setStopPort(stopPort); jetty.setEnv(env); jetty.setJvmArgs(jvmArgs); + jetty.setJettyOptions(jettyOptions); jetty.setJettyXmlFiles(jettyXmls); jetty.setJettyProperties(jettyProperties); jetty.setModules(modules); diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyHomeForker.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyHomeForker.java index 6c02db96cbf2..7c42689468a0 100644 --- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyHomeForker.java +++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyHomeForker.java @@ -25,10 +25,10 @@ import java.nio.file.FileVisitResult; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import java.nio.file.SimpleFileVisitor; import java.nio.file.attribute.BasicFileAttributes; import java.util.ArrayList; +import java.util.Arrays; import java.util.EnumSet; import java.util.List; import java.util.Map; @@ -74,6 +74,11 @@ public class JettyHomeForker extends AbstractForker */ protected String[] modules; + /* + * Optional jetty commands + */ + protected String jettyOptions; + protected List libExtJarFiles; protected Path modulesPath; protected Path etcPath; @@ -82,6 +87,16 @@ public class JettyHomeForker extends AbstractForker protected Path mavenLibPath; protected String version; + public void setJettyOptions(String jettyOptions) + { + this.jettyOptions = jettyOptions; + } + + public String getJettyOptions() + { + return jettyOptions; + } + public List getLibExtJarFiles() { return libExtJarFiles; @@ -167,24 +182,16 @@ protected ProcessBuilder createCommand() { List cmd = new ArrayList<>(); cmd.add("java"); - cmd.add("-jar"); - cmd.add(new File(jettyHome, "start.jar").getAbsolutePath()); - - cmd.add("-DSTOP.PORT=" + stopPort); - if (stopKey != null) - cmd.add("-DSTOP.KEY=" + stopKey); //add any args to the jvm - if (jvmArgs != null) + if (StringUtil.isNotBlank(jvmArgs)) { - String[] args = jvmArgs.split(" "); - for (String a : args) - { - if (!StringUtil.isBlank(a)) - cmd.add(a.trim()); - } + Arrays.stream(jvmArgs.split(" ")).filter(a -> StringUtil.isNotBlank(a)).forEach((a) -> cmd.add(a.trim())); } + cmd.add("-jar"); + cmd.add(new File(jettyHome, "start.jar").getAbsolutePath()); + if (systemProperties != null) { for (Map.Entry e : systemProperties.entrySet()) @@ -193,6 +200,10 @@ protected ProcessBuilder createCommand() } } + cmd.add("-DSTOP.PORT=" + stopPort); + if (stopKey != null) + cmd.add("-DSTOP.KEY=" + stopKey); + //set up enabled jetty modules StringBuilder tmp = new StringBuilder(); tmp.append("--module="); @@ -210,6 +221,12 @@ protected ProcessBuilder createCommand() tmp.append(",ext"); tmp.append(",maven"); cmd.add(tmp.toString()); + + //put any other jetty options onto the command line + if (StringUtil.isNotBlank(jettyOptions)) + { + Arrays.stream(jettyOptions.split(" ")).filter(a -> StringUtil.isNotBlank(a)).forEach((a) -> cmd.add(a.trim())); + } //put any jetty properties onto the command line if (jettyProperties != null)