Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit 3e31a66

Browse files
committed
[MJAVADOC-500] Add support for explicit toolchain reference
git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1815573 13f79535-47bb-0310-9956-ffa450edef68
1 parent 3fe1f62 commit 3e31a66

File tree

1 file changed

+61
-9
lines changed

1 file changed

+61
-9
lines changed

maven-javadoc-plugin/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java

Lines changed: 61 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
import java.io.InputStream;
3333
import java.io.OutputStream;
3434
import java.io.Writer;
35+
import java.lang.reflect.InvocationTargetException;
36+
import java.lang.reflect.Method;
3537
import java.net.MalformedURLException;
3638
import java.net.URI;
3739
import java.net.URISyntaxException;
@@ -1716,6 +1718,18 @@ public abstract class AbstractJavadocMojo
17161718
*/
17171719
@Parameter( defaultValue = "true", property = "maven.javadoc.applyJavadocSecurityFix" )
17181720
private boolean applyJavadocSecurityFix = true;
1721+
1722+
/**
1723+
* <p>
1724+
* Specify the requirements for this jdk toolchain.
1725+
* This overrules the toolchain selected by the maven-toolchain-plugin.
1726+
* </p>
1727+
* <strong>note:</strong> requires at least Maven 3.3.1
1728+
*
1729+
* @since 3.0.0
1730+
*/
1731+
@Parameter
1732+
private Map<String, String> jdkToolchain;
17191733

17201734
// ----------------------------------------------------------------------
17211735
// static
@@ -2674,20 +2688,58 @@ public Artifact resolveDependency( Dependency dependency )
26742688
}
26752689

26762690

2677-
/**
2678-
* TODO remove the part with ToolchainManager lookup once we depend on
2679-
* 2.0.9 (have it as prerequisite). Define as regular component field then.
2680-
*
2681-
* @return Toolchain instance
2682-
*/
2683-
private Toolchain getToolchain()
2691+
//TODO remove the part with ToolchainManager lookup once we depend on
2692+
//3.0.9 (have it as prerequisite). Define as regular component field then.
2693+
protected final Toolchain getToolchain()
26842694
{
26852695
Toolchain tc = null;
2686-
if ( toolchainManager != null )
2696+
2697+
if ( jdkToolchain != null )
2698+
{
2699+
// Maven 3.3.1 has plugin execution scoped Toolchain Support
2700+
try
2701+
{
2702+
Method getToolchainsMethod =
2703+
toolchainManager.getClass().getMethod( "getToolchains", MavenSession.class, String.class,
2704+
Map.class );
2705+
2706+
@SuppressWarnings( "unchecked" )
2707+
List<Toolchain> tcs =
2708+
(List<Toolchain>) getToolchainsMethod.invoke( toolchainManager, session, "jdk",
2709+
jdkToolchain );
2710+
2711+
if ( tcs != null && tcs.size() > 0 )
2712+
{
2713+
tc = tcs.get( 0 );
2714+
}
2715+
}
2716+
catch ( NoSuchMethodException e )
2717+
{
2718+
// ignore
2719+
}
2720+
catch ( SecurityException e )
2721+
{
2722+
// ignore
2723+
}
2724+
catch ( IllegalAccessException e )
2725+
{
2726+
// ignore
2727+
}
2728+
catch ( IllegalArgumentException e )
2729+
{
2730+
// ignore
2731+
}
2732+
catch ( InvocationTargetException e )
2733+
{
2734+
// ignore
2735+
}
2736+
}
2737+
2738+
if ( tc == null )
26872739
{
26882740
tc = toolchainManager.getToolchainFromBuildContext( "jdk", session );
26892741
}
2690-
2742+
26912743
return tc;
26922744
}
26932745

0 commit comments

Comments
 (0)