xmvn/0003-Simple-implementation-of-toolchains.patch
Marian Koncek 1734725d14 Mimic maven-javadoc-plugin for -source and --release
Add simple implementation of toolchains
2022-09-05 13:57:18 +02:00

77 lines
3.1 KiB
Diff

From acb236f878b020722512b1ce0ba20329500083c2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fridrich=20=C5=A0trba?= <fridrich.strba@bluewin.ch>
Date: Sat, 7 May 2022 18:13:02 +0200
Subject: [PATCH 1/2] Simple implementation of toolchains
https://github.com/fedora-java/xmvn/issues/142
---
.../fedoraproject/xmvn/mojo/JavadocMojo.java | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/xmvn-mojo/src/main/java/org/fedoraproject/xmvn/mojo/JavadocMojo.java b/xmvn-mojo/src/main/java/org/fedoraproject/xmvn/mojo/JavadocMojo.java
index b2cd41fd..2b06e702 100644
--- a/xmvn-mojo/src/main/java/org/fedoraproject/xmvn/mojo/JavadocMojo.java
+++ b/xmvn-mojo/src/main/java/org/fedoraproject/xmvn/mojo/JavadocMojo.java
@@ -45,6 +45,8 @@
import org.apache.maven.project.DependencyResolutionResult;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.ProjectDependenciesResolver;
+import org.apache.maven.toolchain.Toolchain;
+import org.apache.maven.toolchain.ToolchainManager;
import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.util.StringUtils;
import org.eclipse.aether.util.filter.AndDependencyFilter;
@@ -69,6 +71,9 @@
@Component
private Configurator confugurator;
+ @Component
+ private ToolchainManager toolchainManager;
+
@Parameter( defaultValue = "${session}", readonly = true )
private MavenSession session;
@@ -161,8 +166,18 @@ private void populateClasspath( Collection<Path> reactorClassPath, Collection<Pa
public void execute()
throws MojoExecutionException, MojoFailureException
{
+ String javadocTool = null;
+ Toolchain tc = toolchainManager.getToolchainFromBuildContext( "jdk", session );
+ if ( tc != null )
+ {
+ javadocTool = tc.findTool( "javadoc" );
+ }
Path javadocExecutable;
- if ( System.getenv().containsKey( "JAVA_HOME" ) )
+ if ( javadocTool != null && !javadocTool.isEmpty() )
+ {
+ javadocExecutable = Paths.get( javadocTool );
+ }
+ else if ( System.getenv().containsKey( "JAVA_HOME" ) )
{
javadocExecutable = Paths.get( System.getenv( "JAVA_HOME" ) ) //
.resolve( "bin" ) //
From 110da12905adb020630c540e2a8937a71a0b2dc6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fridrich=20=C5=A0trba?= <fridrich.strba@bluewin.ch>
Date: Sat, 7 May 2022 21:29:24 +0200
Subject: [PATCH 2/2] Fix typo
---
.../src/main/java/org/fedoraproject/xmvn/mojo/JavadocMojo.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/xmvn-mojo/src/main/java/org/fedoraproject/xmvn/mojo/JavadocMojo.java b/xmvn-mojo/src/main/java/org/fedoraproject/xmvn/mojo/JavadocMojo.java
index 2b06e702..a83e8acf 100644
--- a/xmvn-mojo/src/main/java/org/fedoraproject/xmvn/mojo/JavadocMojo.java
+++ b/xmvn-mojo/src/main/java/org/fedoraproject/xmvn/mojo/JavadocMojo.java
@@ -69,7 +69,7 @@
private ProjectDependenciesResolver resolver;
@Component
- private Configurator confugurator;
+ private Configurator configurator;
@Component
private ToolchainManager toolchainManager;