You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2015/03/31 20:35:45 UTC

[1/3] cxf git commit: [CXF-6268] Add toolchains support to codegen-plugin

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 <je...@dudie.fr>
Authored: Wed Feb 25 02:16:54 2015 +0100
Committer: Daniel Kulp <dk...@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;
     }
     


[2/3] cxf git commit: [CXF-6268] Add integration test This closes #61

Posted by dk...@apache.org.
[CXF-6268] Add integration test
This closes #61

Conflicts:
	maven-plugins/codegen-plugin/pom.xml


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

Branch: refs/heads/3.0.x-fixes
Commit: 5f751d75008a6f7f389bfbfac3969b62dcd176f3
Parents: 6398faf
Author: kops <je...@dudie.fr>
Authored: Thu Mar 5 23:52:04 2015 +0100
Committer: Daniel Kulp <dk...@apache.org>
Committed: Tue Mar 31 14:21:46 2015 -0400

----------------------------------------------------------------------
 maven-plugins/codegen-plugin/pom.xml            | 53 +++++++++++
 maven-plugins/codegen-plugin/src/it/README.md   | 12 +++
 .../src/it/jdk6-cxf-with-toolchain/pom.xml      | 97 ++++++++++++++++++++
 .../src/main/wsdl/HelloWorld.wsdl               | 79 ++++++++++++++++
 .../codegen-plugin/src/it/settings.xml          | 45 +++++++++
 5 files changed, 286 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/5f751d75/maven-plugins/codegen-plugin/pom.xml
----------------------------------------------------------------------
diff --git a/maven-plugins/codegen-plugin/pom.xml b/maven-plugins/codegen-plugin/pom.xml
index 15de147..72b5115 100644
--- a/maven-plugins/codegen-plugin/pom.xml
+++ b/maven-plugins/codegen-plugin/pom.xml
@@ -136,6 +136,59 @@
             <optional>true</optional>
         </dependency>
     </dependencies>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-plugin-plugin</artifactId>
+                <configuration>
+                    <!-- see http://jira.codehaus.org/browse/MNG-5346 -->
+                    <skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
+                </configuration>
+                <executions>
+                    <execution>
+                        <id>mojo-descriptor</id>
+                        <goals>
+                            <goal>descriptor</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <artifactId>maven-install-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>install-to-integration-repo</id>
+                        <phase>pre-integration-test</phase>
+                        <goals>
+                            <goal>install</goal>
+                        </goals>
+                        <configuration>
+                            <localRepositoryPath>${project.build.directory}/it/repo</localRepositoryPath>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-invoker-plugin</artifactId>
+                <version>1.9</version>
+                <executions>
+                    <execution>
+                        <id>test-toolchains-integration</id>
+                        <phase>integration-test</phase>
+                        <goals>
+                            <goal>integration-test</goal>
+                        </goals>
+                        <configuration>
+                            <settingsFile>src/it/settings.xml</settingsFile>
+                            <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
     <profiles>
         <profile>
             <id>ibmjdk</id>

http://git-wip-us.apache.org/repos/asf/cxf/blob/5f751d75/maven-plugins/codegen-plugin/src/it/README.md
----------------------------------------------------------------------
diff --git a/maven-plugins/codegen-plugin/src/it/README.md b/maven-plugins/codegen-plugin/src/it/README.md
new file mode 100644
index 0000000..b202bec
--- /dev/null
+++ b/maven-plugins/codegen-plugin/src/it/README.md
@@ -0,0 +1,12 @@
+toolchain-integration-tests
+===========================
+
+jdk6-cxf-with-toolchain
+-----------------------
+
+This project contains sample maven module using `cxf-codegen-plugin` to generate java from WSDL file.
+
+- it enforces usage of JDK 1.7 or higher to run the `mvn` command
+- it configures `maven-toolchains-plugins` to target JDK 6
+- cxf `fork` parameter if set to true to enable toolchain detection
+- if the toolchain wasn't correctly used by the cxf-codegen-plugin`, the the build should fail during the _compile_ phase

http://git-wip-us.apache.org/repos/asf/cxf/blob/5f751d75/maven-plugins/codegen-plugin/src/it/jdk6-cxf-with-toolchain/pom.xml
----------------------------------------------------------------------
diff --git a/maven-plugins/codegen-plugin/src/it/jdk6-cxf-with-toolchain/pom.xml b/maven-plugins/codegen-plugin/src/it/jdk6-cxf-with-toolchain/pom.xml
new file mode 100644
index 0000000..1dd949f
--- /dev/null
+++ b/maven-plugins/codegen-plugin/src/it/jdk6-cxf-with-toolchain/pom.xml
@@ -0,0 +1,97 @@
+<?xml version="1.0"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.cxf.it</groupId>
+  <artifactId>jdk6-cxf-with-toolchain</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <packaging>jar</packaging>
+  <properties>
+    <project.build.sourceEncoding>utf-8</project.build.sourceEncoding>
+  </properties>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-enforcer-plugin</artifactId>
+        <version>1.4</version>
+        <executions>
+          <execution>
+            <id>enforce-jdk7-of-higher</id>
+            <phase>verify</phase>
+            <goals>
+              <goal>enforce</goal>
+            </goals>
+            <configuration>
+              <rules>
+                <requireJavaVersion>
+                  <version>[1.7,)</version>
+                </requireJavaVersion>
+              </rules>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-toolchains-plugin</artifactId>
+        <version>1.1</version>
+        <configuration>
+          <toolchains>
+            <jdk>
+              <version>6</version>
+            </jdk>
+          </toolchains>
+        </configuration>
+        <executions>
+          <execution>
+            <goals>
+              <goal>toolchain</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.cxf</groupId>
+        <artifactId>cxf-codegen-plugin</artifactId>
+        <version>@project.version@</version>
+        <executions>
+          <execution>
+            <id>wsdl2java</id>
+            <phase>generate-sources</phase>
+            <goals>
+              <goal>wsdl2java</goal>
+            </goals>
+            <configuration>
+              <fork>true</fork>
+              <wsdlOptions>
+                <wsdlOption>
+                  <wsdl>src/main/wsdl/HelloWorld.wsdl</wsdl>
+                </wsdlOption>
+              </wsdlOptions>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>build-helper-maven-plugin</artifactId>
+        <version>1.9.1</version>
+        <executions>
+          <execution>
+            <id>add-wsdl-source</id>
+            <phase>process-sources</phase>
+            <goals>
+              <goal>add-source</goal>
+            </goals>
+            <configuration>
+              <sources>
+                <source>${project.build.directory}/generated-sources/cxf</source>
+              </sources>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>

http://git-wip-us.apache.org/repos/asf/cxf/blob/5f751d75/maven-plugins/codegen-plugin/src/it/jdk6-cxf-with-toolchain/src/main/wsdl/HelloWorld.wsdl
----------------------------------------------------------------------
diff --git a/maven-plugins/codegen-plugin/src/it/jdk6-cxf-with-toolchain/src/main/wsdl/HelloWorld.wsdl b/maven-plugins/codegen-plugin/src/it/jdk6-cxf-with-toolchain/src/main/wsdl/HelloWorld.wsdl
new file mode 100644
index 0000000..21dd8de
--- /dev/null
+++ b/maven-plugins/codegen-plugin/src/it/jdk6-cxf-with-toolchain/src/main/wsdl/HelloWorld.wsdl
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+##    licensed to the Apache Software Foundation (ASF) under one
+##    or more contributor license agreements. See the NOTICE file
+##    distributed with this work for additional information
+##    regarding copyright ownership. The ASF licenses this file
+##    to you under the Apache License, Version 2.0 (the
+##    "License"); you may not use this file except in compliance
+##    with the License. You may obtain a copy of the License at
+##    
+##    http://www.apache.org/licenses/LICENSE-2.0
+##    
+##    Unless required by applicable law or agreed to in writing,
+##    software distributed under the License is distributed on an
+##    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+##    KIND, either express or implied. See the License for the
+##    specific language governing permissions and limitations
+##    under the License.
+-->
+<wsdl:definitions name="HelloWorld" targetNamespace="http://www.apache.org/contract/HelloWorld"
+    xmlns="http://schemas.xmlsoap.org/wsdl/"
+    xmlns:tns="http://www.apache.org/contract/HelloWorld"
+    xmlns:x1="http://www.apache.org/schema/HelloWorld"
+    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+    xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+    <wsdl:types>
+        <schema targetNamespace="http://www.apache.org/schema/HelloWorld"
+            xmlns="http://www.w3.org/2001/XMLSchema"
+            xmlns:tns="http://www.apache.org/schema/HelloWorld"
+            elementFormDefault="qualified">
+            <element name="sayHi">
+                <complexType>
+                    <sequence>
+                        <element name="requestType" type="string"/>
+                    </sequence>
+                </complexType>
+            </element>
+            <element name="sayHiResponse">
+                <complexType>
+                    <sequence>
+                        <element name="responseType" type="string"/>
+                    </sequence>
+                </complexType>
+            </element>
+        </schema>
+    </wsdl:types>
+    <wsdl:message name="sayHiRequest">
+        <wsdl:part element="x1:sayHi" name="in"/>
+    </wsdl:message>
+    <wsdl:message name="sayHiResponse">
+        <wsdl:part element="x1:sayHiResponse" name="out"/>
+    </wsdl:message>
+    <wsdl:portType name="HelloWorldPortType">
+        <wsdl:operation name="sayHi">
+            <wsdl:input message="tns:sayHiRequest" name="sayHiRequest"/>
+            <wsdl:output message="tns:sayHiResponse" name="sayHiResponse"/>
+        </wsdl:operation>
+    </wsdl:portType>
+    <wsdl:binding name="HelloWorldBinding" type="tns:HelloWorldPortType">
+        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+        <wsdl:operation name="sayHi">
+            <soap:operation soapAction="" style="document"/>
+            <wsdl:input name="sayHiRequest">
+                <soap:body use="literal"/>
+            </wsdl:input>
+            <wsdl:output name="sayHiResponse">
+                <soap:body use="literal"/>
+            </wsdl:output>
+        </wsdl:operation>
+    </wsdl:binding>
+    <wsdl:service name="HelloWorldService">
+        <wsdl:port name="HelloWorldPort" binding="tns:HelloWorldBinding">
+            <!-- Actual soap:address value is dynamically generated after deployment -->
+            <soap:address location="http://dummy.value"/>
+        </wsdl:port>
+    </wsdl:service>
+</wsdl:definitions>
+

http://git-wip-us.apache.org/repos/asf/cxf/blob/5f751d75/maven-plugins/codegen-plugin/src/it/settings.xml
----------------------------------------------------------------------
diff --git a/maven-plugins/codegen-plugin/src/it/settings.xml b/maven-plugins/codegen-plugin/src/it/settings.xml
new file mode 100644
index 0000000..d29dc39
--- /dev/null
+++ b/maven-plugins/codegen-plugin/src/it/settings.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0"?>
+<settings>
+  <profiles>
+    <profile>
+      <id>it-repo</id>
+      <activation>
+        <activeByDefault>true</activeByDefault>
+      </activation>
+      <repositories>
+        <repository>
+          <id>local.central</id>
+          <url>@localRepositoryUrl@</url>
+          <releases>
+            <enabled>true</enabled>
+          </releases>
+          <snapshots>
+            <enabled>true</enabled>
+          </snapshots>
+        </repository>
+      </repositories>
+      <pluginRepositories>
+        <pluginRepository>
+          <id>local.central</id>
+          <url>@localRepositoryUrl@</url>
+          <releases>
+            <enabled>true</enabled>
+          </releases>
+          <snapshots>
+            <enabled>true</enabled>
+          </snapshots>
+        </pluginRepository>
+        <pluginRepository>
+          <id>local.it</id>
+          <url>file://@project.build.directory@/it/repo</url>
+          <releases>
+            <enabled>true</enabled>
+          </releases>
+          <snapshots>
+            <enabled>true</enabled>
+          </snapshots>
+        </pluginRepository>
+      </pluginRepositories>
+    </profile>
+  </profiles>
+</settings>


[3/3] cxf git commit: [CXF-6268] Updates for 3.0.x branch

Posted by dk...@apache.org.
[CXF-6268] Updates for 3.0.x branch


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

Branch: refs/heads/3.0.x-fixes
Commit: 7a2608611dd2a1702ea161601fd609ff7bab491c
Parents: 5f751d7
Author: Daniel Kulp <dk...@apache.org>
Authored: Tue Mar 31 14:35:15 2015 -0400
Committer: Daniel Kulp <dk...@apache.org>
Committed: Tue Mar 31 14:35:15 2015 -0400

----------------------------------------------------------------------
 maven-plugins/codegen-plugin/pom.xml            | 21 +++++---------------
 .../cxf/maven_plugin/AbstractCodegenMoho.java   |  2 +-
 parent/pom.xml                                  |  6 ++++++
 3 files changed, 12 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/7a260861/maven-plugins/codegen-plugin/pom.xml
----------------------------------------------------------------------
diff --git a/maven-plugins/codegen-plugin/pom.xml b/maven-plugins/codegen-plugin/pom.xml
index 72b5115..d18f04f 100644
--- a/maven-plugins/codegen-plugin/pom.xml
+++ b/maven-plugins/codegen-plugin/pom.xml
@@ -57,6 +57,11 @@
         </dependency>
         <dependency>
             <groupId>org.apache.maven</groupId>
+            <artifactId>maven-toolchain</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.maven</groupId>
             <artifactId>maven-project</artifactId>
             <scope>provided</scope>
         </dependency>
@@ -139,22 +144,6 @@
     <build>
         <plugins>
             <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-plugin-plugin</artifactId>
-                <configuration>
-                    <!-- see http://jira.codehaus.org/browse/MNG-5346 -->
-                    <skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
-                </configuration>
-                <executions>
-                    <execution>
-                        <id>mojo-descriptor</id>
-                        <goals>
-                            <goal>descriptor</goal>
-                        </goals>
-                    </execution>
-                </executions>
-            </plugin>
-            <plugin>
                 <artifactId>maven-install-plugin</artifactId>
                 <executions>
                     <execution>

http://git-wip-us.apache.org/repos/asf/cxf/blob/7a260861/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 c63385b..68cc9d7 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
@@ -230,8 +230,8 @@ public abstract class AbstractCodegenMoho extends AbstractMojo {
     private ArtifactRepositoryFactory artifactRepositoryFactory;
     /**
      * The toolchain manager.
+     * @component
      */
-    @Component
     private ToolchainManager toolchainManager;
 
     /**

http://git-wip-us.apache.org/repos/asf/cxf/blob/7a260861/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index 8ea31f5..540bbad 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -757,6 +757,12 @@
             </dependency>
             <dependency>
                 <groupId>org.apache.maven</groupId>
+                <artifactId>maven-toolchain</artifactId>
+                <version>${cxf.maven.core.version}</version>
+                <scope>provided</scope>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.maven</groupId>
                 <artifactId>maven-project</artifactId>
                 <version>${cxf.maven.core.version}</version>
                 <scope>provided</scope>