How to rename / move a project in Intellij Idea 12

2019-02-05 13:24发布

问题:

As stated here one can change the name of a project. However, it only changes the name of the project and it will not change the folder structure.

As an example if your project is called sample1 and it resides ~/user1/development/IdeaProjects/sample1, the folder location won't be changed to ~/user1/development/IdeaProjects/sample2 if one changes the project name to sample2.

回答1:

It seems that one has to right click on the project (after following the instructions to rename the Project), then choose Refactor -> Move to relocate project to the new location. I didn't find any solution to rename and move a project at once.



回答2:

  1. Close IntelliJ
  2. Rename the folder in Explorer (Windows) / Finder (OSX)
  3. Open IntelliJ
  4. Import Project from Dialog, or File -> Import Project
  5. Select the folder with the new name
  6. Follow the dialogues


回答3:

  1. Right click on project, then Refactor -> Rename... (shift+F6), set desired name
  2. Close IntelliJ
  3. Rename directory in your filesystem to your desired name
  4. In startup dialog select Open (or File -> Open... in main window)
  5. Please select renamed project directory

Enjoy, it work's for me!



回答4:

If it is a gradle project, instead of renaming it using Refactor->Rename :

  • set the rootProject.name variable in the settings.gradle file to the new project name.
  • reimport the project. Hit the 'Refresh all Gradle Projects' button in the Gradle Tool Window.

Then follow steps 2 to 5 in @Dawid's answer.

To remove the old project from IntelliJ's list of managed projects:

  • select File->Open Recent->Manage Projects..
  • click the 'x' next to the old project name


回答5:

After renaming the project folder of a Kotlin project in IntelliJ, using the Import Project option as suggested in the other answers created module related problems for me. I was not able to select Main class in the Run dialogue. To solve this, I used Create New Project option. It doesn't delete your project files.

So to rename the folder, first create a copy of your project for safety and then follow these steps:

  1. Close IntelliJ.
  2. Go to file explorer and manually rename the folder.
  3. Open IntelliJ.
  4. Choose the option Create New Project
  5. Select your desired language/framework e.g. Kotlin, click Next
  6. For Project Name, specify your desired project name. Maybe same as folder name.
  7. For Project Location, choose the folder that you manually renamed.
  8. Click Finish, IntelliJ will ask if you want to overwrite .idea and .iml files. Click Yes for both.

Hope that helps.



回答6:

click on your project file,which is you want to move and then push F6