[CXF-7683]Codegen fails when using JDK10 with maven and cxf-plugin
diff --git a/cxf-xjc-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractXSDToJavaMojo.java b/cxf-xjc-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractXSDToJavaMojo.java
index 4b1232d..56fb83f 100644
--- a/cxf-xjc-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractXSDToJavaMojo.java
+++ b/cxf-xjc-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractXSDToJavaMojo.java
@@ -153,7 +153,7 @@
}
}
public void execute() throws MojoExecutionException {
- if (System.getProperty("java.version").startsWith("9")) {
+ if (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 "
@@ -341,6 +341,15 @@
protected List<String> getClasspathElements() throws DependencyResolutionRequiredException {
return project.getCompileClasspathElements();
}
+
+ protected boolean isJava9Compatible() {
+ String version = System.getProperty("java.version");
+ if (version.indexOf(".") > 0) {
+ version = version.substring(0, version.indexOf("."));
+ }
+
+ return Integer.valueOf(version) >= 9;
+ }
private int run(XsdOption option, String xsdFile, String outputDir) throws Exception {
if (!fork) {
diff --git a/pom.xml b/pom.xml
index d950cbe..d2de361 100644
--- a/pom.xml
+++ b/pom.xml
@@ -585,9 +585,9 @@
</build>
</profile>
<profile>
- <id>java9</id>
+ <id>java9-plus</id>
<activation>
- <jdk>9</jdk>
+ <jdk>[9,)</jdk>
</activation>
<dependencies>
<dependency>