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?

I’ve added the correct dependency

dependencies {

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

For Mavan the suggested solution is this

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

apply plugin: 'java'
  repositories {
  configurations {
 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