码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2015-03-28 08:57:55      阅读:144      评论:0      收藏:0      [点我收藏+]

标签:

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 来运行测试。

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

标签:

原文地址:http://my.oschina.net/u/553266/blog/392960

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!