I am converting an ant project to gradle when the main source is built by ant (through gradle) while the test sources are built directly by gradle.
The main sources are under $[projectRoot}/src. Test sources are under $[projectRoot}/test
Even after explicitly setting sourceSets, compileTesstsJava fails to see the test sources and finishes trivially, indicating that source set is empty:
sourceSets {
main {
java {
srcDir = 'src'
}
}
test {
java {
srcDir = 'test'
}
}
}
Here is the compileTestJava run:
$ ./gradlew test --debug
//...
^[[1m> Building 42% > :compileTestJava^[[22m^[[33D^[[0K^[[1A^[[93CStarting to execute task ':compileTestJava'
^[[1m> Building 42% > :compileTestJava^[[22m^[[33D^[[0K^[[1A^[[14CINFO
^[[1m> Building 42% > :compileTestJava^[[22m^[[33D^[[0K^[[1A^[[18C]
^[[1m> Building 42% > :compileTestJava^[[22m^[[33D^[[0K^[[1A^[[21Corg.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter
^[[1m> Building 42% > :compileTestJava^[[22m^[[33D^[[0K^[[1A^[[93C]
^[[1m> Building 42% > :compileTestJava^[[22m^[[33D^[[0K^[[1A^[[95CSkipping task ':compileTestJava' as it has no source files.
^[[1m> Building 42% > :compileTestJava^[[22m^[[33D^[[0K^[[1A^[[154C
^[[1m> Building 42% > :compileTestJava^[[22m^[[33D^[[0K14:34:21.427
^[[1m> Building 42% > :compileTestJava^[[22m^[[33D^[[0K^[[1A^[[12C [
^[[1m> Building 42% > :compileTestJava^[[22m^[[33D^[[0K^[[1A^[[14CDEBUG
^[[1m> Building 42% > :compileTestJava^[[22m^[[33D^[[0K^[[1A^[[19C] [
^[[1m> Building 42% > :compileTestJava^[[22m^[[33D^[[0K^[[1A^[[22Corg.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter
^[[1m> Building 42% > :compileTestJava^[[22m^[[33D^[[0K^[[1A^[[91C]
^[[1m> Building 42% > :compileTestJava^[[22m^[[33D^[[0K^[[1A^[[93CFinished executing task ':compileTestJava'
//...
$
Here is my full build.gradle:
defaultTasks ‘test’ buildDir = ‘dist’ apply plugin: ‘java’ apply plugin: ‘eclipse’
ext {
antTarget = “feature” }
sourceSets {
main {
java {
srcDir = ‘src’
}
}
test {
java {
srcDir = ‘test’
}
} }
repositories {
mavenLocal()
mavenCentral()
maven { url “https://repo.spring.io/libs-release” } }
dependencies {
// Add at least version 4.8 of JUnit as dependency.
testCompile ‘junit:junit:[4.8,)’ }
task wrapper(type: Wrapper) {
println '[Running tasks for project ’ + project.getDescription() + ‘]’
gradleVersion = ‘1.11’ }
task antBuild (group: ‘legacyBuild’, description : ‘Invoke Ant build’) {
println ‘[Invoking Ant build]’
ant.importBuild ‘build/build.xml’ }
clean {
project.file(‘dist’).deleteDir() }
Any suggestions greatly appreciated!
I have checked in the gradle script and the full build log into
https://github.com/rk-git/anttogradle
/Kobe