stianh / gradle-jaxb-plugin Goto Github PK
View Code? Open in Web Editor NEWGradle plugin for generating jaxb classes.
Gradle plugin for generating jaxb classes.
Must be able to supply the dependencies needed for these plugins in addition to any eventual options
The package can be specified inside the xsd now, but sometimes one needs to overwrite it. For example when you're using an external schema that one "cannot" change.
When specifying which package to generate Java code into, xjc will fail when doing separate compilation. Add an issue to JAXB's JIRA
at http://java.net/jira/browse/JAXB.
Use the maven-jaxb2-plugin episode sample as a test case for the
issue. Just add package specifications and it will fail.
Hi,
I recently upgraded my OpenJDK (7.u40_2.4.0 -> 7.u40_2.4.1) and I think I've been bitten by the same problem as described in [1]:
:generateSchemaSource FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':generateSchemaSource'.
> java.lang.AssertionError: org.xml.sax.SAXParseException; systemId: jar:file:/home/estan/.gradle/caches/artifacts-23/filestore/com.sun.xml.bind/jaxb-xjc/2.2.7/jar/f351eed8b1ee9a1dd242bf81bf7a391c40a16d18/jaxb-xjc-2.2.7.jar!/com/sun/tools/xjc/reader/xmlschema/bindinfo/binding.xsd; lineNumber: 52; columnNumber: 88; schema_reference: Failed to read schema document 'xjc.xsd', because 'file' access is not allowed due to restriction set by the accessExternalSchema property.
I'm not sure if the Gradle plugin is able to solve this, since I can't find a way in the Ant task to control the JAXP features used (to turn off the now default restricted access to external resources), but I'll file it as a bug here since at the moment I've had to downgrade my JDK to work around the problem.
Thanks a lot for an otherwise nice plugin!
Would it be possible to flesh out this section a little more and to give some examples, at first glance I have no idea what this section refers to or what I am supposed to do. Do I include this in my build.gradle and also what are the most common default settings (at a very minimum, what do I need?)
the jaxb source directory sets
sourceSets {
main {
jaxb {
<setup srcDir, includes, excludes, output, etc>
}
}
test {
jaxb {
<setup srcDir, includes, excludes, output, etc>
}
}
}
Currently the schemaDir is hard coded to "src/${sourceSet.name}/jaxb". Request to allow the default to be changed via a plugin convention object.
I took a look at the source code and it seems the plugin does define a convention object but the name of the object, JaxbSourceDirectory, does not lend itself to extension. I would be happy to create a patch if you felt like it was OK to rename the convention object perhaps to JaxbPluginConvention?
Also, please consider changing the default from "src/${sourceSet.name}/jaxb" to "src/${sourceSet.name}/xsd". This might be more appropriate because there could be other uses for these schemas other than just JAXB code generation.
Make it possible to specify all the ant task's parameters on this plugin
I did get some feedback from one of the contributors to the project that this project is dead, has not been updated to work with later JDK's and no future plan to refresh the project.
Ideally when something does not work and no intention to update, would hope this project would be deleted from github and all references to it everywhere; It sucked a lot of time away from my day thinking I was doing something wrong, but in the end it was simply dead, not working code.
It looks like this plugin project is dead; if anyone has a working example of how to use JAXB with gradle (using JDK 1.6 or higher), please let me know.
It looks like someone somewhere will have to jump in and rewrite this from scratch; I would but have little time, will put it on the stack of other things out there that were started and then abandoned.
The plugin currently requires the jaxb-xjc library to be added to the jaxb Configuration. The compile Configuration inherits from the jaxb Configuration which ultimately means that the jaxb-xjc library MUST be a part of the compile Configuration.
This is unwanted. The jaxb-xjc library is only needed during the build process to generate the Java classes it is not needed to actually compile the code.
One example of an unwanted side effect of this is that if you have a WAR file that depends on the project that has the jaxb plugin applied, the WAR file will end up with a jaxb-xjc.jar file in the WEB-INF/lib, unnecessarily bloating the WAR file. This of course can be worked around by excluding the jaxb-xjc from the War project's compile dependency but this should not be necessary.
Also, in regards to compiling the generated Java files I realize we still need to add the jaxb-api/jaxb-impl JARs to the compile Configuration. Please consider whether it is the job of the jaxb plugin to actual assist in seting up these JARs in the compile Configuration at all? Perhaps it is just expected that the jaxb-api/jaxb-impl will be added to the normal compile Confguration directly like this:
compile ("com.sun.xml.bind:jaxb-impl:2.1.3")
instead of
jaxb ("com.sun.xml.bind:jaxb-impl:2.1.3")
Not saying I have a strong opinion...just a question.
I am confused about this snippet of code in the usage section:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'no.entitas.gradle.jaxb:gradle-jaxb-plugin:2.0'
}
}
In my build script I have a separate dependencies{} section and a repositories {} section that does not live inside a buildscript{} section.
What is the code above doing that in the Usage: section there are two dependencies{} section and the 'repositories{} lives inside a buildscript{} section?
I cannot get this plugin to work by following the instructions.
I have logged some information here, if someone can reply to the Gradle forums list.
http://forums.gradle.org/gradle/topics/how_to_run_xjc_within_gradle_to_generate_classes_from_xsd
Set a default value of "" for the two project properties mentioned above so that the build can be executed without setting these properties. This would be useful for developers working on patches who do not have or need access to the username and password.
I am looking at the Usage section and there is this snipped of code:
dependencies {
jaxb 'com.sun.xml.bind:jaxb-xjc:2.2.4-1'
}
I typically see gradle build files that have lines that begin with 'compile group' or 'testCompile group:'
What does beginning the line with 'jaxb' do, should this not simply be 'compile'?
If you look at this URL section 8.3, and 8.4. I am trying to understand the Usage section in detail.
It looks like the code on the master != release 2.0 in maven-central/jcenter.
When applying release 2.0 to my project with Gradle 1.11 I get the warnings:
The ConfigurationContainer.add() method has been deprecated and is scheduled to be removed in Gradle 2.0. Please use the create() method instead.
The TaskContainer.add() method has been deprecated and is scheduled to be removed in Gradle 2.0. Please use the create() method instead.
As the warnings suggest, with Gradle 2.0-rc-1 the plugin is unusable as it results in an error:
* What went wrong:
A problem occurred evaluating script.
> Could not find method add() for arguments [jaxb, no.entitas.gradle.jaxb.plugin.JaxbPlugin$_apply_closure1@79726c51] on configuration container.
This, while on the master this issue was already fixed a year ago (23-5-2013).
Can you please publish a new release to make the plugin compatible with Gradle 2+?
When I followed the Usage example and ran a $gradle build, I got the following:
Download http://repo1.maven.org/maven2/com/sun/xml/bind/jaxb-xjc/2.2.4-1/jaxb-xjc-2.2.4-1.pom Download http://repo1.maven.org/maven2/com/sun/xml/bind/jaxb-impl/2.2.4-1/jaxb-impl-2.2.4-1.pom Download http://repo1.maven.org/maven2/javax/xml/bind/jaxb-api/2.2.3/jaxb-api-2.2.3.pom Download http://repo1.maven.org/maven2/javax/xml/stream/stax-api/1.0-2/stax-api-1.0-2.pom Download http://repo1.maven.org/maven2/com/sun/xml/bind/jaxb-xjc/2.2.4-1/jaxb-xjc-2.2.4-1.jar Download http://repo1.maven.org/maven2/com/sun/xml/bind/jaxb-impl/2.2.4-1/jaxb-impl-2.2.4-1.jar Download http://repo1.maven.org/maven2/javax/xml/bind/jaxb-api/2.2.3/jaxb-api-2.2.3.jar Download http://repo1.maven.org/maven2/javax/xml/stream/stax-api/1.0-2/stax-api-1.0-2.jar
Notice this is pulling down jars from com.sun.xml.bind.jaxb-api/2.2.3/jaxb-api-2.2.3.jar and jaxb-xjc and jaxb-impl and stax-api and much more.
I don't want to use any of those; I am using JDK 1.6 which does not need these jars as dependencies; I want to use the JAXB capabilities built into the JDK.
How to make this plugin work so that it only pulls what is needed when using JDK 1.6 or higher? Can the Usage section be updated (as most of the free world is on JDK 1.6 or higher?)
Very confused by using this plugin.
As @mraccola mentioned in #5, it would make more sense that the default source directory is .../xsd instead of .../jaxb. This signals that the schemas can be used for other things besides generating source code from.
Spelled out, this means changing the plugin to use "src/${sourceSet.name}/xsd as the default.
Version 1.1-SNAPSHOT Gradle 1.0 Milestone 3
I have added jaxb-xjc as a dependecy:
dependencies {
classpath module(group: 'no.entitas', name: 'gradle-jaxb-plugin', version: '1.1-SNAPSHOT'){
dependency "com.sun.xml.bind:jaxb-xjc:2.2.4-1"
}
It does not generate any more output from the run, but just generates a useless class (JAXBDebug) in default package which can cause problems under IDEs.
When I added just this:
apply plugin: 'jaxb'
buildscript {
repositories {
mavenLocal()
mavenCentral()
maven {
credentials {
username ""
password ""
}
url "https://myrepo.mycomp.com"
}
}
dependencies {
classpath 'no.entitas.gradle.jaxb:gradle-jaxb-plugin:2.0'
}
}
dependencies {
compile 'org.springframework:spring-core:4.0.6.RELEASE'
compile 'org.springframework:spring-context:4.0.6.RELEASE'
compile 'org.apache.commons:commons-email:1.3.3'
// why does not begin with 'compile'?
jaxb 'com.sun.xml.bind:jaxb-xjc:2.2.4-1'
// QA
testCompile 'org.springframework:spring-test:4.0.6.RELEASE'
testCompile group: 'junit', name: 'junit', version: '4.+'
}
I get an error:
$ gradle build
Download http://repo1.maven.org/maven2/no/entitas/gradle/jaxb/gradle-jaxb-plugin/2.0/gradle-jaxb-plugin-2.0.pom
Download http://repo1.maven.org/maven2/no/entitas/gradle/jaxb/gradle-jaxb-plugin/2.0/gradle-jaxb-plugin-2.0.jar
The ConfigurationContainer.add() method has been deprecated and is scheduled to be removed in Gradle 2.0. Please use the create() method instead.
The TaskContainer.add() method has been deprecated and is scheduled to be removed in Gradle 2.0. Please use the create() method instead.
:generateSchemaSource UP-TO-DATE
:compileJava
FAILURE: Build failed with an exception.
What went wrong:
Could not resolve all dependencies for configuration ':compile'.
Could not find org.springframework:spring-core:4.0.6.RELEASE.
Required by:
:mymodule:unspecified
Could not find org.springframework:spring-context:4.0.6.RELEASE.
Required by:
:mymodule:unspecified
Could not find cglib:cglib:2.2.2.
Required by:
:mymodule:unspecified
Could not find com.force.api:force-wsc:22.0.0.
Required by:
:ForceOnbaseImportNB:unspecified
Could not find org.apache.commons:commons-email:1.3.3.
Required by:
:mymodule:unspecified
Could not find com.sun.xml.bind:jaxb-xjc:2.2.4-1.
Required by:
:mymodule:unspecified
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 5.852 secs
When I run this plugin with JDK 1.6.0_45, it hangs and never returns to the command prompt.
$ gradle build
The ConfigurationContainer.add() method has been deprecated and is scheduled to be removed in Gradle 2.0. Please use the create() method instead.
The TaskContainer.add() method has been deprecated and is scheduled to be removed in Gradle 2.0. Please use the create() method instead.
:generateSchemaSource UP-TO-DATE
:compileJava
:processResources UP-TO-DATE
:classes
:jar UP-TO-DATE
:assemble UP-TO-DATE
:generateTestSchemaSource UP-TO-DATE
:compileTestJava
(it hangs here forever and does not return until I hit Cntrl-C)
Would be nice to be able to install the artifact into a local Maven repository without needing to digitally sign the artifact.
Currently, running the following command:
gradle install
results in the following error:
Execution failed for task ':signArchives'.
Cause: Cannot perform signing task ':signArchives' because it has no configured signatory
This is a problem for developers who do not have access to the signing key.
Want to upgrade but I couldn't find any release notes. Can you please provide release notes for the past 3 releases?
defaults: name:catalog.cat, loader:classpathloader
Now it is only possible to specify 1 package for each module, not per file.
This can be solved by not overriding the jaxb:package statement in the schema file.
Hi,
according to improvment http://java.net/jira/browse/JAXB-499 now it is possible set encoding for generated sources.
See also http://jaxb.java.net/nonav/2.2.5-2/docs/ch02.html#a-2-2-5u2 and http://jaxb.java.net/nonav/2.2.5-2/docs/ch04.html#section-356252324237826 .
So, please, add this ability to plugin. Without it we have a lot of WARNings during generating sources.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.