Skip to content

[MJAVADOC-821] Align toolchain discovery code with Maven Compiler Plugin #334

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ under the License.
<jetty.version>9.4.55.v20240627</jetty.version>
<version.plexus-utils>4.0.2</version.plexus-utils>
<!-- for ITs -->
<compilerPluginVersion>3.11.0</compilerPluginVersion>
<compilerPluginVersion>3.13.0</compilerPluginVersion>
<sourcePluginVersion>3.3.0</sourcePluginVersion>
<enforcerPluginVersion>3.4.1</enforcerPluginVersion>
<pluginPluginVersion>3.15.0</pluginPluginVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.Writer;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
Expand Down Expand Up @@ -2615,27 +2614,13 @@ public Artifact resolveDependency(Dependency dependency) throws MavenReportExcep
}
}

// TODO remove the part with ToolchainManager lookup once we depend on
// 3.0.9 (have it as prerequisite). Define as regular component field then.
protected final Toolchain getToolchain() {
Toolchain tc = null;

if (jdkToolchain != null) {
// Maven 3.3.1 has plugin execution scoped Toolchain Support
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);

if (tcs != null && tcs.size() > 0) {
tc = tcs.get(0);
}
} catch (SecurityException | ReflectiveOperationException e) {
// ignore
List<Toolchain> tcs = toolchainManager.getToolchains(session, "jdk", jdkToolchain);
if (tcs != null && !tcs.isEmpty()) {
tc = tcs.get(0);
}
}

Expand Down Expand Up @@ -4625,7 +4610,7 @@ private void addJavadocOptions(
addArgIf(arguments, quiet, "-quiet", SINCE_JAVADOC_1_5);
}

if (release != null) {
if (javadocRuntimeVersion.isAtLeast("9") && release != null) {
arguments.add("--release");
arguments.add(release);
} else {
Expand Down