我有一个下面的gradle构建脚本
apply plugin: 'java'
sourceSets {
test {
java {
srcDir 'tests'
}
}
main{
java {srcDir 'web-schedule\\src'}
}
}
repositories {
mavenCentral()
}
dependencies {
compile 'javax:javaee-api:6.0'
compile 'javax:javaee-web-api:6.0'
testRuntime 'org.jboss.arquillian:arquillian-bom:1.0.3.Final'
testRuntime 'org.jboss.arquillian.junit:arquillian-junit-container:1.0.3.Final'
testRuntime 'org.jboss.arquillian.container:arquillian-glassfish-remote-3.1:1.0.0.CR3'
testRuntime 'junit:junit:4.+'
testRuntime 'org.jboss.weld:weld-api:1.1.Final'
}我尝试使用gradle实现全自动编译和测试执行。基本上问题是库依赖。为了在没有测试的情况下编译项目本身,我只需要遵循库
compile 'javax:javaee-api:6.0'
compile 'javax:javaee-web-api:6.0'但对于测试编译,我也需要所有其他的东西。但是在测试编译过程中,如果我有它,它就会抛出异常。我发现解决方案将它排除在测试编译和执行过程之外。现在,我手动执行此操作。我想实现的是完全自动完成它。我需要做的就是。
发布于 2013-03-13 22:10:19
我不明白为什么您必须删除除前两个用于编译生产代码的依赖项之外的所有依赖项,因为其中不涉及testRuntime配置。不确定您是否必须删除测试编译的前两个依赖项,但您肯定必须删除它们才能执行测试。以下是我要尝试的:
sourceSets {
test {
runtimeClasspath -= configurations.compile
// additionally try this:
// compileClasspath -= configurations.compile
}
}发布于 2013-11-06 05:07:40
javaee-api-6.0.jar是一个错误的jar,它没有方法体,只有signatures.So它不可能在运行时使用它。因此,您可以从测试的类路径中排除这个特定的库:
configurations {
testRuntime.exclude module: 'javaee-api'
}https://stackoverflow.com/questions/15385577
复制相似问题