align used algorithm to detect java bin to use (#3025)
add javaPath for JettyRunDistro mojo to force a java executable to use Signed-off-by: olivier lamy <oliver.lamy@gmail.com>
This commit is contained in:
parent
66d6ea6799
commit
8500e806ec
|
@ -624,6 +624,9 @@ Only relevant if `waitForChild` is `false`.
|
||||||
forkWebXml::
|
forkWebXml::
|
||||||
Default is `target/fork-web.xml`.
|
Default is `target/fork-web.xml`.
|
||||||
This is the name of the file into which jetty generates the effective web.xml for use by the child process.
|
This is the name of the file into which jetty generates the effective web.xml for use by the child process.
|
||||||
|
javaPath::
|
||||||
|
Default will be your `${java.home}/bin/java`
|
||||||
|
This the java executable used to start the child process
|
||||||
|
|
||||||
The following `jetty:run` parameters are NOT applicable:
|
The following `jetty:run` parameters are NOT applicable:
|
||||||
|
|
||||||
|
@ -715,6 +718,9 @@ maxChildCheckInterval::
|
||||||
Default value 100.
|
Default value 100.
|
||||||
This is the interval in milliseconds between checks to see if the child started correctly.
|
This is the interval in milliseconds between checks to see if the child started correctly.
|
||||||
Only applicable if `waitForChild` is `false`.
|
Only applicable if `waitForChild` is `false`.
|
||||||
|
javaPath::
|
||||||
|
Default will be your `${java.home}/bin/java`
|
||||||
|
This the java executable used to start the child process
|
||||||
|
|
||||||
____
|
____
|
||||||
[NOTE]
|
[NOTE]
|
||||||
|
|
|
@ -93,6 +93,7 @@
|
||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
<jettyBase>${basedir}/src/base</jettyBase>
|
<jettyBase>${basedir}/src/base</jettyBase>
|
||||||
|
<javaPath>${java.home}/bin/java</javaPath>
|
||||||
<jettyProperties>
|
<jettyProperties>
|
||||||
<jettyProperty>jetty.server.dumpAfterStart=true</jettyProperty>
|
<jettyProperty>jetty.server.dumpAfterStart=true</jettyProperty>
|
||||||
<jettyProperty>jetty.port.file=${jetty.port.file}</jettyProperty>
|
<jettyProperty>jetty.port.file=${jetty.port.file}</jettyProperty>
|
||||||
|
|
|
@ -199,6 +199,8 @@ public class JettyRunDistro extends JettyRunMojo
|
||||||
|
|
||||||
private Path tokenFile;
|
private Path tokenFile;
|
||||||
|
|
||||||
|
@Parameter(property = "jetty.javaPath")
|
||||||
|
private String javaPath;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.jetty.maven.plugin.JettyRunMojo#execute()
|
* @see org.eclipse.jetty.maven.plugin.JettyRunMojo#execute()
|
||||||
|
@ -492,7 +494,14 @@ public class JettyRunDistro extends JettyRunMojo
|
||||||
public ProcessBuilder configureCommand()
|
public ProcessBuilder configureCommand()
|
||||||
{
|
{
|
||||||
List<String> cmd = new ArrayList<>();
|
List<String> cmd = new ArrayList<>();
|
||||||
cmd.add("java");
|
if(StringUtil.isNotBlank( javaPath ))
|
||||||
|
{
|
||||||
|
cmd.add( javaPath );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cmd.add( getJavaBin() );
|
||||||
|
}
|
||||||
cmd.add("-jar");
|
cmd.add("-jar");
|
||||||
cmd.add(new File(jettyHome, "start.jar").getAbsolutePath());
|
cmd.add(new File(jettyHome, "start.jar").getAbsolutePath());
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,7 @@ import org.apache.maven.plugins.annotations.Parameter;
|
||||||
import org.apache.maven.plugins.annotations.ResolutionScope;
|
import org.apache.maven.plugins.annotations.ResolutionScope;
|
||||||
import org.eclipse.jetty.annotations.AnnotationConfiguration;
|
import org.eclipse.jetty.annotations.AnnotationConfiguration;
|
||||||
import org.eclipse.jetty.server.Server;
|
import org.eclipse.jetty.server.Server;
|
||||||
|
import org.eclipse.jetty.util.StringUtil;
|
||||||
import org.eclipse.jetty.util.resource.Resource;
|
import org.eclipse.jetty.util.resource.Resource;
|
||||||
import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
||||||
|
|
||||||
|
@ -152,6 +153,8 @@ public class JettyRunForkedMojo extends JettyRunMojo
|
||||||
*/
|
*/
|
||||||
private boolean hasSlf4jDeps;
|
private boolean hasSlf4jDeps;
|
||||||
|
|
||||||
|
@Parameter(property = "jetty.javaPath")
|
||||||
|
private String javaPath;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ShutdownThread
|
* ShutdownThread
|
||||||
|
@ -271,7 +274,14 @@ public class JettyRunForkedMojo extends JettyRunMojo
|
||||||
tpool.stop();
|
tpool.stop();
|
||||||
|
|
||||||
List<String> cmd = new ArrayList<>();
|
List<String> cmd = new ArrayList<>();
|
||||||
cmd.add(getJavaBin());
|
if( StringUtil.isNotBlank( javaPath ))
|
||||||
|
{
|
||||||
|
cmd.add( javaPath );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cmd.add( getJavaBin() );
|
||||||
|
}
|
||||||
|
|
||||||
if (jvmArgs != null)
|
if (jvmArgs != null)
|
||||||
{
|
{
|
||||||
|
@ -307,7 +317,6 @@ public class JettyRunForkedMojo extends JettyRunMojo
|
||||||
cmd.add("--props");
|
cmd.add("--props");
|
||||||
cmd.add(props.getAbsolutePath());
|
cmd.add(props.getAbsolutePath());
|
||||||
|
|
||||||
String token = createToken();
|
|
||||||
Path tokenFile = target.toPath().resolve(createToken()+".txt");
|
Path tokenFile = target.toPath().resolve(createToken()+".txt");
|
||||||
cmd.add("--token");
|
cmd.add("--token");
|
||||||
cmd.add(tokenFile.toAbsolutePath().toString());
|
cmd.add(tokenFile.toAbsolutePath().toString());
|
||||||
|
@ -510,45 +519,6 @@ public class JettyRunForkedMojo extends JettyRunMojo
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private String getJavaBin()
|
|
||||||
{
|
|
||||||
String javaexes[] = new String[]
|
|
||||||
{ "java", "java.exe" };
|
|
||||||
|
|
||||||
File javaHomeDir = new File(System.getProperty("java.home"));
|
|
||||||
for (String javaexe : javaexes)
|
|
||||||
{
|
|
||||||
File javabin = new File(javaHomeDir,fileSeparators("bin/" + javaexe));
|
|
||||||
if (javabin.exists() && javabin.isFile())
|
|
||||||
{
|
|
||||||
return javabin.getAbsolutePath();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return "java";
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String fileSeparators(String path)
|
|
||||||
{
|
|
||||||
StringBuilder ret = new StringBuilder();
|
|
||||||
for (char c : path.toCharArray())
|
|
||||||
{
|
|
||||||
if ((c == '/') || (c == '\\'))
|
|
||||||
{
|
|
||||||
ret.append(File.separatorChar);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ret.append(c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String pathSeparators(String path)
|
public static String pathSeparators(String path)
|
||||||
{
|
{
|
||||||
StringBuilder ret = new StringBuilder();
|
StringBuilder ret = new StringBuilder();
|
||||||
|
|
|
@ -738,4 +738,44 @@ public class JettyRunMojo extends AbstractJettyMojo
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected String getJavaBin()
|
||||||
|
{
|
||||||
|
String javaexes[] = new String[]
|
||||||
|
{ "java", "java.exe" };
|
||||||
|
|
||||||
|
File javaHomeDir = new File(System.getProperty("java.home"));
|
||||||
|
for (String javaexe : javaexes)
|
||||||
|
{
|
||||||
|
File javabin = new File(javaHomeDir,fileSeparators("bin/" + javaexe));
|
||||||
|
if (javabin.exists() && javabin.isFile())
|
||||||
|
{
|
||||||
|
return javabin.getAbsolutePath();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return "java";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String fileSeparators(String path)
|
||||||
|
{
|
||||||
|
StringBuilder ret = new StringBuilder();
|
||||||
|
for (char c : path.toCharArray())
|
||||||
|
{
|
||||||
|
if ((c == '/') || (c == '\\'))
|
||||||
|
{
|
||||||
|
ret.append(File.separatorChar);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ret.append(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue