You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2024/03/01 17:09:14 UTC
(maven-compiler-plugin) branch master updated: extract Maven 3.3.1 specific method call
This is an automated email from the ASF dual-hosted git repository.
hboutemy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-compiler-plugin.git
The following commit(s) were added to refs/heads/master by this push:
new d59ef49 extract Maven 3.3.1 specific method call
d59ef49 is described below
commit d59ef49ead31f7d85c24f98ca6747f9b3a1906a2
Author: Hervé Boutemy <hb...@apache.org>
AuthorDate: Fri Mar 1 18:09:06 2024 +0100
extract Maven 3.3.1 specific method call
---
.../plugin/compiler/AbstractCompilerMojo.java | 43 ++++++++++++----------
1 file changed, 24 insertions(+), 19 deletions(-)
diff --git a/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java b/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java
index 365a649..538b7ff 100644
--- a/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java
+++ b/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java
@@ -1500,26 +1500,11 @@ public abstract class AbstractCompilerMojo extends AbstractMojo {
Toolchain tc = null;
if (jdkToolchain != null) {
- // require Maven 3.3.1, that has plugin execution scoped Toolchain support MNG-5755
- try {
- // TODO use direct method invocation when prerequisite upgraded to Maven 3.3.1
- Method getToolchainsMethod = toolchainManager
- .getClass()
- .getMethod("getToolchains", MavenSession.class, String.class, Map.class);
-
- @SuppressWarnings("unchecked")
- List<Toolchain> tcs =
- (List<Toolchain>) getToolchainsMethod.invoke(toolchainManager, session, "jdk", jdkToolchain);
+ // require Maven 3.3.1, that has plugin execution scoped Toolchain support: MNG-5755
+ List<Toolchain> tcs = getToolchains();
- if (tcs != null && !tcs.isEmpty()) {
- tc = tcs.get(0);
- }
- } catch (NoSuchMethodException
- | SecurityException
- | IllegalAccessException
- | IllegalArgumentException
- | InvocationTargetException e) {
- // ignore
+ if (tcs != null && !tcs.isEmpty()) {
+ tc = tcs.get(0);
}
}
@@ -1530,6 +1515,26 @@ public abstract class AbstractCompilerMojo extends AbstractMojo {
return tc;
}
+ // TODO use direct method invocation when prerequisite upgraded to Maven 3.3.1
+ private List<Toolchain> getToolchains() {
+ try {
+ Method getToolchainsMethod =
+ toolchainManager.getClass().getMethod("getToolchains", MavenSession.class, String.class, Map.class);
+
+ @SuppressWarnings("unchecked")
+ List<Toolchain> tcs =
+ (List<Toolchain>) getToolchainsMethod.invoke(toolchainManager, session, "jdk", jdkToolchain);
+ return tcs;
+ } catch (NoSuchMethodException
+ | SecurityException
+ | IllegalAccessException
+ | IllegalArgumentException
+ | InvocationTargetException e) {
+ // ignore
+ }
+ return null;
+ }
+
private boolean isDigits(String string) {
for (int i = 0; i < string.length(); i++) {
if (!Character.isDigit(string.charAt(i))) {