How to import projects with same name?

Hi Guys,

My team just moves to Gradle from Maven, so I’m new to Gradle.

I’m using the latest buildship plugin in my Eclipse Mars2, trying to import projects with same name from svn repo like:
http://host1.svnrepo.com/project/ist/FUN
http://host1.svnrepo.com/project/uat/FUN

How can I import both? Say I already imported ist’s FUN into Eclipse, If I import uat’s FUN project then, it will be failed, and give me exception which indicates the project with same name ‘FUN’ already exists.

Maven plugin has an option to rename the imported project, but I cannot find the same for Gradle. Any help/hint would be appreciate.

You can programmatically set the eclipse project name.

https://docs.gradle.org/current/dsl/org.gradle.plugins.ide.eclipse.model.EclipseProject.html

Assuming a multi-module build, you could add the following to the root build.gradle

String prefix = projectDir.parentFile.name
allprojects { p ->
   apply plugin: 'eclipse' 
   eclipse.project.name = "${prefix}-${p.name}"
}
1 Like

Many thanks. It works like a charm.