如何添加一个新的sourceset到摇篮? [英] How do I add a new sourceset to Gradle?
问题描述
我要集成测试添加到我的摇篮版本(1.0版)。他们应该,因为他们需要部署web应用程序到本地主机(他们测试Web应用程序)从我的正常测试单独运行。测试应该能够使用我的主要来源集中定义的类。我如何做到这一点?
I want to add integration tests to my Gradle build (Version 1.0). They should run separately from my normal tests because they require a webapp to be deployed to localhost (they test that webapp). The tests should be able to use classes defined in my main source set. How do I make this happen?
推荐答案
这花了我一段时间才能找出和在线资源是不是很大。所以我想我的文档解决方案。
This took me a while to figure out and the online resources weren't great. So I wanted to document my solution.
这是一个具有intTest源除了主测试源台套一个简单的Gradle构建脚本:
This is a simple gradle build script that has an intTest source set in addition to the main and test source sets:
apply plugin: "java"
sourceSets {
// Note that just declaring this sourceset creates two configurations.
intTest {
java {
compileClasspath += main.output
runtimeClasspath += main.output
}
}
}
configurations {
intTestCompile.extendsFrom testCompile
intTestRuntime.extendsFrom testRuntime
}
task intTest(type:Test){
description = "Run integration tests (located in src/intTest/...)."
testClassesDir = project.sourceSets.intTest.output.classesDir
classpath = project.sourceSets.intTest.runtimeClasspath
}
这篇关于如何添加一个新的sourceset到摇篮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!