You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ti...@apache.org on 2020/04/18 02:53:05 UTC
[maven-surefire] 01/01: finished the impl
This is an automated email from the ASF dual-hosted git repository.
tibordigana pushed a commit to branch pull/285
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git
commit 599f3f7a1e4b184414ec79994e3b4604ecfb52e9
Author: tibordigana <ti...@apache.org>
AuthorDate: Sat Apr 18 04:20:33 2020 +0200
finished the impl
---
.../plugin/surefire/AbstractSurefireMojo.java | 40 ++++++++++++++--------
1 file changed, 25 insertions(+), 15 deletions(-)
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
index ec79ed1..9058b82 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
@@ -85,7 +85,6 @@ import org.apache.maven.surefire.testset.TestListResolver;
import org.apache.maven.surefire.testset.TestRequest;
import org.apache.maven.surefire.testset.TestSetFailedException;
import org.apache.maven.surefire.util.DefaultScanResult;
-import org.apache.maven.surefire.util.ReflectionUtils;
import org.apache.maven.surefire.util.RunOrder;
import org.apache.maven.toolchain.DefaultToolchain;
import org.apache.maven.toolchain.Toolchain;
@@ -143,6 +142,8 @@ import static org.apache.maven.surefire.booter.SystemUtils.toJdkHomeFromJvmExec;
import static org.apache.maven.surefire.booter.SystemUtils.toJdkVersionFromReleaseFile;
import static org.apache.maven.surefire.suite.RunResult.failure;
import static org.apache.maven.surefire.suite.RunResult.noTestsRun;
+import static org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray;
+import static org.apache.maven.surefire.util.ReflectionUtils.tryGetMethod;
/**
* Abstract base class for running tests using Surefire.
@@ -947,38 +948,37 @@ public abstract class AbstractSurefireMojo
return consoleLogger;
}
-
//TODO remove the part with ToolchainManager lookup once we depend on
//3.0.9 (have it as prerequisite). Define as regular component field then.
- //This code duplicates AbstractCompilerMojo in maven-compiler-plugin
- protected final Toolchain getToolchain() throws MojoFailureException
+ private Toolchain getToolchain() throws MojoFailureException
{
Toolchain tc = null;
- if ( jdkToolchain != null )
+ if ( getJdkToolchain() != null )
{
- Method getToolchainsMethod = ReflectionUtils.tryGetMethod(
- getToolchainManager().getClass(), "getToolchains" );
+ Method getToolchainsMethod = tryGetMethod( ToolchainManager.class, "getToolchains",
+ MavenSession.class, String.class, Map.class );
if ( getToolchainsMethod != null )
{
- List<Toolchain> tcs =
- (List<Toolchain>) ReflectionUtils.invokeMethodWithArray( getToolchainManager(),
- getToolchainsMethod, getSession(), "jdk" );
- if ( tcs != null && !tcs.isEmpty() )
+ //noinspection unchecked
+ List<Toolchain> tcs = (List<Toolchain>) invokeMethodWithArray( getToolchainManager(),
+ getToolchainsMethod, getSession(), "jdk", getJdkToolchain() );
+ if ( tcs.isEmpty() )
{
- tc = tcs.get( 0 );
+ throw new MojoFailureException(
+ "Requested toolchain specification did not match any configured toolchain: "
+ + getJdkToolchain() );
}
else
{
- throw new MojoFailureException(
- "Requested toolchain specification did not match any configured toolchain: " + jdkToolchain );
+ tc = tcs.get( 0 );
}
}
}
if ( tc == null )
{
- tc = toolchainManager.getToolchainFromBuildContext( "jdk", getSession() );
+ tc = getToolchainManager().getToolchainFromBuildContext( "jdk", getSession() );
}
return tc;
@@ -3940,6 +3940,16 @@ public abstract class AbstractSurefireMojo
SurefireHelper.logDebugOrCliShowErrors( s, getConsoleLogger(), cli );
}
+ public Map<String, String> getJdkToolchain()
+ {
+ return jdkToolchain;
+ }
+
+ public void setJdkToolchain( Map<String, String> jdkToolchain )
+ {
+ this.jdkToolchain = jdkToolchain;
+ }
+
public String getTempDir()
{
return tempDir;