如何从 Gradle 运行 Groovy 以及 Groovy 单元测试

原创
2015/03/28 07:47
阅读数 1K
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 来运行测试。

展开阅读全文
加载中

作者的其它热门文章

打赏
0
2 收藏
分享
打赏
0 评论
2 收藏
0
分享
返回顶部
顶部