Repository: cxf
Updated Branches:
refs/heads/master 3d1b17589 -> 41812468c
[CXF-6268] Add toolchains support to codegen-plugin
Default behavior is modified and the javaExecutable path is resolved in the
following order:
1. a 'javaExecutable' property explicitely set is used as is ;
2. if the the toolchain manager provides a 'jdk' then it is used ;
3. fallback to default behavior: ${java.home}/bin/java.
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/d7945c77
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/d7945c77
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/d7945c77
Branch: refs/heads/master
Commit: d7945c77da4f438cd7f52b1a512e65c62409d0ef
Parents: 3d1b175
Author: kops <[email protected]>
Authored: Wed Feb 25 02:16:54 2015 +0100
Committer: Daniel Kulp <[email protected]>
Committed: Tue Mar 31 13:29:11 2015 -0400
----------------------------------------------------------------------
.../cxf/maven_plugin/AbstractCodegenMoho.java | 27 +++++++++++++++++---
1 file changed, 23 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf/blob/d7945c77/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractCodegenMoho.java
----------------------------------------------------------------------
diff --git
a/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractCodegenMoho.java
b/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractCodegenMoho.java
index f2e9535..8c854e2 100644
---
a/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractCodegenMoho.java
+++
b/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractCodegenMoho.java
@@ -55,6 +55,8 @@ import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.apache.maven.repository.RepositorySystem;
import org.apache.maven.settings.Proxy;
+import org.apache.maven.toolchain.Toolchain;
+import org.apache.maven.toolchain.ToolchainManager;
import org.codehaus.plexus.archiver.jar.JarArchiver;
import org.codehaus.plexus.archiver.jar.Manifest;
import org.codehaus.plexus.archiver.jar.Manifest.Attribute;
@@ -173,10 +175,16 @@ public abstract class AbstractCodegenMoho extends
AbstractMojo {
/**
* Sets the Java executable to use when fork parameter is
<code>true</code>.
*/
- @Parameter(defaultValue = "${java.home}/bin/java")
+ @Parameter
private String javaExecutable;
/**
+ * The toolchain manager.
+ */
+ @Component
+ private ToolchainManager toolchainManager;
+
+ /**
* The Maven session.
*/
@Parameter(readonly = true, required = true, property = "session")
@@ -779,17 +787,28 @@ public abstract class AbstractCodegenMoho extends
AbstractMojo {
}
private File getJavaExecutable() throws IOException {
+ if (javaExecutable != null) {
+ getLog().debug("Plugin configuration set the 'javaExecutable'
parameter to " + javaExecutable);
+ } else {
+ Toolchain tc =
toolchainManager.getToolchainFromBuildContext("jdk", mavenSession);
+ if (tc != null) {
+ getLog().info("Using toolchain " + tc + " to find the java
executable");
+ javaExecutable = tc.findTool("java");
+ } else {
+ getLog().debug("The java executable is set to default value");
+ javaExecutable = SystemUtils.getJavaHome() + File.separator +
"bin" + File.separator + "java";
+ }
+ }
String exe = SystemUtils.IS_OS_WINDOWS &&
!javaExecutable.endsWith(".exe") ? ".exe" : "";
File javaExe = new File(javaExecutable + exe);
-
if (!javaExe.isFile()) {
throw new IOException(
"The java executable '"
+ javaExe
+ "' doesn't exist or is not a file."
- + "Verify the <javaExecutable/>
parameter.");
+ + "Verify the <javaExecutable/>
parameter or toolchain configuration.");
}
-
+ getLog().info("The java executable is " + javaExe.getAbsolutePath());
return javaExe;
}