[CXFXJC-27]ensure xjc plugin can work with java11
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 75b580b..9e9b0dd 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
@@ -161,12 +161,9 @@
public void execute() throws MojoExecutionException {
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 "
- + "--add-exports=jdk.xml.dom/org.w3c.dom.html=ALL-UNNAMED "
+ additionalJvmArgs =
+ "--add-exports=jdk.xml.dom/org.w3c.dom.html=ALL-UNNAMED "
+ "--add-exports=java.xml/com.sun.org.apache.xerces.internal.impl.xs=ALL-UNNAMED "
- + "--add-exports=java.xml.bind/com.sun.xml.internal.bind.marshaller=ALL-UNNAMED "
- + "--add-opens java.xml.ws/javax.xml.ws.wsaddressing=ALL-UNNAMED "
+ "--add-opens java.base/java.security=ALL-UNNAMED "
+ "--add-opens java.base/java.net=ALL-UNNAMED "
+ "--add-opens java.base/java.lang=ALL-UNNAMED "
@@ -349,12 +346,15 @@
}
protected boolean isJava9Compatible() {
- String version = System.getProperty("java.version");
- if (version.indexOf(".") > 0) {
- version = version.substring(0, version.indexOf("."));
+ String version = System.getProperty("java.specification.version");
+ int majorVersion;
+ if (version.contains(".")) { //before jdk 9
+ majorVersion = Integer.parseInt(version.split("\\.")[1]);
+ } else {
+ majorVersion = Integer.parseInt(version);
}
- return Integer.valueOf(version) >= 9;
+ return majorVersion >= 9;
}
private int run(XsdOption option, String xsdFile, String outputDir) throws Exception {
diff --git a/pom.xml b/pom.xml
index aea85a2..7827904 100644
--- a/pom.xml
+++ b/pom.xml
@@ -46,6 +46,7 @@
<properties>
<cxf-buildtools-version>3.4.1</cxf-buildtools-version>
<jdk.version>1.8</jdk.version>
+ <jaxb-version>2.2.11</jaxb-version>
<eclipse.outputDirectory>${basedir}/target/classes</eclipse.outputDirectory>
<downloadSources>true</downloadSources>
@@ -94,17 +95,17 @@
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
- <version>2.2.11</version>
+ <version>${jaxb-version}</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-xjc</artifactId>
- <version>2.2.11</version>
+ <version>${jaxb-version}</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
- <version>2.2.11</version>
+ <version>${jaxb-version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
@@ -589,11 +590,14 @@
<activation>
<jdk>[9,)</jdk>
</activation>
+ <properties>
+ <jaxb-version>2.3.0</jaxb-version>
+ </properties>
<dependencies>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
- <version>2.3.0</version>
+ <version>${jaxb-version}</version>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>