Hi
How do I add a second Groovy build SourceSet in Gradle? I am using Gradle 1.7 at the moment and I cannot seem to get Gradle to understand exactly the specification.
I have these folders:
src/main/groovy
src/main/resources
src/templates/groovy
src/templates/resources
src/test/groovy
src/test/resources
I would like Groovy in the under ‘src/templates/groovy’ to compile and be added to the build. I get an exception org.gradle.api.tasks.TaskExecutionException: Execution failed for task ‘:compileTemplatesGroovy’. Caused by: java.lang.ClassNotFoundException: groovy.lang.GroovyObject
Here is my ‘build.gradle’ file:
// Peter A. Pilgrim present the Java EE 7 Developer Handbook
apply plugin: 'java'
apply plugin: 'groovy'
apply plugin: 'maven'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'application'
// Define equivalent Maven GAV coordinates.
group = 'uk.co.xenonique.example'
archivesBaseName = 'example-generator'
version = '1.0-SNAPSHOT'
mainClassName = "uk.co.xenonique.example.ExampleGenerators"
repositories {
mavenLocal()
mavenCentral()
maven {
url 'https://maven.java.net/content/groups/promoted'
}
maven {
url 'http://repository.jboss.org/nexus/content/groups/public'
}
}
task wrapper(type: Wrapper) {
gradleVersion = '1.7'
}
// 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'
println "-----------------------------------"
println "output.classesDir="+output.classesDir
println "output.resourcesDir="+output.resourcesDir
println "compileClasspath="+compileClasspath.asPath
println "runtimeClasspath="+runtimeClasspath.asPath
println "-----------------------------------"
groovy {
srcDir 'src/templates/groovy'
}
resources {
srcDir 'src/templates/resources'
}
}
test {
resources {
srcDir 'src/test/resources'
}
output.resourcesDir = 'build/classes/test'
output.classesDir
= 'build/classes/test'
}
}
dependencies {
compile 'org.codehaus.groovy:groovy-all:2.0.0'
compile 'jline:jline:1.0'
}
jar {
dependsOn compileTemplatesGroovy
}
run {
dependsOn compileTemplatesGroovy
dependsOn processTemplatesResources
standardInput = System.in
}
// End