diff --git a/org.eclipse.buildship.ui.test/Launch Buildship UI tests.launch b/org.eclipse.buildship.ui.test/Launch Buildship UI tests.launch
index 9cbf78cae..c9a6d6ce1 100644
--- a/org.eclipse.buildship.ui.test/Launch Buildship UI tests.launch
+++ b/org.eclipse.buildship.ui.test/Launch Buildship UI tests.launch
@@ -26,7 +26,7 @@
-
+
diff --git a/org.eclipse.buildship.ui.test/src/main/groovy/org/eclipse/buildship/ui/internal/wizard/project/ProjectImportWizardUiTest.groovy b/org.eclipse.buildship.ui.test/src/main/groovy/org/eclipse/buildship/ui/internal/wizard/project/ProjectImportWizardUiTest.groovy
index 520f01213..63b71a10a 100644
--- a/org.eclipse.buildship.ui.test/src/main/groovy/org/eclipse/buildship/ui/internal/wizard/project/ProjectImportWizardUiTest.groovy
+++ b/org.eclipse.buildship.ui.test/src/main/groovy/org/eclipse/buildship/ui/internal/wizard/project/ProjectImportWizardUiTest.groovy
@@ -11,6 +11,8 @@ package org.eclipse.buildship.ui.internal.wizard.project
import org.eclipse.core.resources.IProject
import org.eclipse.core.runtime.IProgressMonitor
+import org.eclipse.core.runtime.jobs.Job
+import org.eclipse.jdt.core.JavaCore
import org.eclipse.jface.dialogs.IDialogConstants
import org.eclipse.swtbot.eclipse.finder.waits.Conditions
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell
@@ -72,6 +74,28 @@ class ProjectImportWizardUiTest extends SwtBotSpecification {
bot.button("Cancel").click()
}
+ def "import project from folder does not include Java resources of subprojects in the root project"() {
+ given:
+ def rootDir = dir('rootProject') {
+ file 'settings.gradle', 'include "subProject"'
+ dir('subProject') {
+ file 'build.gradle', 'plugins { id "java-library" }'
+ dir('src/main/java') {
+ file 'Foobar.java', 'class Foobar { }'
+ }
+ }
+ }
+
+ when:
+ importProjectFromFolder rootDir
+ waitForImportJobsToFinish()
+ waitForGradleJobsToFinish()
+
+ then:
+ findProject('rootProject').hasNature(JavaCore.NATURE_ID) == false
+ findProject('subProject').hasNature(JavaCore.NATURE_ID) == true
+ }
+
private static SWTBotShell openGradleImportWizard() {
bot.menu("File").menu("Import...").click()
SWTBotShell shell = bot.shell("Import")
@@ -82,6 +106,21 @@ class ProjectImportWizardUiTest extends SwtBotSpecification {
bot.shell(ProjectWizardMessages.Title_GradleProjectWizardPage)
}
+ private void importProjectFromFolder(File projectDir) {
+ bot.menu("File").menu("Import...").click()
+ bot.shell("Import").activate()
+ bot.waitUntil(Conditions.shellIsActive("Import"))
+ bot.tree().expandNode("General").select("Projects from Folder or Archive")
+ bot.button("Next >").click()
+ bot.comboBoxWithLabel("Import source:").setText(projectDir.canonicalPath)
+ bot.button(IDialogConstants.FINISH_LABEL).click()
+ }
+
+ private void waitForImportJobsToFinish() {
+ def jobFamily = Class.forName("org.eclipse.ui.internal.wizards.datatransfer.SmartImportJob")
+ Job.getJobManager().join(jobFamily, null)
+ }
+
class FaultyWorkspaceOperations {
@Delegate WorkspaceOperations delegate = CorePlugin.workspaceOperations()
diff --git a/org.eclipse.buildship.ui/src/main/java/org/eclipse/buildship/ui/internal/project/GradleProjectConfigurator.java b/org.eclipse.buildship.ui/src/main/java/org/eclipse/buildship/ui/internal/project/GradleProjectConfigurator.java
index a4dbaf223..588100b71 100644
--- a/org.eclipse.buildship.ui/src/main/java/org/eclipse/buildship/ui/internal/project/GradleProjectConfigurator.java
+++ b/org.eclipse.buildship.ui/src/main/java/org/eclipse/buildship/ui/internal/project/GradleProjectConfigurator.java
@@ -78,7 +78,8 @@ private boolean isGradleRoot(File root) {
@Override
public boolean shouldBeAnEclipseProject(IContainer container, IProgressMonitor monitor) {
- return false;
+ IPath location = container.getLocation();
+ return location != null && isGradleRoot(location.toFile());
}
@Override
@@ -88,11 +89,7 @@ public Set getFoldersToIgnore(IProject project, IProgressMonitor monito
@Override
public boolean canConfigure(IProject project, Set ignoredPaths, IProgressMonitor monitor) {
- IPath location = project.getLocation();
- if(location != null) {
- return isGradleRoot(location.toFile());
- }
- return false;
+ return shouldBeAnEclipseProject(project, monitor);
}
@Override