Skip to content

Commit 4c0e045

Browse files
snjezargrunber
authored andcommitted
Failed to import a folder with multi gradle projects
Signed-off-by: Snjezana Peco <[email protected]>
1 parent 3a8937a commit 4c0e045

File tree

6 files changed

+46
-0
lines changed

6 files changed

+46
-0
lines changed

org.eclipse.jdt.ls.core/gradle/init/init.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ allprojects {
33
// Add prefix when project name has conflicts with root project name
44
if (project != rootProject && rootProject.name.toLowerCase() == project.name.toLowerCase()) {
55
eclipse.project.name = (rootProject.name + project.path).replaceAll(':', '-')
6+
} else if (project == rootProject && rootProject.name.toLowerCase() != project.projectDir.name.toLowerCase()) {
7+
eclipse.project.name = (rootProject.name + '-' + project.projectDir.name).replaceAll(':', '-')
68
}
79
})
810
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
plugins {
2+
id 'java'
3+
}
4+
5+
group = 'com.example'
6+
version = '0.0.1-SNAPSHOT'
7+
sourceCompatibility = '17'
8+
9+
repositories {
10+
mavenCentral()
11+
}
12+
13+
dependencies {
14+
15+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rootProject.name = 'rest-service'
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
plugins {
2+
id 'java'
3+
}
4+
5+
group = 'com.example'
6+
version = '0.0.1-SNAPSHOT'
7+
sourceCompatibility = '17'
8+
9+
repositories {
10+
mavenCentral()
11+
}
12+
13+
dependencies {
14+
15+
}
16+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rootProject.name = 'rest-service'

org.eclipse.jdt.ls.tests/src/org/eclipse/jdt/ls/core/internal/managers/GradleProjectImporterTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,17 @@ public void testNameConflictProject() throws Exception {
636636
assertIsGradleProject(subProject);
637637
}
638638

639+
// https://github.com/eclipse-jdtls/eclipse.jdt.ls/issues/1743
640+
@Test
641+
public void testNameConflictProject2() throws Exception {
642+
List<IProject> projects = importProjects("gradle/nameconflict2");
643+
assertEquals(2, projects.size());
644+
IProject project1 = WorkspaceHelper.getProject("rest-service-initial");
645+
assertIsGradleProject(project1);
646+
IProject project2 = WorkspaceHelper.getProject("rest-service-complete");
647+
assertIsGradleProject(project2);
648+
}
649+
639650
@Test
640651
public void testAndroidProjectSupport() throws Exception {
641652
try {

0 commit comments

Comments
 (0)