Open CalamarBicefalo opened 6 years ago
We saw this problem ourselves when we tried compiling in 9 the other day. We haven't investigated any fixes yet. If you find one please let us know, we'll try to fix it as soon as we have time to look into answers.
I recently upgraded to JDK10 (from 8) and probably worked through some of this. I have the following dependencies bundled with the plugin.
jaxb: [
"gradle.plugin.org.openrepose:gradle-jaxb-plugin:${pluginVersions.jaxb}",
"com.sun.xml.bind:jaxb-core:2.3.0",
"com.sun.xml.bind:jaxb-impl:2.3.0",
"com.sun.mail:javax.mail:1.6.1",
"javax.xml.bind:jaxb-api:2.3.0",
],
do those dependencies make it work for you? We are looking at moving to 10 ourselves. If they work for you we'd love a pr with them.
Yes, I had it working in 9 and delayed until 10 to avoid thrashing the team. It's been working fine for 6+ months. I am using 2.5.0
due to a NPE bug in this plugin, jaxbApi 2.2.12
and jaxbBind 2.2.10
due to compatibility issues with later releases. I don't have the bandwidth to create a PR, but can show a quick snippet that might help
jaxb.gradle:
apply plugin: 'org.openrepose.gradle.plugins.jaxb'
dependencies {
jaxb libraries.jaxb
}
jaxb {
xsdDir = "${sourceSets.main.output.resourcesDir}/xsd"
bindingsDir = "${sourceSets.main.output.resourcesDir}/xsd"
xjc {
destinationDir = "${buildDir}/generated-sources/jaxb"
args = [ '-Xxew', '-Xvalue-constructor', '-Xfluent-api', '-Xcommons-lang', ]
}
}
sourceSets.main.java.srcDirs += jaxb.xjc.destinationDir
xjc.dependsOn(processResources)
compileJava.dependsOn(xjc)
dependencies.gradle:
jaxb: [
"javax.xml.bind:jaxb-api:${versions.jaxbApi}",
"org.glassfish.jaxb:jaxb-xjc:${versions.jaxbBind}",
"org.glassfish.jaxb:jaxb-runtime:${versions.jaxbBind}",
'org.jvnet.jaxb2_commons:jaxb2-value-constructor:3.0',
'com.github.jaxb-xew-plugin:jaxb-xew-plugin:1.10',
'org.jvnet.jaxb2_commons:jaxb2-commons-lang:2.4',
'org.jvnet.jaxb2_commons:jaxb2-fluent-api:3.0',
"com.sun.mail:javax.mail:1.6.1",
'xerces:xercesImpl:2.12.0',
],
codeQuality.gradle:
sourceCompatibility = JavaVersion.VERSION_1_10
configurations {
checkstyleConfig
patchJsr250
patchJsr305
}
dependencies {
compile libraries.jsr250
patchJsr305 libraries.jsr305
patchJsr250 libraries.jsr250
checkstyleConfig gradlePlugins.checkstyle
}
tasks.withType(JavaExec) {
jvmArgs += [
'--add-modules', 'java.se.ee',
'--add-modules', 'java.xml.bind',
'--add-modules', 'java.compiler',
'--add-exports', 'java.xml.ws.annotation/javax.annotation.security=ALL-UNNAMED',
]
afterEvaluate {
configurations.patchJsr250.each {
jvmArgs += [ '--patch-module', "java.xml.ws.annotation=${it}" ]
}
}
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
options.compilerArgs += [
'-Xlint:all',
'-Xlint:-processing',
'--add-modules', 'java.se.ee',
'--add-modules', 'java.xml.bind',
'--add-modules', 'java.compiler',
'--add-modules', 'java.xml.ws.annotation',
]
options.errorprone {
disableWarningsInGeneratedCode = true
excludedPaths = "${buildDir}/generated-sources/.*"
}
afterEvaluate {
configurations.patchJsr305.each {
options.compilerArgs += [ '--patch-module', "java.xml.ws.annotation=${it}" ]
}
}
}
// static analyzers...
Yes, I had it working in 9 and delayed until 10 to avoid thrashing the team. It's been working fine for 6+ months. I am using
2.5.0
due to a NPE bug in this plugin, jaxbApi2.2.12
and jaxbBind2.2.10
due to compatibility issues with later releases. I don't have the bandwidth to create a PR, but can show a quick snippet that might help
dependencies.gradle:
jaxb: [ "javax.xml.bind:jaxb-api:${versions.jaxbApi}", "org.glassfish.jaxb:jaxb-xjc:${versions.jaxbBind}", "org.glassfish.jaxb:jaxb-runtime:${versions.jaxbBind}", 'org.jvnet.jaxb2_commons:jaxb2-value-constructor:3.0', 'com.github.jaxb-xew-plugin:jaxb-xew-plugin:1.10', 'org.jvnet.jaxb2_commons:jaxb2-commons-lang:2.4', 'org.jvnet.jaxb2_commons:jaxb2-fluent-api:3.0', "com.sun.mail:javax.mail:1.6.1", 'xerces:xercesImpl:2.12.0', ],
@ben-manes - can you please expand a bit on this please? I can't quite understand how this file is being used and where the versions piece is coming from. I tried this code in 4.10.2 and in my build.gradle
I do a `apply from: './gradle-config/depdencies.gradle'
and it looks like
ext {
versions = {
jaxbApi = '2.2.12'
jaxbBind = '2.2.10'
}
jaxb = [
"javax.xml.bind:jaxb-api:${versions.jaxbApi}",
"org.glassfish.jaxb:jaxb-xjc:${versions.jaxbBind}",
"org.glassfish.jaxb:jaxb-runtime:${versions.jaxbBind}",
'org.jvnet.jaxb2_commons:jaxb2-value-constructor:3.0',
'com.github.jaxb-xew-plugin:jaxb-xew-plugin:1.10',
'org.jvnet.jaxb2_commons:jaxb2-commons-lang:2.4',
'org.jvnet.jaxb2_commons:jaxb2-fluent-api:3.0',
"com.sun.mail:javax.mail:1.6.1",
'xerces:xercesImpl:2.12.0',
]
}
but I get this error
Could not get unknown property 'jaxbApi' for object of type org.gradle.api.internal.plugins.DefaultExtraPropertiesExtension.
Sorry I'm new to the whole multi file build and config so any pointers would be great as I would really like to get our build using this in a jdk11 environment, happy to share my full config in some gists afterwards.
I think it's because you are using {}
on versions
instead of []
for an list. That and missing the comma after jaxbApi
version causes Groovy to make an object with two properties instead of a map.
I can't offer the source example, but I use this dependencies.gradle in public project.
@ben-manes thanks so much for this, those configs are amazing and a thing gradle beauty. 👍
I'll dig through that a bit more, I'm still getting some odd errors but I think its more to do with the jaxb libraries and jdk 11 more than the config now.
Why is JDK11 so hard to work with? :-)
It seems to be working now but a few strange errors on the command line:
Errors occurred while build effective model from /Users/michael/.gradle/caches/modules-2/files-2.1/com.sun.istack/istack-commons-tools/2.21/25ebe0fb8451bb4cb700312c62ee3fc1be2131d8/istack-commons-tools-2.21.pom:
'dependencies.dependency.systemPath' for com.sun:tools:jar must specify an absolute path but is ${tools.jar} in com.sun.istack:istack-commons-tools:2.21
I use your caffeine & version plugins a lot as well, thanks so much for sharing all this with the community!
Hi @mb-3000, this happens because tools.jar was removed in Java 9. I solved this error updating my dependencies.
Hi @mb-3000, this happens because tools.jar was removed in Java 9. I solved this error updating my dependencies.
Do you have an example of the config? the plugin seems to want to use 2.2.1 jaxb even if I change to using jaxb 2.3.x. I'm using gradle, it seems to work even with the error but it would be good if the plugin could be updated soon?
Sorry, I'm not using this plugin anymore, but i have the following dependencies in my project and it works fine:
compile group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.0'
compile group: 'com.sun.xml.bind', name: 'jaxb-core', version: '2.3.0'
compile group: 'com.sun.xml.bind', name: 'jaxb-impl', version: '2.3.0'
Are you using the last version (2.5.0) ?
Here's solution worked with me (java 11):
plugins {
id "org.openrepose.gradle.plugins.jaxb" version "2.5.0"
}
dependencies {
jaxb 'org.glassfish.jaxb:jaxb-xjc:2.3.2'
jaxb 'org.glassfish.jaxb:jaxb-runtime:2.3.2'
compile 'jakarta.xml.bind:jakarta.xml.bind-api:2.3.2'
compile 'org.glassfish.jaxb:jaxb-runtime:2.3.2'
}
jaxb {
xsdDir = "${project.buildDir}/example"
xjc {
generateEpisodeFiles = false
generatePackage = "org.company.example"
destinationDir = "${buildDir}/generated-sources/jaxb"
}
}
tasks.named("xsd-dependency-tree").configure {
outputs.upToDateWhen { false }
}
compileJava.dependsOn(xjc)
We are using JDK 10. We get a bunch of errors when some of the dependencies listed in the readme of this project seem to reference good old tools.jar. Since this is no longer available since jigsaw the xjc task isn't too happy.
Errors occurred while build effective model from /Users/a-mac-computer/.gradle/caches/modules-2/files-2.1/org.glassfish.jaxb/jaxb-xjc/2.2.11/2356f739b56bed93101e181ea67224f3ea35dc67/jaxb-xjc-2.2.11.pom: 'dependencyManagement.dependencies.dependency.systemPath' for com.sun:tools:jar must specify an absolute path but is ${tools.jar} in org.glassfish.jaxb:jaxb-xjc:2.2.11
I tried upgrading jaxb-xjc to the latest 2.3.0 but that crashes altogether.
Any suggestions?