Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to rename the project in gradle instead of using folder name?

Tags:

gradle

We would like to have all subprojects be called sdi-xxx and sdi-yyy so when we run gradle eclipse it generates eclipse project names correctly in .project and when we build it creates a jar file with the name sdi-xxxx.jar and sid-yyyy.jar. I have seen this somewhere but for the life of me, I can't find it in the doc(that doc is huge and I know I saw it there somewhere).

thanks, Dean

like image 831
Dean Hiller Avatar asked Jul 17 '12 20:07

Dean Hiller


People also ask

Can I change project name in Android Studio?

First, open the project directory by right-clicking on the project name and click at show in explorer option. Step 2: Close the android studio, and go to the window explorer of the project directory and rename the root folder with a new name.

How do you rename a project in Java?

To rename the project, simply right-click the project and select "Refactor/Rename...". Fill in the new name and click OK.


2 Answers

settings.gradle:

prefixProjectName(rootProject, "sdi-")

def prefixProjectName(project, prefix) {
  project.name = prefix + project.name
  project.children.each { prefixProjectName(it, prefix) }
}
like image 112
Peter Niederwieser Avatar answered Sep 23 '22 23:09

Peter Niederwieser


Based on suggestion of Peter N, I currently have the following in my parent settings.gradle

include 'xxx', 'yyy'
rootProject.children.each { it.name = "sdi-" + it.name }

If you want the name of the root parent used as prefix, you could do

include 'xxx', 'yyy'
rootProject.children.each { it.name = rootProject.name + it.name }
like image 34
roomsg Avatar answered Sep 23 '22 23:09

roomsg