michael-o commented on code in PR #737: URL: https://github.com/apache/maven-surefire/pull/737#discussion_r1623497355
########## maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java: ########## @@ -935,31 +932,17 @@ protected final PluginConsoleLogger getConsoleLogger() { return consoleLogger; } - private static <T extends ToolchainManager> Toolchain getToolchainMaven33x( - Class<T> toolchainManagerType, T toolchainManager, MavenSession session, Map<String, String> toolchainArgs) - throws MojoFailureException { - Method getToolchainsMethod = - tryGetMethod(toolchainManagerType, "getToolchains", MavenSession.class, String.class, Map.class); - if (getToolchainsMethod != null) { - //noinspection unchecked - List<Toolchain> tcs = - invokeMethodWithArray(toolchainManager, getToolchainsMethod, session, "jdk", toolchainArgs); - if (tcs.isEmpty()) { - throw new MojoFailureException( - "Requested toolchain specification did not match any configured toolchain: " + toolchainArgs); - } - return tcs.get(0); - } - return null; - } - - // TODO remove the part with ToolchainManager lookup once we depend on - // 3.0.9 (have it as prerequisite). Define as regular component field then. private Toolchain getToolchain() throws MojoFailureException { Toolchain tc = null; if (getJdkToolchain() != null) { - tc = getToolchainMaven33x(ToolchainManager.class, getToolchainManager(), getSession(), getJdkToolchain()); + List<Toolchain> tcs = getToolchainManager().getToolchains(getSession(), "jdk", getJdkToolchain()); + if (tcs.isEmpty()) { + throw new MojoFailureException( + "Requested toolchain specification did not match any configured toolchain: " + + getJdkToolchain()); + } + tc = tcs.get(0); Review Comment: True, but simply hides code complexity. It is has no further use. I wouldn't necessarily delete it. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org