Giter Site home page Giter Site logo

jaxb2-basics's Introduction

JAXB2 Basics

JAXB2 Basics is an open source project which provides useful plugins and tools for JAXB 2.x reference implementation.

IMPORTANT NOTE

This repository has been merged in jaxb-tools repository along maven-jaxb2-plugin.
Users are encouraged to read the migration guide to get the latest version of the plugin according their JAXB version

Documentation

Please refer to the wiki for documentation.

JAXB2 Basics can only be used with JAXB/XJC 2.3.0 and higher. JAXB/XJC versions 2.2.x and earlier are no longer supported.

JAXB2 Basics can only be used with Java 1.8 and above.

Using JAXB2 Basics

JAXB2 Basics Plugins

  • SimpleEquals Plugin - generates runtime-free reflection-free equals(...) methods.
  • SimpleHashCode Plugin - generates runtime-free reflection-free hashCode() methods.
  • Equals Plugin - generates reflection-free strategic equals(...) method.
  • HashCode Plugin - generates reflection-free strategic hashCode() method.
  • ToString Plugin - generates reflection-free strategic toString() methods.
  • Copyable Plugin - generates reflection-free strategic copy(...) deep copying.
  • Mergeable Plugin - generates reflection-free strategic merge(...) methods to merge data from two source objects into the given object.
  • Inheritance Plugin - makes schema-derived classes extend certain class or implement certain interfaces.
  • Wildcard Plugin - allows you to specify the wildcard mode for the wildcard properties.
  • AutoInheritance Plugin - makes classes derived from global elements or complex types extend or implement certain classes or interfaces automatically.
  • Setters Plugin - generates setters for collections.
  • Simplify Plugin - simplifies weird properties like aOrBOrC.
  • EnumValue Plugin - makes all the generated enums implement the EnumValue<T> interface.
  • JAXBIndex Plugin - generated jaxb.index files listing schema-derived classes.
  • FixJAXB1058 Plugin - fixes JAXB-1058.

Credits

jaxb2-basics's People

Contributors

brcolow avatar codecholeric avatar hansjoachim avatar highsource avatar laurentschoelens avatar mattrpav avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jaxb2-basics's Issues

Provide JSR-305 support

I'd like to analyze my source code with the Checker Framework, in particular using its Nullness checker. Some of my code interfaces with JAXB and JAXB-basics generated code. Now, I can add a package-level annotation for the generated code, specifying that all parameters, return types and fields are @Nullable (or @Nonnull), but in fact there are both @Nullable and @Nonnull parameters and return types, so that doesn't actually work.

Hence my question: would you be open to adding the JSR-305 @Nullable and @Nonnull annotations to the interfaces and classes of the jaxb2-basics-runtme library, as well as the code generated by the jaxb2-basics plugin?

The change would introduce a provided-scope dependency on com.google.code.findbugs:jsr305:3.0.0 and thus be backwards-compatible. (Because Maven won't add it to the classpath of downstream dependencies and Java will simply ignore annotations it can't find on the classpath.)

I'd be willing to do the actual work and open a PR. Let me know if you have questions or concerns.

Simplified Java property name customization

Unless I'm mistaken, there is currently no mechanism to customize the name of the Java properties outputted by the Simply plugin, aside from the pluralization option; I half-remember seeing a statement somewhere in the docs (perhaps the old ones on highsource.org?) to this effect.

If this is indeed the case, should I be aware of anything in particular if I were to fork and (attempt to) implement the functionality?

Pluralize names of simplified-out lists

The simplify plugin generates

protected List<FooType> foo; // foo is singular
protected List<BarType> far; // bar is singular

from the complex property

<xs:choice maxOccurs="unbounded">
    <xs:element name="foo" type="FooType"/>
    <xs:element name="far" type="BarType"/>
</xs:choice>

Would it be possible to generate "pluralized" lists (similarly to what simpler&better binding mode does), i.e.

protected List<FooType> foos; // Notice fooS instead of Foo
protected List<BarType> bars;  // Notice barS instead of Bar

?

Issue with boolean default values and mergeFrom, copyTo, equals

I have a schema with a "testBoolean" attribute (type xs:boolean) with default value "true".

xs:attribute name="testBoolean" type="xs:boolean" default="true"

xjc will generate a "isTestBoolean" method for the testBoolean, which shows that internally the boolean can have a null value which is converted to the schema-defined true in the isTestBoolean method.

public boolean isTestBoolean() {
    if (testBoolean == null) {
        return true;
    } else {
        return testBoolean;
    }
}

Issue found is that the mergeFrom seems to convert undefined boolean values to "false" instead of the default value. The code line below shows that the generated code is directly checking the protected "testBoolean" field, instead of using "isTestBoolean()" method. It also converts a null value to "false".

lhsTestBoolean = ((leftObject.testBoolean!= null)?leftObject.isTestBoolean():false);

The result is that after running the mergeFrom function the booleans have an incorrect value "false" instead of staying undefined (null/true).

Tested with jaxb-basics 0.9.4 and 0.9.5.

There is similar code generated for many other methods as well (equals, copyTo ..) which I did not test.

Maven build fails

$ git branch -avv
* 0.9.5                 9a922d6 Version 0.9.5
  master                b64a89b [origin/master] Version 0.9.6-SNAPSHOT
  remotes/origin/HEAD   -> origin/master
  remotes/origin/master b64a89b Version 0.9.6-SNAPSHOT

some-user@KOC10550 ~/git/jaxb2-basics
$ mvn package
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for org.jvnet.jaxb2_commons:jaxb2-basics-plugins:jar:0.9.5
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-shade-plugin is missing. @ org.jvnet.jaxb2_commons:jaxb2-basics-plugins:[unknown-version], C:\Users\some-user\git\jaxb2-basics\plugins\pom.xml, line 27, column 12
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] JAXB2 Basics - Project
[INFO] JAXB2 Basics - Ant Task
[INFO] JAXB2 Basics - Runtime
[INFO] JAXB2 Basics - Tools
[INFO] JAXB2 Basics - Testing
[INFO] JAXB2 Basics - Basic Plugins
[INFO] JAXB2 Basics - Full Plugins JAR
[INFO] JAXB2 Basics - Distribution
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building JAXB2 Basics - Project 0.9.5
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ jaxb2-basics-project ---
[INFO]
[INFO] >>> maven-source-plugin:2.3:jar (attach-source) > generate-sources @ jaxb2-basics-project >>>
[INFO]
[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ jaxb2-basics-project ---
[INFO]
[INFO] <<< maven-source-plugin:2.3:jar (attach-source) < generate-sources @ jaxb2-basics-project <<<
[INFO]
[INFO] --- maven-source-plugin:2.3:jar (attach-source) @ jaxb2-basics-project ---
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building JAXB2 Basics - Ant Task 0.9.5
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ jaxb2-basics-ant ---
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ jaxb2-basics-ant ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\some-user\git\jaxb2-basics\ant\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ jaxb2-basics-ant ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ jaxb2-basics-ant ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\some-user\git\jaxb2-basics\ant\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ jaxb2-basics-ant ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ jaxb2-basics-ant ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-jar-plugin:2.5:jar (default-jar) @ jaxb2-basics-ant ---
[INFO] Building jar: C:\Users\some-user\git\jaxb2-basics\ant\target\jaxb2-basics-ant-0.9.5.jar
[INFO]
[INFO] >>> maven-source-plugin:2.3:jar (attach-source) > generate-sources @ jaxb2-basics-ant >>>
[INFO]
[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ jaxb2-basics-ant ---
[INFO]
[INFO] <<< maven-source-plugin:2.3:jar (attach-source) < generate-sources @ jaxb2-basics-ant <<<
[INFO]
[INFO] --- maven-source-plugin:2.3:jar (attach-source) @ jaxb2-basics-ant ---
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building JAXB2 Basics - Runtime 0.9.5
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ jaxb2-basics-runtime ---
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ jaxb2-basics-runtime ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ jaxb2-basics-runtime ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-bundle-plugin:2.5.3:manifest (bundle-manifest) @ jaxb2-basics-runtime ---
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ jaxb2-basics-runtime ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 3 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ jaxb2-basics-runtime ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ jaxb2-basics-runtime ---
[INFO] Surefire report directory: C:\Users\some-user\git\jaxb2-basics\runtime\target\surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running org.hisrc.xml.bind.tests.addelement.AddElementTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.36 sec
Running org.hisrc.xml.bind.tests.dogs.DogTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.044 sec
Running org.hisrc.xml.bind.tests.dynamicelementname.DynamicElementNameTest
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><characteristics><store_capacity>40</store_capacity></characteristics>Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.021 sec
Running org.hisrc.xml.bind.tests.DynamicSchemaTest
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><a name="works"/>Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.154 sec
Running org.jvnet.jaxb2_commons.lang.tests.CopyStrategyTest
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.059 sec
Running org.jvnet.jaxb2_commons.xml.bind.model.util.tests.XmlTypeUtilsTest
Tests run: 36, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.056 sec
Running org.jvnet.jaxb2_commons.xml.namespace.util.tests.QNameUtilsTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec

Results :

Tests run: 43, Failures: 0, Errors: 0, Skipped: 0

[INFO]
[INFO] --- maven-jar-plugin:2.5:jar (default-jar) @ jaxb2-basics-runtime ---
[INFO] Building jar: C:\Users\some-user\git\jaxb2-basics\runtime\target\jaxb2-basics-runtime-0.9.5.jar
[INFO]
[INFO] >>> maven-source-plugin:2.3:jar (attach-source) > generate-sources @ jaxb2-basics-runtime >>>
[INFO]
[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ jaxb2-basics-runtime ---
[INFO]
[INFO] <<< maven-source-plugin:2.3:jar (attach-source) < generate-sources @ jaxb2-basics-runtime <<<
[INFO]
[INFO] --- maven-source-plugin:2.3:jar (attach-source) @ jaxb2-basics-runtime ---
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building JAXB2 Basics - Tools 0.9.5
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ jaxb2-basics-tools ---
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ jaxb2-basics-tools ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\some-user\git\jaxb2-basics\tools\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ jaxb2-basics-tools ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ jaxb2-basics-tools ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ jaxb2-basics-tools ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ jaxb2-basics-tools ---
[INFO] Surefire report directory: C:\Users\some-user\git\jaxb2-basics\tools\target\surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running org.jvnet.jaxb2_commons.reflection.util.test.FieldAccessorTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.094 sec
Running org.jvnet.jaxb2_commons.xjc.model.concrete.tests.alpha.AlphaMInfoFactoryTest
Tests run: 8, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.101 sec

Results :

Tests run: 9, Failures: 0, Errors: 0, Skipped: 0

[INFO]
[INFO] --- maven-jar-plugin:2.5:jar (default-jar) @ jaxb2-basics-tools ---
[INFO] Building jar: C:\Users\some-user\git\jaxb2-basics\tools\target\jaxb2-basics-tools-0.9.5.jar
[INFO]
[INFO] >>> maven-source-plugin:2.3:jar (attach-source) > generate-sources @ jaxb2-basics-tools >>>
[INFO]
[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ jaxb2-basics-tools ---
[INFO]
[INFO] <<< maven-source-plugin:2.3:jar (attach-source) < generate-sources @ jaxb2-basics-tools <<<
[INFO]
[INFO] --- maven-source-plugin:2.3:jar (attach-source) @ jaxb2-basics-tools ---
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building JAXB2 Basics - Testing 0.9.5
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ jaxb2-basics-testing ---
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ jaxb2-basics-testing ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\some-user\git\jaxb2-basics\testing\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ jaxb2-basics-testing ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ jaxb2-basics-testing ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\some-user\git\jaxb2-basics\testing\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ jaxb2-basics-testing ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ jaxb2-basics-testing ---
[INFO] Surefire report directory: C:\Users\some-user\git\jaxb2-basics\testing\target\surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running org.jvnet.jaxb2_commons.test.tests.TrivialSamplesTest
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.108 sec

Results :

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0

[INFO]
[INFO] --- maven-jar-plugin:2.5:jar (default-jar) @ jaxb2-basics-testing ---
[INFO] Building jar: C:\Users\some-user\git\jaxb2-basics\testing\target\jaxb2-basics-testing-0.9.5.jar
[INFO]
[INFO] >>> maven-source-plugin:2.3:jar (attach-source) > generate-sources @ jaxb2-basics-testing >>>
[INFO]
[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ jaxb2-basics-testing ---
[INFO]
[INFO] <<< maven-source-plugin:2.3:jar (attach-source) < generate-sources @ jaxb2-basics-testing <<<
[INFO]
[INFO] --- maven-source-plugin:2.3:jar (attach-source) @ jaxb2-basics-testing ---
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building JAXB2 Basics - Basic Plugins 0.9.5
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ jaxb2-basics ---
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ jaxb2-basics ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ jaxb2-basics ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 68 source files to C:\Users\some-user\git\jaxb2-basics\basic\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ jaxb2-basics ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ jaxb2-basics ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ jaxb2-basics ---
[INFO] Surefire report directory: C:\Users\some-user\git\jaxb2-basics\basic\target\surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running org.jvnet.jaxb2_commons.plugin.inheritance.tests.JavaParserTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.245 sec
Running org.jvnet.jaxb2_commons.plugin.inheritance.tests.JavaTypeParserTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec

Results :

Tests run: 2, Failures: 0, Errors: 0, Skipped: 0

[INFO]
[INFO] --- maven-jar-plugin:2.5:jar (default-jar) @ jaxb2-basics ---
[INFO] Building jar: C:\Users\some-user\git\jaxb2-basics\basic\target\jaxb2-basics-0.9.5.jar
[INFO]
[INFO] >>> maven-source-plugin:2.3:jar (attach-source) > generate-sources @ jaxb2-basics >>>
[INFO]
[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ jaxb2-basics ---
[INFO]
[INFO] <<< maven-source-plugin:2.3:jar (attach-source) < generate-sources @ jaxb2-basics <<<
[INFO]
[INFO] --- maven-source-plugin:2.3:jar (attach-source) @ jaxb2-basics ---
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building JAXB2 Basics - Full Plugins JAR 0.9.5
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ jaxb2-basics-plugins ---
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ jaxb2-basics-plugins ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ jaxb2-basics-plugins ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ jaxb2-basics-plugins ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\some-user\git\jaxb2-basics\plugins\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ jaxb2-basics-plugins ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ jaxb2-basics-plugins ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-jar-plugin:2.5:jar (default-jar) @ jaxb2-basics-plugins ---
[INFO] Building jar: C:\Users\some-user\git\jaxb2-basics\plugins\target\jaxb2-basics-plugins-0.9.5.jar
[INFO]
[INFO] >>> maven-source-plugin:2.3:jar (attach-source) > generate-sources @ jaxb2-basics-plugins >>>
[INFO]
[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ jaxb2-basics-plugins ---
[INFO]
[INFO] <<< maven-source-plugin:2.3:jar (attach-source) < generate-sources @ jaxb2-basics-plugins <<<
[INFO]
[INFO] --- maven-source-plugin:2.3:jar (attach-source) @ jaxb2-basics-plugins ---
[INFO]
[INFO] --- maven-shade-plugin:2.4.2:shade (default) @ jaxb2-basics-plugins ---
[INFO] Including org.jvnet.jaxb2_commons:jaxb2-basics:jar:0.9.5 in the shaded jar.
[INFO] Including com.google.code.javaparser:javaparser:jar:1.0.11 in the shaded jar.
[INFO] Including org.jvnet.jaxb2_commons:jaxb2-basics-runtime:jar:0.9.5 in the shaded jar.
[INFO] Including org.jvnet.jaxb2_commons:jaxb2-basics-tools:jar:0.9.5 in the shaded jar.
[INFO] Including org.slf4j:slf4j-api:jar:1.7.7 in the shaded jar.
[INFO] Including commons-beanutils:commons-beanutils:jar:1.9.2 in the shaded jar.
[INFO] Including commons-collections:commons-collections:jar:3.2.1 in the shaded jar.
[INFO] Including org.slf4j:jcl-over-slf4j:jar:1.7.7 in the shaded jar.
[INFO] Including org.apache.commons:commons-lang3:jar:3.2.1 in the shaded jar.
[INFO] Replacing original artifact with shaded artifact.
[INFO] Replacing C:\Users\some-user\git\jaxb2-basics\plugins\target\jaxb2-basics-plugins-0.9.5.jar with C:\Users\some-user\git\jaxb2-basics\plugins\target\jaxb2-basics-plugins-0.9.5-shaded.jar
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building JAXB2 Basics - Distribution 0.9.5
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for org.jvnet.jaxb2_commons:jaxb2-basics-sample-po:zip:maven-src:0.9.5 is missing, no dependency information available
[WARNING] The POM for org.jvnet.jaxb2_commons:jaxb2-basics-sample-po:zip:ant-src:0.9.5 is missing, no dependency information available
[WARNING] The POM for org.jvnet.jaxb2_commons:jaxb2-basics-sample-po-simple:zip:maven-src:0.9.5 is missing, no dependency information available
[WARNING] The POM for org.jvnet.jaxb2_commons:jaxb2-basics-sample-po-simple:zip:ant-src:0.9.5 is missing, no dependency information available
[WARNING] The POM for org.jvnet.jaxb2_commons:jaxb2-basics-sample-basic:zip:maven-src:0.9.5 is missing, no dependency information available
[WARNING] The POM for org.jvnet.jaxb2_commons:jaxb2-basics-sample-basic:zip:ant-src:0.9.5 is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] JAXB2 Basics - Project ............................. SUCCESS [  1.150 s]
[INFO] JAXB2 Basics - Ant Task ............................ SUCCESS [  1.214 s]
[INFO] JAXB2 Basics - Runtime ............................. SUCCESS [  4.447 s]
[INFO] JAXB2 Basics - Tools ............................... SUCCESS [  2.000 s]
[INFO] JAXB2 Basics - Testing ............................. SUCCESS [  0.461 s]
[INFO] JAXB2 Basics - Basic Plugins ....................... SUCCESS [  4.548 s]
[INFO] JAXB2 Basics - Full Plugins JAR .................... SUCCESS [  1.447 s]
[INFO] JAXB2 Basics - Distribution ........................ FAILURE [  0.049 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 15.612 s
[INFO] Finished at: 2015-11-02T13:28:06+01:00
[INFO] Final Memory: 26M/264M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project jaxb2-basics-dist: Could not resolve dependencies for project org.jvnet.jaxb2_commons:jaxb2-basics-dist:pom:0.9.5: The following artifacts could not be resolved: org.jvnet.jaxb2_commons:jaxb2-basics-sample-po:zip:maven-src:0.9.5, org.jvnet.jaxb2_commons:jaxb2-basics-sample-po:zip:ant-src:0.9.5, org.jvnet.jaxb2_commons:jaxb2-basics-sample-po-simple:zip:maven-src:0.9.5, org.jvnet.jaxb2_commons:jaxb2-basics-sample-po-simple:zip:ant-src:0.9.5, org.jvnet.jaxb2_commons:jaxb2-basics-sample-basic:zip:maven-src:0.9.5, org.jvnet.jaxb2_commons:jaxb2-basics-sample-basic:zip:ant-src:0.9.5: Failure to find org.jvnet.jaxb2_commons:jaxb2-basics-sample-po:zip:maven-src:0.9.5 in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :jaxb2-basics-dist

0.9.2 and later versions has error: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBind

With 0.9.2 and later versions I have

<plugin> 
<groupId>org.jvnet.jaxb2_commons</groupId> 
<artifactId>jaxb2-basics</artifactId> 
<version>0.9.2</version> 
</plugin> 

I have got error:
Using java.util.ServiceLoader

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". 
SLF4J: Defaulting to no-operation (NOP) logger implementation 
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. 

Wth 0.9.1 all is ok.

<profiles> 
<profile> 
<id>generateResources</id> 
<build> 
<plugins> 
<plugin> 
<groupId>org.jvnet.jaxb2.maven2</groupId> 
<artifactId>maven-jaxb2-plugin</artifactId> 
<version>${maven-jaxb2-plugin.version}</version> 
<configuration> 
<generatePackage>com.rsa.eosago.platform.dto</generatePackage> 
<generateDirectory>src/main/java</generateDirectory> 
<schemaDirectory>src/main/resources/dto/xsd</schemaDirectory> 
<schemaIncludes> 
<schemaInclude>*.xsd</schemaInclude> 
</schemaIncludes> 
<extension>true</extension> 
<strict>false</strict> 
<episode>false</episode> 
<verbose>true</verbose> 
<bindingDirectory>src/main/resources/dto</bindingDirectory> 
<bindingIncludes> 
<include>binding.xjb</include> 
</bindingIncludes> 
<args> 
<arg>-Xannotate</arg> 
<arg>-Xinheritance</arg> 
</args> 
<plugins> 
<plugin> 
<groupId>org.jvnet.jaxb2_commons</groupId> 
<artifactId>jaxb2-basics</artifactId> 
<version>0.9.2</version> 
</plugin> 
<plugin> 
<groupId>org.jvnet.jaxb2_commons</groupId> 
<artifactId>jaxb2-basics-annotate</artifactId> 
<version>1.0.1</version> 
</plugin> 
</plugins> 
</configuration> 
<executions> 
<execution> 
<goals> 
<goal>generate</goal> 
</goals> 
</execution> 
</executions> 
</plugin> 
</plugins> 
</build> 
</profile> 
</profiles>

Make list setters 'null' safe

From my point of view the below code is not null safe.
If value is null, draftl.addAll(value) will throw a NullPointerException

public void setStrings(List<String> value) {
    this.strings = null;
    List<String> draftl = this.getStrings();
    draftl.addAll(value);
}

There are situations where I can simply do not have the chance to test the value before. Eg: setStrings() is automatically invoked by some framework (like Dozer)
Could you make it look like below:

public void setStrings(List<String> value) {
    this.strings = null;
    if (value != null) {
      List<String> draftl = this.getStrings();
      draftl.addAll(value);
    }
}

One workaround is to use the direct access, but if the incoming list is unmodifiable, then we are on dangerous grounds.

xjc:superClass not supported by copyable, equals and hashCode plugins

I got almost correctly class generated from definitions. Almost because clone, hashCode, equals, copyTo don't use the same methods from superClass so some data in clone and equals are missing.
My generated class x extends y implements Cloneable, CopyTo, Serializable,
class y implements Cloneable, CopyTo, Serializable.

Copyable plugin code got some superClass code but it seems to me it's not executed.
How to configure plugin to generate correct method clone which also cloning attributes from superclass?

inheritance:extends overrides xs:extension base

If binding is extended with inheritance:extends=someClass then someClass overrides
mainClass defined in element with xs:extension base=mainClass.

If binding contains xjc:superClass name=someClass then behavior is correct and
mainClass from xs:extension base=mainClass is not overriden by someClass (someClass is added only to class without extends)

Potential Documentation Improvements

At http://confluence.highsource.org/display/J2B/Simplify+Plugin the annotation is at one point placed in the choice, not in an element, which might lead to some confusion.

At the same page, in the section "Usage" there is an xsd snippet containting the part
jaxb:extensionBindingPrefixes="... simplify"
I think it would be a good idea to replace this with
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
jaxb:extensionBindingPrefixes="<otherPrefixes> simplify"
and to explain somewhere that in order to use this plugin the -extension option needs to be set.

Experienced users should know the xmlns:jaxb... part but it can confuse users who dont know that much about xml and jaxb.

Issue with mergeTo and optional attribute

I have an element in my schema with an optional attribute "testAttribute" with type xs:positiveInteger. I am generating mergeTo code with -Xmergeable , and I have
&lt;jaxb:globalBindings generateIsSetMethod="true"&gt;.

When I process XML files where the "testAttribute" is omitted, and use mergeTo method, the omitted (null) values change to defined 0 values (A defined value 0 is not allowed in my schema , while null or "not defined" is legal).

The reason is that the merge code calls the generated "isSet" method, but when the attribute is not set it uses a defined value "0" instead.

 int lhsTestAttribute;
 lhsTestAttribute = (leftObject.isSetTestAttribute()?leftObject.getTestAttribute(): 0);
 int rhsTestAttribute;
 rhsTestAttribute = (rightObject.isSetTestAttribute()?rightObject.getTestAttribute(): 0);

In case I switch to
<jaxb:globalBindings generateIsSetMethod="false">
the issue disappears because the merge code is generated with "Integer" instead of "int" , which properly keeps the null value like this:

 Integer lhsTestAttribute;
 lhsTestAttribute= this.getTestAttribute();
 Integer rhsTestAttribute;
 rhsTestAttribute= that.getTestAttribute();

here the value is merged correctly as null.

wrong place with simplify plugin

The issue is about the simplify plugin.

When I tried to give a maven build on the project, I got exception "compiler was unable to honor this as-element-property customization. It is attached to a wrong place, or its inconsistent with other bindings" whenever the simplify customization was put on choice or element inside the choice.

Here is my schema

 <?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified"  xmlns="http://www.aaa.com/00" targetNamespace="http://www.aaa.com/00" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/jaxb http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd"  xmlns:simplify="http://jaxb2-commons.dev.java.net/basic/simplify" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" jaxb:extensionBindingPrefixes="simplify">  <xs:complexType name="OpTimesAndDur">   <xs:sequence>   <xs:element name="OpTimeDur" minOccurs="0" maxOccurs="50">   <xs:complexType>         <xs:sequence>  <xs:element name="TimeCat" type="xs:string" minOccurs="1" maxOccurs="1" />            <xs:choice minOccurs="1" maxOccurs="1">  <xs:element name="Time" type="xs:dateTime" minOccurs="1" maxOccurs="1">  <xs:annotation>    <xs:appinfo>   <simplify:as-element-property />                  </xs:appinfo>   </xs:annotation>   </xs:element>    <xs:element name="Duration" type="xs:duration" minOccurs="1" maxOccurs="1" />   </xs:choice>   </xs:sequence>   </xs:complexType>     </xs:element>    </xs:sequence>  </xs:complexType></xs:schema>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.