Compile Classpath problem J2SE/J2EE

Due to some reasons unfathomable for mere mortals sun/oracle decided to have two implementations for javax.annotations.Resource with different fields one in the JDK the other one in the J2EE libs. Of course the compiler decides to take the wrong one. What is the correct way in gradle to fix this?

http://download.oracle.com/javaee/6/api/javax/annotation/Resource.html#lookup() http://download.oracle.com/javase/6/docs/api/javax/annotation/Resource.html

I’ve added the correct dependency

dependencies {

compile (group: ‘javax’, name: ‘javaee-endorsed-api’, version: ‘6.0’) }

For Mavan the suggested solution is this http://jaitechwriteups.blogspot.com/2011/02/resource-and-new-lookup-attribute-how.html

I think you can take the same approach as suggested in Maven. You just need to Gradle-ize it.

apply plugin: 'java'
  repositories {
 mavenCentral()
}
  configurations {
 endorsed
 compile.extendsFrom endorsed
}
  dependencies {
 endorsed group:'javax', name:'javaee-endorsed-api', version:'6.0'
}
  task stageEndorsed(type: Sync) {
 from configurations.endorsed
 into temporaryDir
}
  tasks.withType(Compile) {
 dependsOn stageEndorsed
 options.compilerArgs << "-Djava.endorsed.dirs=${stageEndorsed.destinationDir}"
}

Thanks for the answer