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 來運行測試。apache