I’m using the gradle file below to try and work with a Java directory structure in which the test classes are in the same packages/directories as the code they are testing. However, I need to split the test class files into a different directory when building. This .gradle seems to work if I’m building from the command line. However creating an Eclipse project from it will generate duplicate entries in the classpath. What am I doing wrong?
classpath problem:
<classpathentry excluding="**/*Test.java" kind="src" path="src"/>
<classpathentry including="**/*Test.java" kind="src" path="src"/>
build.gradle:
apply plugin: 'java'
apply plugin: 'eclipse'
sourceCompatibility = 1.6
repositories {
mavenCentral()
}
dependencies {
compile group: 'log4j', name: 'log4j', version: '1.2.17'
testCompile group: 'junit', name: 'junit', version: '4.+'
}
sourceSets {
main {
java {
srcDir 'src'
exclude '**/*Test.java'
}
output.classesDir = file("$buildDir/classes")
}
test {
java {
srcDir 'src'
include '**/*Test.java'
}
output.classesDir = file("$buildDir/test-classes")
}
}
Gradle Version: 1.4 Gradle IDE version (for eclipse): 3.2.0.201301240803-M2