You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by co...@apache.org on 2017/06/15 16:40:58 UTC
[08/15] cxf git commit: Merge pull request #2 from
exabrial/Add-toolchain-support
Merge pull request #2 from exabrial/Add-toolchain-support
Add toolchain support to CXF to support builds on TT infra
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/6caf7910
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/6caf7910
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/6caf7910
Branch: refs/heads/2.6.x-fixes
Commit: 6caf7910f741317a6eabd1b7ccee0d9345f654d3
Parents: 2fef247
Author: Tod Bookless <tb...@tomitribe.com>
Authored: Thu Jun 1 09:33:30 2017 -0700
Committer: Jonathan S. Fisher <jf...@tomitribe.com>
Committed: Wed Jun 7 15:10:34 2017 -0500
----------------------------------------------------------------------
maven-plugins/codegen-plugin/pom.xml | 5 +
.../cxf/maven_plugin/AbstractCodegenMoho.java | 142 +++++++++++--------
parent/pom.xml | 7 +-
pom.xml | 36 ++++-
services/wsn/wsn-api/pom.xml | 1 +
systests/databinding/pom.xml | 1 -
systests/jaxrs/pom.xml | 3 +-
7 files changed, 126 insertions(+), 69 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf/blob/6caf7910/maven-plugins/codegen-plugin/pom.xml
----------------------------------------------------------------------
diff --git a/maven-plugins/codegen-plugin/pom.xml b/maven-plugins/codegen-plugin/pom.xml
index 346fa6c..62d7ba2 100644
--- a/maven-plugins/codegen-plugin/pom.xml
+++ b/maven-plugins/codegen-plugin/pom.xml
@@ -55,6 +55,11 @@
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
+ <artifactId>maven-toolchain</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
<scope>provided</scope>
</dependency>
http://git-wip-us.apache.org/repos/asf/cxf/blob/6caf7910/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 584d32a..4da783b 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.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;
@@ -66,7 +68,7 @@ import org.codehaus.plexus.util.cli.StreamConsumer;
import org.sonatype.plexus.build.incremental.BuildContext;
public abstract class AbstractCodegenMoho extends AbstractMojo {
-
+
/**
* JVM/System property name holding the hostname of the http proxy.
*/
@@ -82,28 +84,28 @@ public abstract class AbstractCodegenMoho extends AbstractMojo {
* should not use the proxy configuration.
*/
private static final String HTTP_NON_PROXY_HOSTS = "http.nonProxyHosts";
-
+
/**
* JVM/System property name holding the username of the http proxy.
*/
private static final String HTTP_PROXY_USER = "http.proxyUser";
-
+
/**
* JVM/System property name holding the password of the http proxy.
*/
private static final String HTTP_PROXY_PASSWORD = "http.proxyPassword";
-
+
/**
* @parameter expression="${project.build.outputDirectory}"
* @required
*/
protected String classesDirectory;
-
+
/**
* By default all maven dependencies of type "wsdl" are added to the effective wsdlOptions. Setting this
* parameter to true disables this functionality
- *
+ *
* @parameter expression="${cxf.disableDependencyScan}" default-value="false"
*/
protected boolean disableDependencyScan;
@@ -118,7 +120,7 @@ public abstract class AbstractCodegenMoho extends AbstractMojo {
/**
* Allows running the JavaToWs in a separate process. Valid values are "false", "always", and "once" The
* value of "true" is equal to "once"
- *
+ *
* @parameter default-value="false"
* @since 2.4
*/
@@ -126,20 +128,20 @@ public abstract class AbstractCodegenMoho extends AbstractMojo {
/**
* A list of wsdl files to include. Can contain ant-style wildcards and double wildcards. Defaults to
* *.wsdl
- *
+ *
* @parameter
*/
protected String includes[];
/**
* Directory in which the "DONE" markers are saved that
- *
+ *
* @parameter expression="${cxf.markerDirectory}"
* default-value="${project.build.directory}/cxf-codegen-plugin-markers"
*/
protected File markerDirectory;
/**
* The plugin dependencies, needed for the fork mode.
- *
+ *
* @parameter expression="${plugin.artifacts}"
* @required
* @readonly
@@ -153,13 +155,13 @@ public abstract class AbstractCodegenMoho extends AbstractMojo {
/**
* Use the compile classpath rather than the test classpath for execution useful if the test dependencies
* clash with those of wsdl2java
- *
+ *
* @parameter expression="${cxf.useCompileClasspath}" default-value="false"
*/
protected boolean useCompileClasspath;
/**
* A list of wsdl files to exclude. Can contain ant-style wildcards and double wildcards.
- *
+ *
* @parameter
*/
protected String excludes[];
@@ -167,26 +169,26 @@ public abstract class AbstractCodegenMoho extends AbstractMojo {
* @parameter expression="${cxf.testWsdlRoot}" default-value="${basedir}/src/test/resources/wsdl"
*/
protected File testWsdlRoot;
-
+
/**
* @parameter expression="${cxf.wsdlRoot}" default-value="${basedir}/src/main/resources/wsdl"
*/
protected File wsdlRoot;
-
+
/** @component */
protected BuildContext buildContext;
-
-
+
+
/**
* Sets the JVM arguments (i.e. <code>-Xms128m -Xmx128m</code>) if fork is set to <code>true</code>.
- *
+ *
* @parameter expression="${cxf.codegen.jvmArgs}"
* @since 2.4
*/
private String additionalJvmArgs;
/**
* The local repository taken from Maven's runtime. Typically $HOME/.m2/repository.
- *
+ *
* @parameter expression="${localRepository}"
* @readonly
* @required
@@ -194,7 +196,7 @@ public abstract class AbstractCodegenMoho extends AbstractMojo {
private ArtifactRepository localRepository;
/**
* Artifact factory, needed to create artifacts.
- *
+ *
* @component
* @readonly
* @required
@@ -203,14 +205,15 @@ 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
+ * @readonly
* @since 2.4
*/
private String javaExecutable;
/**
* The remote repositories used as specified in your POM.
- *
+ *
* @parameter expression="${project.repositories}"
* @readonly
* @required
@@ -218,15 +221,23 @@ public abstract class AbstractCodegenMoho extends AbstractMojo {
private List<Repository> repositories;
/**
* Artifact repository factory component.
- *
+ *
* @component
* @readonly
* @required
*/
private ArtifactRepositoryFactory artifactRepositoryFactory;
/**
- * The Maven session.
+ * The toolchain manager.
*
+ * @component
+ * @readonly
+ */
+ private ToolchainManager toolchainManager;
+
+ /**
+ * The Maven session.
+ *
* @parameter expression="${session}"
* @readonly
* @required
@@ -244,7 +255,7 @@ public abstract class AbstractCodegenMoho extends AbstractMojo {
* @required
*/
private ArtifactResolver artifactResolver;
-
+
public AbstractCodegenMoho() {
super();
@@ -276,7 +287,7 @@ public abstract class AbstractCodegenMoho extends AbstractMojo {
"*.wsdl"
};
}
-
+
markerDirectory.mkdirs();
String originalProxyHost = SystemPropertyAction.getProperty(HTTP_PROXY_HOST);
@@ -284,7 +295,7 @@ public abstract class AbstractCodegenMoho extends AbstractMojo {
String originalNonProxyHosts = SystemPropertyAction.getProperty(HTTP_NON_PROXY_HOSTS);
String originalProxyUser = SystemPropertyAction.getProperty(HTTP_PROXY_USER);
String originalProxyPassword = SystemPropertyAction.getProperty(HTTP_PROXY_PASSWORD);
-
+
configureProxyServerSettings();
List<GenericWsdlOption> effectiveWsdlOptions = createWsdlOptionsFromScansAndExplicitWsdlOptions();
@@ -306,7 +317,7 @@ public abstract class AbstractCodegenMoho extends AbstractMojo {
} else {
for (GenericWsdlOption o : effectiveWsdlOptions) {
bus = generate(o, bus, cp);
-
+
File dirs[] = o.getDeleteDirs();
if (dirs != null) {
for (int idx = 0; idx < dirs.length; ++idx) {
@@ -365,13 +376,13 @@ public abstract class AbstractCodegenMoho extends AbstractMojo {
System.getProperties().remove(HTTP_PROXY_PASSWORD);
}
Proxy proxy = mavenSession.getSettings().getActiveProxy();
- if (proxy != null && !StringUtils.isEmpty(proxy.getUsername())
+ if (proxy != null && !StringUtils.isEmpty(proxy.getUsername())
&& !StringUtils.isEmpty(proxy.getPassword())) {
Authenticator.setDefault(null);
}
}
- protected abstract Bus generate(GenericWsdlOption o,
+ protected abstract Bus generate(GenericWsdlOption o,
Bus bus, Set<URI> cp) throws MojoExecutionException;
protected void addPluginArtifact(Set<URI> artifactsPath) {
@@ -422,7 +433,7 @@ public abstract class AbstractCodegenMoho extends AbstractMojo {
if (proxy.getNonProxyHosts() != null) {
System.setProperty(HTTP_NON_PROXY_HOSTS, proxy.getNonProxyHosts());
}
- if (!StringUtils.isEmpty(proxy.getUsername())
+ if (!StringUtils.isEmpty(proxy.getUsername())
&& !StringUtils.isEmpty(proxy.getPassword())) {
final String authUser = proxy.getUsername();
final String authPassword = proxy.getPassword();
@@ -439,13 +450,13 @@ public abstract class AbstractCodegenMoho extends AbstractMojo {
}
}
-
- protected abstract List<GenericWsdlOption> createWsdlOptionsFromScansAndExplicitWsdlOptions()
+
+ protected abstract List<GenericWsdlOption> createWsdlOptionsFromScansAndExplicitWsdlOptions()
throws MojoExecutionException;
/**
* Recursively delete the given directory
- *
+ *
* @param f
* @return
*/
@@ -464,12 +475,12 @@ public abstract class AbstractCodegenMoho extends AbstractMojo {
return true;
}
-
+
protected abstract String getMarkerSuffix();
-
+
protected List<String> generateCommandLine(GenericWsdlOption wsdlOption)
throws MojoExecutionException {
-
+
File outputDirFile = wsdlOption.getOutputDir();
outputDirFile.mkdirs();
URI basedir = project.getBasedir().toURI();
@@ -477,7 +488,7 @@ public abstract class AbstractCodegenMoho extends AbstractMojo {
return wsdlOption.generateCommandLine(outputDirFile, basedir, wsdlURI,
getLog().isDebugEnabled());
}
-
+
protected void forkOnce(Set<URI> classPath, List<GenericWsdlOption> effectiveWsdlOptions)
throws MojoExecutionException {
List<GenericWsdlOption> toDo = new LinkedList<GenericWsdlOption>();
@@ -535,9 +546,9 @@ public abstract class AbstractCodegenMoho extends AbstractMojo {
}
}
}
-
+
protected abstract Class<?> getForkClass();
-
+
protected File getDoneFile(URI basedir, URI wsdlURI, String mojo) {
String doneFileName = wsdlURI.toString();
@@ -557,9 +568,9 @@ public abstract class AbstractCodegenMoho extends AbstractMojo {
protected abstract File getGeneratedSourceRoot();
protected abstract File getGeneratedTestRoot();
-
- protected void runForked(Set<URI> classPath,
- String mainClassName,
+
+ protected void runForked(Set<URI> classPath,
+ String mainClassName,
String[] args) throws MojoExecutionException {
getLog().info("Running code generation in fork mode...");
getLog().debug("Running code generation in fork mode with args " + Arrays.asList(args));
@@ -603,7 +614,7 @@ public abstract class AbstractCodegenMoho extends AbstractMojo {
jar.createArchive();
cmd.createArg().setValue("-jar");
-
+
String tmpFilePath = file.getAbsolutePath();
if (tmpFilePath.contains(" ")) {
//ensure the path is in double quotation marks if the path contain space
@@ -636,7 +647,7 @@ public abstract class AbstractCodegenMoho extends AbstractMojo {
getLog().debug(e);
throw new MojoExecutionException(e.getMessage(), e);
}
-
+
String cmdLine = CommandLineUtils.toString(cmd.getCommandline());
@@ -659,10 +670,10 @@ public abstract class AbstractCodegenMoho extends AbstractMojo {
}
}
-
+
/**
* Determine if code should be generated from the given wsdl
- *
+ *
* @param wsdlOption
* @param doneFile
* @param wsdlURI
@@ -673,7 +684,7 @@ public abstract class AbstractCodegenMoho extends AbstractMojo {
protected void createMarkerFile(GenericWsdlOption wsdlOption, File doneFile, URI wsdlURI) throws IOException {
doneFile.createNewFile();
}
-
+
private String[] createForkOnceArgs(List<List<String>> wargs) throws MojoExecutionException {
try {
File f = FileUtils.createTempFile("cxf-w2j", "args");
@@ -693,11 +704,11 @@ public abstract class AbstractCodegenMoho extends AbstractMojo {
throw new MojoExecutionException("Could not create argument file", ex);
}
}
-
+
/**
* Try to find a file matching the wsdl path (either absolutely, relatively to the current dir or to
* the project base dir)
- *
+ *
* @return wsdl file
*/
public File getWsdlFile(GenericWsdlOption option, File baseDir) {
@@ -721,18 +732,18 @@ public abstract class AbstractCodegenMoho extends AbstractMojo {
}
return file;
}
-
+
public URI getWsdlURI(GenericWsdlOption option, URI baseURI) throws MojoExecutionException {
String wsdlLocation = option.getUri();
if (wsdlLocation == null) {
throw new MojoExecutionException("No wsdl available for base URI " + baseURI);
}
File wsdlFile = new File(wsdlLocation);
- return wsdlFile.exists() ? wsdlFile.toURI()
+ return wsdlFile.exists() ? wsdlFile.toURI()
: baseURI.resolve(URIParserUtil.escapeChars(wsdlLocation));
}
- protected void downloadRemoteWsdls(List<GenericWsdlOption> effectiveWsdlOptions)
+ protected void downloadRemoteWsdls(List<GenericWsdlOption> effectiveWsdlOptions)
throws MojoExecutionException {
for (GenericWsdlOption wsdlOption : effectiveWsdlOptions) {
@@ -742,7 +753,7 @@ public abstract class AbstractCodegenMoho extends AbstractMojo {
}
Artifact wsdlArtifact = artifactFactory.createArtifactWithClassifier(wsdlA.getGroupId(),
wsdlA.getArtifactId(),
- wsdlA.getVersion(),
+ wsdlA.getVersion(),
wsdlA.getType(),
wsdlA.getClassifier());
wsdlArtifact = resolveRemoteWsdlArtifact(wsdlArtifact);
@@ -761,20 +772,31 @@ 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.");
+ + "' doesn't exist or is not a file."
+ + "Verify the <javaExecutable/> parameter or toolchain configuration.");
}
-
+ getLog().info("The java executable is " + javaExe.getAbsolutePath());
return javaExe;
}
-
+
private Artifact resolveRemoteWsdlArtifact(Artifact artifact) throws MojoExecutionException {
Artifact remoteWsdl = resolveDependentWsdl(artifact);
if (remoteWsdl == null) {
@@ -817,7 +839,7 @@ public abstract class AbstractCodegenMoho extends AbstractMojo {
private Artifact resolveArbitraryWsdl(Artifact artifact) {
try {
@SuppressWarnings("rawtypes")
- List remoteRepos = ProjectUtils.buildArtifactRepositories(repositories,
+ List remoteRepos = ProjectUtils.buildArtifactRepositories(repositories,
artifactRepositoryFactory,
mavenSession.getContainer());
artifactResolver.resolve(artifact, remoteRepos, localRepository);
http://git-wip-us.apache.org/repos/asf/cxf/blob/6caf7910/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index 44d7a1a..02b05d2 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -123,7 +123,7 @@
<cxf.jettison.version>1.3.4</cxf.jettison.version>
<cxf.jetty.osgi.version>[7.2,8.2)</cxf.jetty.osgi.version>
<cxf.jetty.version>7.5.4.v20111024</cxf.jetty.version>
- <cxf.jibx.version>1.2.4.5</cxf.jibx.version>
+ <cxf.jibx.version>1.2.6</cxf.jibx.version>
<cxf.joda.time.version>2.2</cxf.joda.time.version>
<cxf.junit.version>4.11</cxf.junit.version>
<cxf.maven.core.version>2.2.1</cxf.maven.core.version>
@@ -622,6 +622,11 @@
<version>${cxf.maven.core.version}</version>
</dependency>
<dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-toolchain</artifactId>
+ <version>${cxf.maven.core.version}</version>
+ </dependency>
+ <dependency>
<groupId>httpunit</groupId>
<artifactId>httpunit</artifactId>
<version>1.6.2</version>
http://git-wip-us.apache.org/repos/asf/cxf/blob/6caf7910/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index cd5e55f..262a629 100644
--- a/pom.xml
+++ b/pom.xml
@@ -231,8 +231,6 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
- <source>${cxf.jdk.version}</source>
- <target>${cxf.jdk.version}</target>
<maxmem>256M</maxmem>
<fork>${cxf.compiler.fork}</fork>
</configuration>
@@ -468,6 +466,16 @@
<pluginManagement>
<plugins>
<plugin>
+ <groupId>org.jibx</groupId>
+ <artifactId>maven-jibx-plugin</artifactId>
+ <version>1.3.1</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-toolchains-plugin</artifactId>
+ <version>1.1</version>
+ </plugin>
+ <plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin </artifactId>
<version>1.0-alpha-2</version>
@@ -520,7 +528,6 @@
<version>2.9.1</version>
<configuration>
<attach>true</attach>
- <source>1.6</source>
<quiet>true</quiet>
<bottom>Apache CXF</bottom>
<javadocVersion>1.5</javadocVersion>
@@ -545,8 +552,6 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
- <source>1.6</source>
- <target>1.6</target>
<maxmem>256M</maxmem>
<fork>${cxf.compiler.fork}</fork>
<encoding>UTF-8</encoding>
@@ -691,6 +696,27 @@
</plugin>
</plugins>
</pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-toolchains-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>toolchain</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <toolchains>
+ <jdk>
+ <version>${cxf.jdk.version}</version>
+ <vendor>oracle</vendor>
+ </jdk>
+ </toolchains>
+ </configuration>
+ </plugin>
+ </plugins>
</build>
<reporting>
http://git-wip-us.apache.org/repos/asf/cxf/blob/6caf7910/services/wsn/wsn-api/pom.xml
----------------------------------------------------------------------
diff --git a/services/wsn/wsn-api/pom.xml b/services/wsn/wsn-api/pom.xml
index 598ed35..e565ffd 100644
--- a/services/wsn/wsn-api/pom.xml
+++ b/services/wsn/wsn-api/pom.xml
@@ -58,6 +58,7 @@
<phase>generate-sources</phase>
<configuration>
<sourceRoot>${basedir}/target/jaxws</sourceRoot>
+ <fork>${cxf.codegenplugin.forkmode}</fork>
<defaultOptions>
<markGenerated>true</markGenerated>
<faultSerialVersionUID>1</faultSerialVersionUID>
http://git-wip-us.apache.org/repos/asf/cxf/blob/6caf7910/systests/databinding/pom.xml
----------------------------------------------------------------------
diff --git a/systests/databinding/pom.xml b/systests/databinding/pom.xml
index e769b0b..5ebc901 100644
--- a/systests/databinding/pom.xml
+++ b/systests/databinding/pom.xml
@@ -165,7 +165,6 @@
<plugin>
<groupId>org.jibx</groupId>
<artifactId>maven-jibx-plugin</artifactId>
- <version>${cxf.jibx.version}</version>
<configuration>
<directory>target/generated/src/test/java/jibx_bindings</directory>
<!--load>true</load-->
http://git-wip-us.apache.org/repos/asf/cxf/blob/6caf7910/systests/jaxrs/pom.xml
----------------------------------------------------------------------
diff --git a/systests/jaxrs/pom.xml b/systests/jaxrs/pom.xml
index ccad91e..a85479d 100644
--- a/systests/jaxrs/pom.xml
+++ b/systests/jaxrs/pom.xml
@@ -353,8 +353,7 @@
</plugin>
<plugin>
<groupId>org.jibx</groupId>
- <artifactId>jibx-maven-plugin</artifactId>
- <version>${cxf.jibx.version}</version>
+ <artifactId>maven-jibx-plugin</artifactId>
<executions>
<execution>
<id>generate-java-code-from-schema</id>