简体   繁体   中英

Renaming Gradle Project in Netbeans

I have a Gradle-root-project that I would like to rename (I'm using Netbeans 8.0.2) and I can't find an option to do so. With a Java project it was as simple as right click project -> rename.

Is there a way to rename a Gradle project? (Without causing issues with the classes therein)

  1. Access the build.gradle file and you can change project file name to be name = 'newName'
  2. Access the settings.gradle and change rootProject.name as rootProject.name = 'NewName'
  3. Then try checking the name changed by running $ gradle -r | grep name $ gradle -r | grep name

My settings.gradle had only one line and the build.gradle didn't have a name parameter, so this is what I did:

  1. Changed rootProject.name = 'NewName' in settings.gradle
  2. Refactored the main class name (the class that contains main()) to the new name public class NewName .
  3. Changed to the new name, the manifest attributes and mainClass values in build.gradle :

    manifest { attributes 'Main-Class': 'com.abc.NewName' }

and

if (!hasProperty('mainClass')) {
    ext.mainClass = 'com.abc.NewName'
}

edit settings.gradle file:

 rootProject.name = 'newNameHere'

then right click ( on the project gradle icon ) > Reload Project

NOTE: if you have errors in your config or files name wont be changed

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM