You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by ff...@apache.org on 2018/03/28 06:43:44 UTC
[cxf] branch master updated: [CXF-7683]Codegen fails when using
JDK10 with maven and cxf-plugin
This is an automated email from the ASF dual-hosted git repository.
ffang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cxf.git
The following commit(s) were added to refs/heads/master by this push:
new 89ad818 [CXF-7683]Codegen fails when using JDK10 with maven and cxf-plugin
89ad818 is described below
commit 89ad818be1bad8f550b3030a7dc50625f24f5431
Author: Freeman Fang <fr...@gmail.com>
AuthorDate: Wed Mar 28 14:41:55 2018 +0800
[CXF-7683]Codegen fails when using JDK10 with maven and cxf-plugin
---
.../java/org/apache/cxf/common/util/Compiler.java | 3 ++-
.../main/java/org/apache/cxf/helpers/DOMUtils.java | 2 +-
.../main/java/org/apache/cxf/helpers/JavaUtils.java | 20 +++++++++++++++++++-
maven-plugins/codegen-plugin/pom.xml | 4 ++--
.../apache/cxf/maven_plugin/AbstractCodegenMoho.java | 4 +++-
.../org/apache/cxf/maven_plugin/Java2WSMojo.java | 3 ++-
.../cxf/maven_plugin/wadlto/WADL2JavaMojo.java | 3 ++-
parent/pom.xml | 4 ++--
.../apache/cxf/tools/common/ProcessorTestBase.java | 3 ++-
9 files changed, 35 insertions(+), 11 deletions(-)
diff --git a/core/src/main/java/org/apache/cxf/common/util/Compiler.java b/core/src/main/java/org/apache/cxf/common/util/Compiler.java
index 02711d5..a7acdf7 100644
--- a/core/src/main/java/org/apache/cxf/common/util/Compiler.java
+++ b/core/src/main/java/org/apache/cxf/common/util/Compiler.java
@@ -38,6 +38,7 @@ import javax.tools.StandardJavaFileManager;
import javax.tools.ToolProvider;
import org.apache.cxf.helpers.FileUtils;
+import org.apache.cxf.helpers.JavaUtils;
public class Compiler {
private long maxMemory = Runtime.getRuntime().maxMemory();
@@ -177,7 +178,7 @@ public class Compiler {
//fix for CXF-2081, set maximum heap of this VM to javac.
list.add("-J-Xmx" + maxMemory);
- if (System.getProperty("java.version").startsWith("9")) {
+ if (JavaUtils.isJava9Compatible()) {
list.add("--add-modules");
list.add("java.activation,java.xml.ws.annotation,java.corba,java.transaction,java.xml.bind,java.xml.ws");
}
diff --git a/core/src/main/java/org/apache/cxf/helpers/DOMUtils.java b/core/src/main/java/org/apache/cxf/helpers/DOMUtils.java
index 5b79367..908cb2c 100644
--- a/core/src/main/java/org/apache/cxf/helpers/DOMUtils.java
+++ b/core/src/main/java/org/apache/cxf/helpers/DOMUtils.java
@@ -67,7 +67,7 @@ public final class DOMUtils {
static {
- if (System.getProperty("java.version").startsWith("9")) {
+ if (JavaUtils.isJava9Compatible()) {
try {
Method[] methods = DOMUtils.class.getClassLoader().
diff --git a/core/src/main/java/org/apache/cxf/helpers/JavaUtils.java b/core/src/main/java/org/apache/cxf/helpers/JavaUtils.java
index 9b5b7aa..0dce097 100644
--- a/core/src/main/java/org/apache/cxf/helpers/JavaUtils.java
+++ b/core/src/main/java/org/apache/cxf/helpers/JavaUtils.java
@@ -27,7 +27,7 @@ public final class JavaUtils {
/** Use this character as suffix */
static final char KEYWORD_PREFIX = '_';
-
+
/**
* These are java keywords as specified at the following URL.
* http://java.sun.com/docs/books/jls/third_edition/html/lexical.html#3.9
@@ -46,6 +46,17 @@ public final class JavaUtils {
"void", "volatile", "while"
));
+ private static boolean isJava9Compatible;
+
+ static {
+ String version = System.getProperty("java.version");
+ if (version.indexOf(".") > 0) {
+ version = version.substring(0, version.indexOf("."));
+ }
+
+ setJava9Compatible(Integer.valueOf(version) >= 9);
+ }
+
private JavaUtils() {
}
@@ -66,4 +77,11 @@ public final class JavaUtils {
return KEYWORD_PREFIX + keyword;
}
+ public static boolean isJava9Compatible() {
+ return isJava9Compatible;
+ }
+
+ private static void setJava9Compatible(boolean java9Compatible) {
+ JavaUtils.isJava9Compatible = java9Compatible;
+ }
}
diff --git a/maven-plugins/codegen-plugin/pom.xml b/maven-plugins/codegen-plugin/pom.xml
index ec7ca00..5c7331e 100644
--- a/maven-plugins/codegen-plugin/pom.xml
+++ b/maven-plugins/codegen-plugin/pom.xml
@@ -207,9 +207,9 @@
</dependencies>
</profile>
<profile>
- <id>java9</id>
+ <id>java9-plus</id>
<activation>
- <jdk>9</jdk>
+ <jdk>[9,)</jdk>
</activation>
<dependencies>
<dependency>
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 7e15252..7a4f797 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
@@ -42,6 +42,7 @@ import org.apache.cxf.common.util.SystemPropertyAction;
import org.apache.cxf.common.util.URIParserUtil;
import org.apache.cxf.helpers.CastUtils;
import org.apache.cxf.helpers.FileUtils;
+import org.apache.cxf.helpers.JavaUtils;
import org.apache.maven.ProjectDependenciesResolver;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.resolver.AbstractArtifactResolutionException;
@@ -203,7 +204,7 @@ public abstract class AbstractCodegenMoho extends AbstractMojo {
}
public void execute() throws MojoExecutionException {
- if (System.getProperty("java.version").startsWith("9")) {
+ if (JavaUtils.isJava9Compatible()) {
fork = "true";
additionalJvmArgs = "--add-modules java.activation,java.xml.bind,java.xml.ws "
+ "--add-exports=java.xml.bind/com.sun.xml.internal.bind.v2.runtime=ALL-UNNAMED "
@@ -780,6 +781,7 @@ public abstract class AbstractCodegenMoho extends AbstractMojo {
: baseURI.resolve(URIParserUtil.escapeChars(wsdlLocation));
}
+
protected void downloadRemoteWsdls(List<GenericWsdlOption> effectiveWsdlOptions)
throws MojoExecutionException {
diff --git a/maven-plugins/java2ws-plugin/src/main/java/org/apache/cxf/maven_plugin/Java2WSMojo.java b/maven-plugins/java2ws-plugin/src/main/java/org/apache/cxf/maven_plugin/Java2WSMojo.java
index fc996a6..fca5084 100644
--- a/maven-plugins/java2ws-plugin/src/main/java/org/apache/cxf/maven_plugin/Java2WSMojo.java
+++ b/maven-plugins/java2ws-plugin/src/main/java/org/apache/cxf/maven_plugin/Java2WSMojo.java
@@ -27,6 +27,7 @@ import java.util.StringTokenizer;
import org.apache.commons.lang3.SystemUtils;
import org.apache.cxf.helpers.FileUtils;
+import org.apache.cxf.helpers.JavaUtils;
import org.apache.cxf.tools.common.CommandInterfaceUtils;
import org.apache.cxf.tools.java2ws.JavaToWS;
import org.apache.maven.artifact.Artifact;
@@ -209,7 +210,7 @@ public class Java2WSMojo extends AbstractMojo {
private String additionalJvmArgs;
public void execute() throws MojoExecutionException {
- if (System.getProperty("java.version").startsWith("9")) {
+ if (JavaUtils.isJava9Compatible()) {
fork = true;
additionalJvmArgs = "--add-modules java.activation,java.xml.bind,java.xml.ws "
+ "--add-exports=java.xml.bind/com.sun.xml.internal.bind.v2.runtime=ALL-UNNAMED "
diff --git a/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/WADL2JavaMojo.java b/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/WADL2JavaMojo.java
index e741e5e..20c8554 100644
--- a/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/WADL2JavaMojo.java
+++ b/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/WADL2JavaMojo.java
@@ -26,6 +26,7 @@ import java.util.List;
import java.util.Set;
import org.apache.cxf.Bus;
+import org.apache.cxf.helpers.JavaUtils;
import org.apache.cxf.maven_plugin.common.ClassLoaderSwitcher;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.Component;
@@ -73,7 +74,7 @@ public class WADL2JavaMojo extends AbstractCodeGeneratorMojo {
}
public void execute() throws MojoExecutionException {
- if (System.getProperty("java.version").startsWith("9")) {
+ if (JavaUtils.isJava9Compatible()) {
fork = "true";
additionalJvmArgs = "--add-modules java.activation,java.xml.bind,java.xml.ws "
+ "--add-exports=java.xml.bind/com.sun.xml.internal.bind.v2.runtime=ALL-UNNAMED "
diff --git a/parent/pom.xml b/parent/pom.xml
index fa58257..020b86d 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -2361,7 +2361,7 @@
</build>
</profile>
<profile>
- <id>java9</id>
+ <id>java9-plus</id>
<properties>
<cxf.karaf.version>4.1.0</cxf.karaf.version>
<cxf.pax.exam.version>4.11.0</cxf.pax.exam.version>
@@ -2369,7 +2369,7 @@
<cxf.surefire.fork.vmargs>-ea --patch-module java.xml.ws.annotation=${project.basedir}/target/java9/javax.annotation-api-${cxf.javax.annotation-api.version}.jar --patch-module java.transaction=${project.basedir}/target/java9 --add-exports=java.naming/com.sun.jndi.ldap=ALL-UNNAMED --add-exports=java.xml.bind/com.sun.xml.internal.bind=ALL-UNNAMED --add-exports=java.xml.bind/com.sun.xml.internal.bind.v2=ALL-UNNAMED --add-exports=java.xml.bind/com.sun.xml.internal.bind.v2.run [...]
</properties>
<activation>
- <jdk>9</jdk>
+ <jdk>[9,)</jdk>
</activation>
<build>
<plugins>
diff --git a/tools/common/src/main/java/org/apache/cxf/tools/common/ProcessorTestBase.java b/tools/common/src/main/java/org/apache/cxf/tools/common/ProcessorTestBase.java
index e1725ff..a900493 100644
--- a/tools/common/src/main/java/org/apache/cxf/tools/common/ProcessorTestBase.java
+++ b/tools/common/src/main/java/org/apache/cxf/tools/common/ProcessorTestBase.java
@@ -45,6 +45,7 @@ import javax.xml.namespace.QName;
import org.apache.cxf.common.util.StringUtils;
import org.apache.cxf.helpers.FileUtils;
+import org.apache.cxf.helpers.JavaUtils;
import org.apache.cxf.tools.util.ToolsStaxUtils;
import org.apache.ws.commons.schema.constants.Constants;
@@ -94,7 +95,7 @@ public class ProcessorTestBase extends Assert {
@Before
public void setUp() throws Exception {
- if (System.getProperty("java.version").startsWith("9")) {
+ if (JavaUtils.isJava9Compatible()) {
System.setProperty("org.apache.cxf.common.util.Compiler-fork", "true");
}
}
--
To stop receiving notification emails like this one, please contact
ffang@apache.org.