apply plugin: 'groovy'
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
compile 'org.codehaus.groovy:groovy-all:2.3.7'
compile 'org.apache.ant:ant:1.9.4'
testCompile 'junit:junit:4.11'
testCompile 'commons-io:commons-io:2.2'
}
sourceSets {
main {
groovy {
srcDirs = ['./src/main/groovy']
include 'Main.groovy'
}
}
test {
groovy {
srcDirs = ['./src/test/groovy']
}
}
}
task runScript(type: JavaExec) {
description 'Run Groovy script'
// Set main property to name of Groovy script class.
main = 'Main'
// Set classpath for running the Groovy script.
classpath = sourceSets.main.runtimeClasspath
}
defaultTasks 'runScript'
使用类似以上的 build.grale 配置, 你可以以 grale 来运行指定的类; gradle test 来运行测试。