Eclipse Buildship插件:嵌套源文件夹

时间:2016-09-13 09:02:28

标签: eclipse gradle gradle-eclipse

我正在使用Gradle Buildship插件来构建我的Eclipse项目。

Gradle itselft配置得很好。所以,我能够从shell构建任何东西。

gradle项目有一个根文件夹和其他子项目。

当我点击Gradle -> Refresh Project时,它会告诉我:

Synchronize Gradle builds with workspace failed due to an unexpected error.
Cannot nest 'living_webapi/src/main/java/com/living/persistence/entities' inside 'living_webapi/src/main/java'. To enable the nesting exclude 'com/' from 'living_webapi/src/main/java'
Java Model Exception: Java Model Status [Cannot nest 'living_webapi/src/main/java/com/living/persistence/entities' inside 'living_webapi/src/main/java'. To enable the nesting exclude 'com/' from 'living_webapi/src/main/java']
    at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:786)
    at org.eclipse.jdt.internal.core.JavaProject.setRawClasspath(JavaProject.java:3097)
    at org.eclipse.jdt.internal.core.JavaProject.setRawClasspath(JavaProject.java:3059)
    at org.eclipse.jdt.internal.core.JavaProject.setRawClasspath(JavaProject.java:3112)
    at org.eclipse.buildship.core.workspace.internal.SourceFolderUpdater.updateClasspath(SourceFolderUpdater.java:234)
    at org.eclipse.buildship.core.workspace.internal.SourceFolderUpdater.updateClasspath(SourceFolderUpdater.java:82)
    at org.eclipse.buildship.core.workspace.internal.SourceFolderUpdater.update(SourceFolderUpdater.java:261)
    at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation.synchronizeOpenJavaProject(SynchronizeGradleBuildOperation.java:223)
    at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation.synchronizeOpenWorkspaceProject(SynchronizeGradleBuildOperation.java:213)
    at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation.synchronizeWorkspaceProject(SynchronizeGradleBuildOperation.java:186)
    at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation.synchronizeGradleProjectWithWorkspaceProject(SynchronizeGradleBuildOperation.java:176)
    at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation.synchronizeGradleBuildWithWorkspace(SynchronizeGradleBuildOperation.java:141)
    at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation.access$000(SynchronizeGradleBuildOperation.java:106)
    at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation$1.run(SynchronizeGradleBuildOperation.java:123)
    at org.eclipse.jdt.internal.core.BatchOperation.executeOperation(BatchOperation.java:39)
    at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:724)
    at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2240)
    at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2267)
    at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:5521)
    at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:5478)
    at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation.run(SynchronizeGradleBuildOperation.java:120)
    at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildsJob.synchronizeBuild(SynchronizeGradleBuildsJob.java:78)
    at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildsJob.runToolingApiJob(SynchronizeGradleBuildsJob.java:69)
    at org.eclipse.buildship.core.util.progress.ToolingApiJob$1.run(ToolingApiJob.java:73)
    at org.eclipse.buildship.core.util.progress.ToolingApiInvoker.invoke(ToolingApiInvoker.java:62)
    at org.eclipse.buildship.core.util.progress.ToolingApiJob.run(ToolingApiJob.java:70)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

2 个答案:

答案 0 :(得分:1)

我也遇到了这个问题。 我的解决方案是设置项目属性。

在Java构建路径中 - >源,将输出文件夹设置为默认值。 有关详细信息,请参见下图。

Project Properties -> Java build path -> Source

Source folder output location

答案 1 :(得分:1)

对我唯一有用的是取消选中“允许将输出文件夹用作源文件夹”选项。

步骤:

  1. 右键单击项目->属性
  2. 单击“属性”弹出窗口左侧的Java构建路径
  3. 单击“源”选项卡
  4. 取消选中“允许源文件夹的输出文件夹”复选框
  5. 点击“应用并关闭”
  6. 右键单击项目-> Gradle->刷新Gradle项目