|
32 | 32 | import java.io.InputStream;
|
33 | 33 | import java.io.OutputStream;
|
34 | 34 | import java.io.Writer;
|
| 35 | +import java.lang.reflect.InvocationTargetException; |
| 36 | +import java.lang.reflect.Method; |
35 | 37 | import java.net.MalformedURLException;
|
36 | 38 | import java.net.URI;
|
37 | 39 | import java.net.URISyntaxException;
|
@@ -1716,6 +1718,18 @@ public abstract class AbstractJavadocMojo
|
1716 | 1718 | */
|
1717 | 1719 | @Parameter( defaultValue = "true", property = "maven.javadoc.applyJavadocSecurityFix" )
|
1718 | 1720 | 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; |
1719 | 1733 |
|
1720 | 1734 | // ----------------------------------------------------------------------
|
1721 | 1735 | // static
|
@@ -2674,20 +2688,58 @@ public Artifact resolveDependency( Dependency dependency )
|
2674 | 2688 | }
|
2675 | 2689 |
|
2676 | 2690 |
|
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() |
2684 | 2694 | {
|
2685 | 2695 | 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 ) |
2687 | 2739 | {
|
2688 | 2740 | tc = toolchainManager.getToolchainFromBuildContext( "jdk", session );
|
2689 | 2741 | }
|
2690 |
| - |
| 2742 | + |
2691 | 2743 | return tc;
|
2692 | 2744 | }
|
2693 | 2745 |
|
|
0 commit comments