英文:
Eclipse project build-path -- conflicting error
问题
Eclipse在Gradle项目的构建路径上出现错误 - 无法在<project-name>/src/test中嵌套'<project-name>/src/test/resources'。要启用嵌套,请从'<project-name>/src/test'中排除'resources/'。
所以我按照它的要求做了以下两件事 -
-
根据此解决方案 https://discuss.gradle.org/t/how-can-i-declare-an-exclusion-on-my-source-folder/22821,已将
exclude 'src/test/resources'
添加到项目的build.gradle
文件中的sourceSets > .. > java
块中,该块已存在。 -
通过Eclipse - 就像它要求的那样 - 从构建路径中排除了'/test/resources'。
但是我仍然在构建路径上看到错误。
编辑:图像显示了应用我所做的更改后的方式 - 打开源代码/编辑窗口的后来情况。我是多年的Java工程师,但对Gradle还不熟悉。
这是否是Eclipse/Buildship插件与Gradle版本不匹配的问题?对Gradle还不熟悉,但看起来Gradle不向后兼容。版本如下:
- Buildship Gradle Integration 3.0
- Eclipse 2020-06
- Gradle 5.5
- Java 11
我将其导入为Gradle项目。
TIA
英文:
Eclipse is giving an error to build-path of the Gradle project on it --
> Cannot nest '<project-name>/src/test/resources' inside <project-name>/src/test'. To enable the nesting exclude 'resources/' from '<project-name>/src/test'
So I do what it asks – both of these two --
-
by the solution here https://discuss.gradle.org/t/how-can-i-declare-an-exclusion-on-my-source-folder/22821 added
exclude 'src/test/resources'
into the Java srcDirs in thesourceSets> .. >java
block already there is in thebuild.gradle
file of the project, -
and via Eclipse—made it exclude the
/test/resources'
from the build-path, just as it asks.
But I sill see the error on the build-path.
Cleared the project name-s in the image
EDIT: image shows way after applying the changes i made-- a latter open of the source/edit window. i'm a Java eng of many yrs. just new on Gradle.
Is this a mismatch on the Eclipse/Buildship plugin and the Gradle version? Not savvy on Gradle/yet, but looks like Gradle isn’t backward compatible.
Versions are:
- Buildship Gradle Integration 3.0
- Eclipse 2020-06
- Gradle 5.5
- Java 11
I imported as a Gradle project.
TIA
答案1
得分: 0
问题在于您有源文件夹**src/test/
以及第一个源文件夹内/嵌套的另一个源文件夹src/test/resources
**。嵌套源文件夹没有意义,因此不允许。因此出现了错误消息。
相反,您应该为测试代码和测试资源使用源文件夹src/test/java
和src/test/resources
。
英文:
The problem is that you have the source folder src/test/
and another source folder src/test/resources
inside/nested in the first source folder. Nesting source folders does not make sense and is therefore not allowed. Hence the error message.
Instead, you should have the source folders src/test/java
and src/test/resources
for your test code and for your test resources.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论