Problems with eclipse task when having integration tests


(Ståle Undheim) #1

Eclipse task when using integration tests creates a broken .classpath file.

I took the withIntegrationTests sample project in the gradle distribution, and added the following

apply plugin: ‘eclipse’

eclipse.classpath {

plusConfigurations += configurations.integrationTestCompile }

This creates a .classpath file with the following entries, that results in errors in eclipse:

These entries should not have been added to the .classpath file. Is there a way to remove them easily?


(Peter Niederwieser) #2

Looks like some part of your post got swallowed. Can you edit or repost and use HTML code tags for code or verbatim text? Alternatively, you can post a link to a GitHub Gist.


(Ståle Undheim) #3

eclipse.classpath {

file {

whenMerged { classpath ->

classpath.entries.removeAll {

it.path.startsWith(buildDir.absolutePath)

}

}

}

}

This snippet removed all build/* from the eclipse classpath


(Peter Niederwieser) #4

I still don’t know which entries were added in the first place. They are missing from your original post, at least when viewed in the web interface (http://forums.gradle.org/gradle/topics/problems_with_eclipse_task_when_having_integration_tests).


(Ståle Undheim) #5

I am unable to edit the original, here is the lines I added:

apply plugin: 'eclipse'
  eclipse.classpath {
     plusConfigurations += configurations.integrationTestCompile
 }

Since integrationTestCompile depends on the output folder off the main files, the build/main/classes and build/main/resources folders are added to the dependencies, and thus added to the Eclipse .classpath. Same goes for test/[classes|resources].

And here is the fix:

eclipse.classpath {
   file {
     whenMerged { classpath ->
       classpath.entries.removeAll {
         it.path.startsWith(buildDir.absolutePath)
       }
     }
   }
 }

This will remove all dependencies whose path starts with the buildDir.