Gradle刷新删除构建路径中的源文件夹 [英] Gradle refresh removes source folders in build path
问题描述
我导入了一个已经存在的 gradle 项目并且一切正常,但是当我从 eclipse 这两个文件夹 src 刷新gradle源文件夹时, test 从构建路径中删除,并且测试文件夹中使用的类不再被发现。
我尝试将它导入为java gradle项目,但迄今为止没有任何工作。另外,将build.gradle主源码集更改为 srcDirs =src也没有帮助。
这是我的版本。 gradle 这与原始项目完全相同。
apply plugin:'eclipse'
apply'plugin':'java'
apply plugin:'war'
repositories {
mavenCentral()
}
webAppDirName ='WebContent '
sourceSets {
main {
java {
srcDir'/ src'
}
资源{
srcDir'/ src'
}
}
test {
java {
srcDirs = [test]
}
}
}
依赖关系{
testCompile'org.mockito:mockito-core:1. +'
testCompile'junit:junit:4.12'
}
有没有人对此有任何想法?
我做的是e dit项目根目录下的.classpath文件:
...
<属性>
< attribute name =FROM_GRADLE_MODELvalue =true/>
< / attributes>
< / classpathentry>
...
将classpathentry节点中的path属性设置为适当的价值。
I imported an already existing gradle project and everything works fine, but when I refresh the gradle source folders from eclipse both folders src and test are removed from the build path and the classes used in the test folder are not found anymore.
I tried importing it as a java and gradle project but nothing worked so far. Also changing the build.gradle main sourceSets to srcDirs = "src" didn't help either.
This is my build.gradle which is exactly the same one of the original project.
apply plugin: 'eclipse'
apply plugin: 'java'
apply plugin: 'war'
repositories {
mavenCentral()
}
webAppDirName = 'WebContent'
sourceSets {
main {
java {
srcDir '/src'
}
resources {
srcDir '/src'
}
}
test {
java {
srcDirs = ["test"]
}
}
}
dependencies {
testCompile 'org.mockito:mockito-core:1.+'
testCompile 'junit:junit:4.12'
}
Does anyone have any thoughts on this?
What I did was edit the .classpath file in the project root:
...
<classpathentry kind="src" path="src/main/java">
<attributes>
<attribute name="FROM_GRADLE_MODEL" value="true"/>
</attributes>
</classpathentry>
...
set the "path" attribute in the "classpathentry" node to the appropriate value.
这篇关于Gradle刷新删除构建路径中的源文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!