Return-Path: X-Original-To: apmail-cxf-commits-archive@www.apache.org Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 7ED3A109F3 for ; Wed, 28 May 2014 16:12:04 +0000 (UTC) Received: (qmail 79329 invoked by uid 500); 28 May 2014 16:12:04 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 79276 invoked by uid 500); 28 May 2014 16:12:04 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 79269 invoked by uid 99); 28 May 2014 16:12:04 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 28 May 2014 16:12:04 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 2CD1C8C5848; Wed, 28 May 2014 16:12:04 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: dkulp@apache.org To: commits@cxf.apache.org Message-Id: <4d218f9400204966830ff41b685c184f@git.apache.org> X-Mailer: ASF-Git Admin Mailer 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 +0000 (UTC) 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 Authored: Wed May 28 12:11:30 2014 -0400 Committer: Daniel Kulp 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 @@ com.sun.xml.bind jaxb-impl - 2.1.12 com.sun.xml.bind jaxb-xjc - 2.1.12 + + + com.sun.xml.bind + jaxb-core 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 @@ com.sun.xml.bind + jaxb-core + provided + + + com.sun.xml.bind jaxb-impl provided 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 @@ javax.xml.bind jaxb-api + 2.2.9 com.sun.xml.bind jaxb-xjc + 2.2.10-b140310.1920 com.sun.xml.bind jaxb-impl + 2.2.10-b140310.1920 + + + com.sun.xml.bind + jaxb-core + 2.2.10-b140310.1920 xml-resolver 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 @@ com.sun.xml.bind + jaxb-core + + + com.sun.xml.bind jaxb-xjc 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 @@ com.sun.xml.bind + jaxb-core + provided + + + com.sun.xml.bind jaxb-impl provided 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 @@ jaxb-impl + com.sun.xml.bind + jaxb-core + + junit junit test 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 @@ javax.xml.bind jaxb-api - 2.1 + 2.2.9 com.sun.xml.bind jaxb-impl - 2.1.13 + 2.2.10-b140310.1920 com.sun.xml.bind jaxb-xjc - 2.1.13 + 2.2.10-b140310.1920 + + + com.sun.xml.bind + jaxb-core + 2.2.10-b140310.1920 junit 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 @@ com.sun.xml.bind jaxb-xjc + + com.sun.xml.bind + jaxb-core + junit junit 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 @@ com.sun.xml.bind jaxb-xjc + + com.sun.xml.bind + jaxb-core + junit junit