zyxist / chainsaw

Gradle plugin: adds support for building Java 9 modules.
Apache License 2.0
71 stars 4 forks source link

error: module jsr250.api reads package javax.annotation from both jsr250.api and java.xml.ws.annotation #6

Closed deepy closed 6 years ago

deepy commented 6 years ago

I tried to use

javaModule.patchModules 'com.google.code.findbugs:jsr305': 'javax.annotation:jsr250-api'

dependencies {
    patch 'com.google.code.findbugs:jsr305:1.3.9'

    compile 'javax.annotation:jsr250-api:1.0'
    compile 'com.google.guava:guava:23.2-jre'
}

But I still got all the errors

error: the unnamed module reads package javax.annotation from both java.xml.ws.annotation and jsr250.api
error: module jsr250.api reads package javax.annotation from both jsr250.api and java.xml.ws.annotation
zyxist commented 6 years ago

Try to run your build with --debug. Somewhere in the output from Gradle, there should be a line with string Compiler arguments: which contains the exact CLI arguments for the compiler. Please attach it, and your module-info.java descriptor, so that I could take a look at them.

This is a sample project generated by automated integration tests for module patching, which pass (/src/test/groovy/com/zyxist/chainsaw/integration/ModulePatchTestSpec.groovy):

plugins {
    id 'java'
    id 'com.zyxist.chainsaw'
}
repositories {
    jcenter()
}
dependencies {
    patch 'com.google.code.findbugs:jsr305:1.3.9'
    compile 'javax.annotation:jsr250-api:1.0'
    compile 'com.google.guava:guava:23.2-jre'
}
javaModule.name = 'com.example'
javaModule.patchModules 'com.google.code.findbugs:jsr305': 'javax.annotation:jsr250-api'

Module descriptor:

module com.example {
    requires jsr250.api;
    requires com.google.common;
    exports com.example;
}
zyxist commented 6 years ago

BTW. I see that you are patching jsr250-api with jsr305, but your compiler complains about java.xml.ws.annotation module. This module is included in JDK itself, and it also contains javax.annotation package with a subset of annotations from jsr250-api.jar.

Make sure that java.xml.ws.annotation is not present in your module descriptor.

deepy commented 6 years ago

Having turned one of the dependencies into a module the problem went away and I can't quite reproduce it any longer :-/

Thanks for the help though!