Renaming an IntelliJ IDEA Project

IntelliJ IDEA gives you all kinds of assistance in refactoring and renaming objects, but we want to rename our entire project. And we want to do it leaving no trace of the previous project name in file names, configuration files or in the IDE when we're finished.

For this post, the project is originally named spring-boot-example-wicket and we want to rename it to spring-wicket-bootstrap.

We start by renaming the project in the Project Structure dialog.

We're going to complete the job in bash, so we close IntelliJ and into a terminal session we go!

First let's see what we're dealing with. We go into the project root directory and perform a grep.

$ grep -r 'spring-boot-example-wicket' .

As you can see, we've got “spring-boot-example-wicket” sprinkled everywhere.

One more bash command and the job will be done. The command is below (broken out on two lines for readability.) First a grep to find, then we'll pipe the results to a sed command to replace the string.

$ grep -rl 'spring-boot-example-wicket' . |
xargs sed -i 's/spring-boot-example-wicket/spring-wicket-bootstrap/g'

Isn't bash awesome?!

We rename our .IML file to spring-wicket-bootstrap.iml and REEEEEE-LOAD! No trace of the earlier project name, thanks to Linux, shell scripting, and IntelliJ's accommodating refactoring support.

Posted April 03, 2015 12:33 PM EDT

More Like This Post