在Eclipse中看不到gradle的新sourceSet [英] New sourceSet by gradle cannot be seen in Eclipse
问题描述
我在gradle项目中创建了称为集成测试的其他源集。一切正常,但是eclipse无法看到为此源集定义的依赖项类。
I have created additional source set called "integration-test" in my gradle project. Ewerything works fine, but eclipse cannot see dependency classes defined exactly for this source set.
subprojects {
apply plugin: 'java'
apply plugin: 'eclipse'
repositories {
mavenCentral()
}
sourceSets {
integrationTest {
java {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
srcDir file('src/integration-test/java')
}
resources.srcDir file('src/integration-test/resources')
}
}
configurations {
integrationTestCompile.extendsFrom testCompile
integrationTestRuntime.extendsFrom testRuntime
}
dependencies {
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-all:1.10.19'
integrationTestCompile 'org.springframework:spring-test:4.1.7.RELEASE'
compile 'org.springframework:spring-context:4.1.7.RELEASE'
compile 'org.springframework:spring-core:4.1.7.RELEASE'
}
task integrationTest(type: Test) {
testClassesDir = sourceSets.integrationTest.output.classesDir
classpath = sourceSets.integrationTest.runtimeClasspath
outputs.upToDateWhen { false }
}
check.dependsOn integrationTest
integrationTest.mustRunAfter test
version = '1.0'
}
当我通过 build gradle,项目是建立,唯一的问题是与蚀。如果我将 org.springframework:spring-test:4.1.7.RELEASE相关性从 integrationTestCompile更改为 testCompile,问题就不存在了。
When i build this project by command "build gradle", project is build, the only problem is with eclipse. If I change dependency 'org.springframework:spring-test:4.1.7.RELEASE' from "integrationTestCompile" to "testCompile", problem is gone.
推荐答案
回答您的问题有点晚了,但是我找到了解决方案,因为我有完全相同的答案问题。
It is a little late to answer your question, but I just found a solution to this, since I had the exact same problem.
添加以下内容:
eclipse {
classpath {
plusConfigurations.add configurations.integrationTestCompile
plusConfigurations.add configurations.integrationTestRuntime
}
}
到gradle文件中解决了该问题。希望对您也一样。
to the gradle file solved the problem. I hope it does the same for you.
这篇关于在Eclipse中看不到gradle的新sourceSet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!