I reopened a project from 6 months ago.This is the structure
src/main/groovy
src/template/groovy
src/test/groovy
I found that the unit tests are broken (src/test/groovy), because the class path is not picking up code from src/template/groovy
This is my gradle file:
apply plugin: 'java'
apply plugin: 'groovy'
apply plugin: 'maven'
apply plugin: 'eclipse'
apply plugin: 'idea'
group = 'uk.co.xenonique.acme'
archivesBaseName = 'acme'
version = '1.0-SNAPSHOT'
repositories {
mavenLocal()
mavenCentral()
}
task wrapper(type: Wrapper) {
gradleVersion = '1.11'
}
// Override Gradle defaults - a force an exploded JAR view
sourceSets {
main {
output.resourcesDir = 'build/classes/main'
output.classesDir
= 'build/classes/main'
groovy {
srcDir 'src/main/groovy'
}
resources {
srcDir 'src/main/resources'
}
}
templates {
output.resourcesDir = 'build/classes/main'
output.classesDir
= 'build/classes/main'
groovy {
srcDir 'src/templates/groovy'
}
resources {
srcDir 'src/templates/resources'
}
}
test {
output.resourcesDir = 'build/classes/test'
output.classesDir
= 'build/classes/test'
groovy {
srcDir 'src/test/groovy'
}
resources {
srcDir 'src/test/resources'
}
}
}
dependencies {
// http://forums.gradle.org/gradle/topics/how_to_add_an_extra_sourceset_in_a_gradle_groovy_build
templatesCompile configurations.compile
templatesRuntime configurations.runtime
compile 'org.codehaus.groovy:groovy-all:2.0.0'
compile 'jline:jline:1.0'
compile 'org.apache.ant:ant:1.8.4'
compile 'org.apache.ant:ant-launcher:1.8.4'
compile 'org.fusesource.jansi:jansi:1.11'
compile 'org.fusesource.jansi:jansi-native:1.5'
testCompile 'junit:junit:4.11'
}
Also when I execute: gradle idea
It generate source sets as:
src/main/groovy
src/template/java
src/test/groovy
It gets the wrong source set for template. It is groovy not java.