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::
|
||||
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.
|
||||
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:
|
||||
|
||||
|
@ -715,6 +718,9 @@ maxChildCheckInterval::
|
|||
Default value 100.
|
||||
This is the interval in milliseconds between checks to see if the child started correctly.
|
||||
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]
|
||||
|
|
|
@ -93,6 +93,7 @@
|
|||
</goals>
|
||||
<configuration>
|
||||
<jettyBase>${basedir}/src/base</jettyBase>
|
||||
<javaPath>${java.home}/bin/java</javaPath>
|
||||
<jettyProperties>
|
||||
<jettyProperty>jetty.server.dumpAfterStart=true</jettyProperty>
|
||||
<jettyProperty>jetty.port.file=${jetty.port.file}</jettyProperty>
|
||||
|
|
|
@ -198,8 +198,10 @@ public class JettyRunDistro extends JettyRunMojo
|
|||
private Random random;
|
||||
|
||||
private Path tokenFile;
|
||||
|
||||
|
||||
|
||||
@Parameter(property = "jetty.javaPath")
|
||||
private String javaPath;
|
||||
|
||||
/**
|
||||
* @see org.eclipse.jetty.maven.plugin.JettyRunMojo#execute()
|
||||
*/
|
||||
|
@ -492,7 +494,14 @@ public class JettyRunDistro extends JettyRunMojo
|
|||
public ProcessBuilder configureCommand()
|
||||
{
|
||||
List<String> cmd = new ArrayList<>();
|
||||
cmd.add("java");
|
||||
if(StringUtil.isNotBlank( javaPath ))
|
||||
{
|
||||
cmd.add( javaPath );
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd.add( getJavaBin() );
|
||||
}
|
||||
cmd.add("-jar");
|
||||
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.eclipse.jetty.annotations.AnnotationConfiguration;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
||||
|
||||
|
@ -151,7 +152,9 @@ public class JettyRunForkedMojo extends JettyRunMojo
|
|||
* pom has an explicit dependency on it.
|
||||
*/
|
||||
private boolean hasSlf4jDeps;
|
||||
|
||||
|
||||
@Parameter(property = "jetty.javaPath")
|
||||
private String javaPath;
|
||||
|
||||
/**
|
||||
* ShutdownThread
|
||||
|
@ -271,7 +274,14 @@ public class JettyRunForkedMojo extends JettyRunMojo
|
|||
tpool.stop();
|
||||
|
||||
List<String> cmd = new ArrayList<>();
|
||||
cmd.add(getJavaBin());
|
||||
if( StringUtil.isNotBlank( javaPath ))
|
||||
{
|
||||
cmd.add( javaPath );
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd.add( getJavaBin() );
|
||||
}
|
||||
|
||||
if (jvmArgs != null)
|
||||
{
|
||||
|
@ -307,7 +317,6 @@ public class JettyRunForkedMojo extends JettyRunMojo
|
|||
cmd.add("--props");
|
||||
cmd.add(props.getAbsolutePath());
|
||||
|
||||
String token = createToken();
|
||||
Path tokenFile = target.toPath().resolve(createToken()+".txt");
|
||||
cmd.add("--token");
|
||||
cmd.add(tokenFile.toAbsolutePath().toString());
|
||||
|
@ -508,46 +517,7 @@ public class JettyRunForkedMojo extends JettyRunMojo
|
|||
return classPath.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @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)
|
||||
{
|
||||
|
|
|
@ -738,4 +738,44 @@ public class JettyRunMojo extends AbstractJettyMojo
|
|||
|
||||
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