cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject [1/3] cxf git commit: [CXF-6268] Add toolchains support to codegen-plugin
Date Tue, 31 Mar 2015 18:35:45 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes c65a7b712 -> 7a2608611


[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.

Conflicts:
	maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractCodegenMoho.java


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/6398faf5
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/6398faf5
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/6398faf5

Branch: refs/heads/3.0.x-fixes
Commit: 6398faf5ac8f8325e425bd251cd7c75747e23648
Parents: c65a7b7
Author: kops <jeremie@dudie.fr>
Authored: Wed Feb 25 02:16:54 2015 +0100
Committer: Daniel Kulp <dkulp@apache.org>
Committed: Tue Mar 31 14:20:56 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/6398faf5/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 03c0a1c..c63385b 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
@@ -57,6 +57,8 @@ import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.project.ProjectUtils;
 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;
@@ -206,7 +208,7 @@ public abstract class AbstractCodegenMoho extends AbstractMojo {
     /**
      * Sets the Java executable to use when fork parameter is <code>true</code>.
      * 
-     * @parameter default-value="${java.home}/bin/java"
+     * @parameter
      * @since 2.4
      */
     private String javaExecutable;
@@ -227,6 +229,12 @@ public abstract class AbstractCodegenMoho extends AbstractMojo {
      */
     private ArtifactRepositoryFactory artifactRepositoryFactory;
     /**
+     * The toolchain manager.
+     */
+    @Component
+    private ToolchainManager toolchainManager;
+
+    /**
      * The Maven session.
      * 
      * @parameter expression="${session}"
@@ -838,17 +846,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;
     }
     


Mime
View raw message