Issue #6153 Swap order of jetty maven plugin jvmArgs for EXTERNAL (#6155)

* Issue #6153 Swap order of jetty maven plugin jvmArgs for EXTERNAL

Signed-off-by: Jan Bartel <janb@webtide.com>
This commit is contained in:
Jan Bartel 2021-04-29 11:18:38 +10:00 committed by GitHub
parent 973dfcf4f7
commit f05fc25900
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 46 additions and 17 deletions

View File

@ -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.

View File

@ -103,6 +103,7 @@
<jetty.http.port>0</jetty.http.port>
</jettyProperties>
<modules>jsp,jstl,testmod</modules>
<jettyOptions>--debug</jettyOptions>
</configuration>
</execution>
</executions>

View File

@ -290,7 +290,6 @@ public abstract class AbstractWebAppMojo extends AbstractMojo
@Parameter
protected int stopPort;
/**
* Key to provide when stopping jetty on executing java -DSTOP.KEY=&lt;stopKey&gt;
* -DSTOP.PORT=&lt;stopPort&gt; -jar start.jar --stop
@ -319,6 +318,13 @@ public abstract class AbstractWebAppMojo extends AbstractMojo
*/
@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 @@ public abstract class AbstractWebAppMojo extends AbstractMojo
jetty.setStopPort(stopPort);
jetty.setEnv(env);
jetty.setJvmArgs(jvmArgs);
jetty.setJettyOptions(jettyOptions);
jetty.setJettyXmlFiles(jettyXmls);
jetty.setJettyProperties(jettyProperties);
jetty.setModules(modules);

View File

@ -25,10 +25,10 @@ import java.nio.file.FileVisitOption;
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<File> 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<File> getLibExtJarFiles()
{
return libExtJarFiles;
@ -167,24 +182,16 @@ public class JettyHomeForker extends AbstractForker
{
List<String> 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<String, String> e : systemProperties.entrySet())
@ -193,6 +200,10 @@ public class JettyHomeForker extends AbstractForker
}
}
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 @@ public class JettyHomeForker extends AbstractForker
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)