|
2 | 2 |
|
3 | 3 | import org.apache.maven.artifact.DependencyResolutionRequiredException;
|
4 | 4 | import org.apache.maven.plugin.AbstractMojo;
|
5 |
| -import org.apache.maven.plugin.MojoExecutionException; |
6 | 5 | import org.apache.maven.plugin.MojoFailureException;
|
7 | 6 | import org.apache.maven.project.MavenProject;
|
8 |
| -import org.codehaus.plexus.util.cli.CommandLineException; |
9 |
| -import org.codehaus.plexus.util.cli.CommandLineTimeOutException; |
10 |
| -import org.codehaus.plexus.util.cli.CommandLineUtils; |
11 |
| -import org.codehaus.plexus.util.cli.Commandline; |
12 |
| -import org.codehaus.plexus.util.cli.StreamConsumer; |
| 7 | +import org.codehaus.plexus.util.cli.*; |
13 | 8 |
|
14 |
| -import static org.scalatest.tools.maven.MojoUtils.*; |
15 |
| - |
16 |
| -import java.io.*; |
17 |
| -import java.util.Arrays; |
18 |
| -import java.util.Collections; |
19 |
| -import java.util.List; |
20 |
| -import java.util.ArrayList; |
21 |
| -import java.util.Map; |
22 |
| - |
23 |
| -import static java.util.Collections.singletonList; |
24 |
| - |
25 |
| -import java.net.MalformedURLException; |
26 |
| -import java.net.URLClassLoader; |
27 |
| -import java.net.URL; |
| 9 | +import java.io.File; |
28 | 10 | import java.lang.reflect.InvocationTargetException;
|
29 | 11 | import java.lang.reflect.Method;
|
| 12 | +import java.net.MalformedURLException; |
| 13 | +import java.net.URL; |
| 14 | +import java.net.URLClassLoader; |
| 15 | +import java.util.*; |
| 16 | + |
| 17 | +import static java.util.Collections.singletonList; |
| 18 | +import static org.apache.commons.lang3.StringUtils.isEmpty; |
| 19 | +import static org.scalatest.tools.maven.MojoUtils.*; |
30 | 20 |
|
31 | 21 | /**
|
32 | 22 | * Provides the base for all mojos.
|
@@ -270,7 +260,7 @@ private boolean runForkingOnce(String[] args) throws MojoFailureException {
|
270 | 260 |
|
271 | 261 | final Commandline cli = new Commandline();
|
272 | 262 | cli.setWorkingDirectory(project.getBasedir());
|
273 |
| - cli.setExecutable("java"); |
| 263 | + cli.setExecutable(getJvm()); |
274 | 264 |
|
275 | 265 | // Set up environment
|
276 | 266 | if (environmentVariables != null) {
|
@@ -329,6 +319,19 @@ public void consumeLine(final String line) {
|
329 | 319 | }
|
330 | 320 | }
|
331 | 321 |
|
| 322 | + private String getJvm() |
| 323 | + { |
| 324 | + // use the same JVM as the one used to run Maven (the "java.home" one) |
| 325 | + String jvmToUse = System.getProperty( "java.home" ) + File.separator + "bin" + File.separator + "java"; |
| 326 | + |
| 327 | + if (isEmpty(jvmToUse)) { |
| 328 | + jvmToUse = "java"; |
| 329 | + } |
| 330 | + |
| 331 | + getLog().debug( "Using JVM: " + jvmToUse ); |
| 332 | + return jvmToUse; |
| 333 | + } |
| 334 | + |
332 | 335 | private String buildClassPathEnvironment() {
|
333 | 336 | StringBuffer buf = new StringBuffer();
|
334 | 337 | boolean first = true;
|
|
0 commit comments