cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject git commit: Update xjc plugin to work with newer JAXB's, detect the version of jaxb-api found and adjust accordingly.
Date Wed, 28 May 2014 16:12:04 GMT
Repository: cxf-xjc-utils
Updated Branches:
  refs/heads/master 864321f61 -> 34372d4b6


Update xjc plugin to work with newer JAXB's, detect the version of jaxb-api found and adjust
accordingly.


Project: http://git-wip-us.apache.org/repos/asf/cxf-xjc-utils/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf-xjc-utils/commit/34372d4b
Tree: http://git-wip-us.apache.org/repos/asf/cxf-xjc-utils/tree/34372d4b
Diff: http://git-wip-us.apache.org/repos/asf/cxf-xjc-utils/diff/34372d4b

Branch: refs/heads/master
Commit: 34372d4b6ea72548796b0e5c69be5610104587a3
Parents: 864321f
Author: Daniel Kulp <dkulp@apache.org>
Authored: Wed May 28 12:11:30 2014 -0400
Committer: Daniel Kulp <dkulp@apache.org>
Committed: Wed May 28 12:11:30 2014 -0400

----------------------------------------------------------------------
 boolean-test/pom.xml                                |  6 ++++--
 bug671/pom.xml                                      |  5 +++++
 .../org/apache/cxf/xjc/bug671/Bug671Plugin.java     |  3 ++-
 cxf-xjc-plugin/pom.xml                              |  8 ++++++++
 .../apache/cxf/maven_plugin/XSDToJavaRunner.java    | 16 ++++++++++++++++
 dv-test/pom.xml                                     |  4 ++++
 dv/pom.xml                                          |  5 +++++
 .../org/apache/cxf/xjc/dv/DefaultValuePlugin.java   | 11 ++++++++++-
 javadoc/pom.xml                                     |  4 ++++
 pom.xml                                             | 11 ++++++++---
 ts-test/pom.xml                                     |  4 ++++
 wsdlextension-test/pom.xml                          |  4 ++++
 12 files changed, 74 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf-xjc-utils/blob/34372d4b/boolean-test/pom.xml
----------------------------------------------------------------------
diff --git a/boolean-test/pom.xml b/boolean-test/pom.xml
index cb4f578..9274be9 100644
--- a/boolean-test/pom.xml
+++ b/boolean-test/pom.xml
@@ -40,12 +40,14 @@
 		<dependency>
 			<groupId>com.sun.xml.bind</groupId>
 			<artifactId>jaxb-impl</artifactId>
-			<version>2.1.12</version>
 		</dependency>
 		<dependency>
 			<groupId>com.sun.xml.bind</groupId>
 			<artifactId>jaxb-xjc</artifactId>
-			<version>2.1.12</version>
+		</dependency>
+		<dependency>
+			<groupId>com.sun.xml.bind</groupId>
+			<artifactId>jaxb-core</artifactId>
 		</dependency>
 
 		<dependency>

http://git-wip-us.apache.org/repos/asf/cxf-xjc-utils/blob/34372d4b/bug671/pom.xml
----------------------------------------------------------------------
diff --git a/bug671/pom.xml b/bug671/pom.xml
index cbeec4b..9d0a2aa 100644
--- a/bug671/pom.xml
+++ b/bug671/pom.xml
@@ -43,6 +43,11 @@
         </dependency>
         <dependency>
             <groupId>com.sun.xml.bind</groupId>
+            <artifactId>jaxb-core</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.sun.xml.bind</groupId>
             <artifactId>jaxb-impl</artifactId>
             <scope>provided</scope>
         </dependency>

http://git-wip-us.apache.org/repos/asf/cxf-xjc-utils/blob/34372d4b/bug671/src/main/java/org/apache/cxf/xjc/bug671/Bug671Plugin.java
----------------------------------------------------------------------
diff --git a/bug671/src/main/java/org/apache/cxf/xjc/bug671/Bug671Plugin.java b/bug671/src/main/java/org/apache/cxf/xjc/bug671/Bug671Plugin.java
index b22cc99..ce96d93 100644
--- a/bug671/src/main/java/org/apache/cxf/xjc/bug671/Bug671Plugin.java
+++ b/bug671/src/main/java/org/apache/cxf/xjc/bug671/Bug671Plugin.java
@@ -20,6 +20,7 @@
 package org.apache.cxf.xjc.bug671;
 
 
+import com.sun.codemodel.JJavaName;
 import com.sun.tools.xjc.BadCommandLineException;
 import com.sun.tools.xjc.Options;
 import com.sun.tools.xjc.Plugin;
@@ -59,7 +60,7 @@ public class Bug671Plugin {
                     if (idx2 == -1) {
                         idx2 = s.length();
                     }
-                    if (!isJavaIdentifier(s.substring(idx, idx2))) {
+                    if (!JJavaName.isJavaIdentifier(s.substring(idx, idx2))) {
                         s = s.substring(0, idx) + "_" + s.substring(idx);
                     }
                     idx = s.indexOf('.', idx);

http://git-wip-us.apache.org/repos/asf/cxf-xjc-utils/blob/34372d4b/cxf-xjc-plugin/pom.xml
----------------------------------------------------------------------
diff --git a/cxf-xjc-plugin/pom.xml b/cxf-xjc-plugin/pom.xml
index bc99536..018bd06 100644
--- a/cxf-xjc-plugin/pom.xml
+++ b/cxf-xjc-plugin/pom.xml
@@ -84,14 +84,22 @@
         <dependency>
              <groupId>javax.xml.bind</groupId>
              <artifactId>jaxb-api</artifactId>
+             <version>2.2.9</version>
          </dependency>
         <dependency>
             <groupId>com.sun.xml.bind</groupId>
             <artifactId>jaxb-xjc</artifactId>
+            <version>2.2.10-b140310.1920</version>
         </dependency>
         <dependency>
             <groupId>com.sun.xml.bind</groupId>
             <artifactId>jaxb-impl</artifactId>
+            <version>2.2.10-b140310.1920</version>
+        </dependency>
+        <dependency>
+            <groupId>com.sun.xml.bind</groupId>
+            <artifactId>jaxb-core</artifactId>
+            <version>2.2.10-b140310.1920</version>
         </dependency>
         <dependency>
             <groupId>xml-resolver</groupId>

http://git-wip-us.apache.org/repos/asf/cxf-xjc-utils/blob/34372d4b/cxf-xjc-plugin/src/main/java/org/apache/cxf/maven_plugin/XSDToJavaRunner.java
----------------------------------------------------------------------
diff --git a/cxf-xjc-plugin/src/main/java/org/apache/cxf/maven_plugin/XSDToJavaRunner.java
b/cxf-xjc-plugin/src/main/java/org/apache/cxf/maven_plugin/XSDToJavaRunner.java
index 80b4c8d..bd4724b 100644
--- a/cxf-xjc-plugin/src/main/java/org/apache/cxf/maven_plugin/XSDToJavaRunner.java
+++ b/cxf-xjc-plugin/src/main/java/org/apache/cxf/maven_plugin/XSDToJavaRunner.java
@@ -27,6 +27,8 @@ import java.net.URLClassLoader;
 import java.util.ArrayList;
 import java.util.List;
 
+import javax.xml.bind.annotation.XmlElementRef;
+
 import org.xml.sax.InputSource;
 
 import com.sun.codemodel.CodeWriter;
@@ -34,6 +36,7 @@ import com.sun.codemodel.JCodeModel;
 import com.sun.tools.xjc.Language;
 import com.sun.tools.xjc.ModelLoader;
 import com.sun.tools.xjc.Options;
+import com.sun.tools.xjc.api.SpecVersion;
 import com.sun.tools.xjc.model.Model;
 import com.sun.tools.xjc.outline.Outline;
 
@@ -108,6 +111,9 @@ public class XSDToJavaRunner {
                 catResolver.getCatalog().parseCatalog(catalogFile.getPath());
             }
         };
+        if (checkXmlElementRef()) {
+            opt.target = SpecVersion.V2_1;
+        }
         opt.setSchemaLanguage(Language.XMLSCHEMA);
         opt.parseArguments(args);
         Model model = ModelLoader.load(opt, new JCodeModel(), listener);
@@ -131,6 +137,16 @@ public class XSDToJavaRunner {
         }
         return 0;        
     }
+    private boolean checkXmlElementRef() {
+        try {
+            //check the version of JAXB-API that is actually being picked up
+            //so we can set target=2.1 if the 2.1 version of XmlElementRef is picked up
+            XmlElementRef.class.getMethod("required");
+        } catch (Throwable t) {
+            return true;
+        }
+        return false;
+    }
     public static void main(String[] args) throws Exception {
         BuildContext context = new XJCBuildContext();
         XJCErrorListener listener = new XJCErrorListener(context);

http://git-wip-us.apache.org/repos/asf/cxf-xjc-utils/blob/34372d4b/dv-test/pom.xml
----------------------------------------------------------------------
diff --git a/dv-test/pom.xml b/dv-test/pom.xml
index 4188980..a2da8d7 100644
--- a/dv-test/pom.xml
+++ b/dv-test/pom.xml
@@ -44,6 +44,10 @@
         </dependency>
         <dependency>
             <groupId>com.sun.xml.bind</groupId>
+            <artifactId>jaxb-core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.sun.xml.bind</groupId>
             <artifactId>jaxb-xjc</artifactId>
         </dependency>
 

http://git-wip-us.apache.org/repos/asf/cxf-xjc-utils/blob/34372d4b/dv/pom.xml
----------------------------------------------------------------------
diff --git a/dv/pom.xml b/dv/pom.xml
index 58341ee..3e4d7c8 100644
--- a/dv/pom.xml
+++ b/dv/pom.xml
@@ -43,6 +43,11 @@
         </dependency>
         <dependency>
             <groupId>com.sun.xml.bind</groupId>
+            <artifactId>jaxb-core</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.sun.xml.bind</groupId>
             <artifactId>jaxb-impl</artifactId>
             <scope>provided</scope>
         </dependency>

http://git-wip-us.apache.org/repos/asf/cxf-xjc-utils/blob/34372d4b/dv/src/main/java/org/apache/cxf/xjc/dv/DefaultValuePlugin.java
----------------------------------------------------------------------
diff --git a/dv/src/main/java/org/apache/cxf/xjc/dv/DefaultValuePlugin.java b/dv/src/main/java/org/apache/cxf/xjc/dv/DefaultValuePlugin.java
index 166c799..a46ace0 100644
--- a/dv/src/main/java/org/apache/cxf/xjc/dv/DefaultValuePlugin.java
+++ b/dv/src/main/java/org/apache/cxf/xjc/dv/DefaultValuePlugin.java
@@ -125,6 +125,15 @@ public class DefaultValuePlugin {
         return false;
     }
 
+    private int getMinOccurs(XSParticle particle) {
+        try {
+            Number o = (Number)particle.getClass().getMethod("getMinOccurs").invoke(particle);
+            return o.intValue(); 
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+    
     public boolean run(Outline outline, Options opt, ErrorHandler errorHandler) {
         if (!active) {
             return true;
@@ -164,7 +173,7 @@ public class DefaultValuePlugin {
                 if (xsType != null 
                     && xsType.isComplexType()
                     && ((containsDefaultValue(outline, f) && complexTypes)
-                        || (particle != null && particle.getMinOccurs() != 0))) {
+                        || (particle != null && getMinOccurs(particle) != 0))) {
                     String varName = f.getPropertyInfo().getName(false);
                     JFieldVar var = co.implClass.fields().get(varName);
                     if (var != null) {

http://git-wip-us.apache.org/repos/asf/cxf-xjc-utils/blob/34372d4b/javadoc/pom.xml
----------------------------------------------------------------------
diff --git a/javadoc/pom.xml b/javadoc/pom.xml
index 365e5e8..83a61f8 100644
--- a/javadoc/pom.xml
+++ b/javadoc/pom.xml
@@ -41,6 +41,10 @@
 			<artifactId>jaxb-impl</artifactId>
 		</dependency>
 		<dependency>
+			<groupId>com.sun.xml.bind</groupId>
+			<artifactId>jaxb-core</artifactId>
+		</dependency>
+		<dependency>
 			<groupId>junit</groupId>
 			<artifactId>junit</artifactId>
 			<scope>test</scope>

http://git-wip-us.apache.org/repos/asf/cxf-xjc-utils/blob/34372d4b/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index c51603a..bf9d0f1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -86,17 +86,22 @@
             <dependency>
                 <groupId>javax.xml.bind</groupId>
                 <artifactId>jaxb-api</artifactId>
-                <version>2.1</version>
+                <version>2.2.9</version>
             </dependency>
             <dependency>
                 <groupId>com.sun.xml.bind</groupId>
                 <artifactId>jaxb-impl</artifactId>
-                <version>2.1.13</version>
+                <version>2.2.10-b140310.1920</version>
             </dependency>
             <dependency>
                 <groupId>com.sun.xml.bind</groupId>
                 <artifactId>jaxb-xjc</artifactId>
-                <version>2.1.13</version>
+                <version>2.2.10-b140310.1920</version>
+            </dependency>
+            <dependency>
+                <groupId>com.sun.xml.bind</groupId>
+                <artifactId>jaxb-core</artifactId>
+                <version>2.2.10-b140310.1920</version>
             </dependency>
             <dependency>
                 <groupId>junit</groupId>

http://git-wip-us.apache.org/repos/asf/cxf-xjc-utils/blob/34372d4b/ts-test/pom.xml
----------------------------------------------------------------------
diff --git a/ts-test/pom.xml b/ts-test/pom.xml
index a712409..d0552ca 100644
--- a/ts-test/pom.xml
+++ b/ts-test/pom.xml
@@ -44,6 +44,10 @@
             <groupId>com.sun.xml.bind</groupId>
             <artifactId>jaxb-xjc</artifactId>
         </dependency>
+		<dependency>
+			<groupId>com.sun.xml.bind</groupId>
+			<artifactId>jaxb-core</artifactId>
+		</dependency>
         <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>

http://git-wip-us.apache.org/repos/asf/cxf-xjc-utils/blob/34372d4b/wsdlextension-test/pom.xml
----------------------------------------------------------------------
diff --git a/wsdlextension-test/pom.xml b/wsdlextension-test/pom.xml
index c651926..ca6d844 100644
--- a/wsdlextension-test/pom.xml
+++ b/wsdlextension-test/pom.xml
@@ -44,6 +44,10 @@
             <groupId>com.sun.xml.bind</groupId>
             <artifactId>jaxb-xjc</artifactId>
         </dependency>
+		<dependency>
+			<groupId>com.sun.xml.bind</groupId>
+			<artifactId>jaxb-core</artifactId>
+		</dependency>
         <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>


Mime
View raw message