Setting up Subversion in IntelliJ IDEA

This tutorial will guide you through setting up IntelliJ IDEA to work with Subversion. The new version of IntelliJ IDEA (version 7) has some remarkable improvements and new features concerning version control.We will start from creating a new project, import it into version control, and then checking it out again. If you want to set up Subversion for an existing project in that has already been imported, you can start at Checking out the Project.

Checking in the Project

The first thing you will need to do, is to create a new project in IntelliJ. For this example I named my project myproject.

Now you need to open the Version Control menu and select Import into Subversion…. Click on the + to add a repository. You will be prompted to enter the location to your Subversion repository. In this example, it will be:

http://localhost/svn

When the repository has been successfully added, right click on the repository. Select New and then Remote Folder…. Enter your project’s name (in this case it will be myproject) and click on OK.

Select the folder you have just created and click on Import. You will be prompted to select the project directory to import into Subversion. Select the base directory of the project you have just created and click on OK. It is always important to add a message when you commit to Subversion as this will help you later on when you need to create patches or revert to a previous version of the project. As my message, I entered initial import:

If you are prompted for a password, enter the username and password you set up when installing Subversion. I always select Save credentials which saves some time in entering your password each time.

As this was the initial import, we need to check it out of version control again to start working on it. When you check it out, IntelliJ will automatically set up the version control for the project. Note that the version control will only be set up with a checked out version and not with the project you have created on your hard drive. This means that any changes you make to the original project (the one we created in the first step) will not be versioned. In the next step we will delete the project that we have created and do a fresh checkout from Subversion. You may also just check it out to a different directory, but this may cause confusion so rather rename the original directory.

Close the project in IntelliJ and delete the project files (myproject is the base directory of the project):

rm -rf [your_project_location]/myproject

Checking out the Project
All the previous steps were necessary only for checking in a new project. If you want to start with an existing project from Subversion, you can follow the following steps:

Create a directory for your project (the project name in this case is myproject):

mkdir [your_project_location]/myproject

In IntelliJ, select Version Control from the menu and select Checkout from Version Control > Subversion. Expand the repository we added in the previous section and select the project directory (in this case myproject). Click on Checkout.

You will be asked to select the directory to where the project should be checked out to. Select the directory we created in the previous step and click on OK. The project will be checked out to the directory you have specified.

You will also be prompted to open the newly checked out project. If you open the project, you will notice a Changes tab at the bottom of the screen. From this tab you can commit your changes to Subversion, view the difference between different versions, add different changelists (handy for special configurations), create patches, revert to specific versions, shelve your changes, etc.

GWTCompiler Memory

I am using IntelliJ IDEA (my IDE of choice) to work on some GWT stuff. I have been noticing some strange “Out of Memory” exceptions when compiling the GWT code into JavaScript, especially when the application starts to get ‘n bit bigger than your normal “Hello World” program. I am working on an application that, at the moment, contains about 40 very detailed forms and more or less 10 000 LoC. It is still very early in the development and thus, the application will grow some more over the next few months.IntelliJ IDEA 6+ by default includes a plugin named GWT Studio. This plugin allows you to specify only three settings at the moment (under Google Web Toolkit in your IDE Settings). You can specify the path to your GWT installation directory, the output style of the JavaScript, and you can choose to run the GWTCompiler when you build your application. I usually deselect this last option as it saves some time when you are running the application frequently (usually when debugging or experimenting with the style). You can then compile the code to JavaScript from the built-in browser by clicking on the “Compile/Browse” toolbar button.

As you may have noticed, the GWT Studio plugin does not provide settings for the GWTCompiler. This means that you cannot increase the memory for the GWTCompiler itself. You can, however, increase the amount of memory available to the JVM when running the application. To do this, enter the following as a “VM parameter” in your “Run/Debug Configurations”:

-Xmx512M

This will increase the memory to 512Mb when running the application and has worked well enough for me. We have also had some success by specifying the amount of memory available to the GWTCompiler by using Ant build scripts (I’ll leave that for another day).

If anyone else has other suggestions, please post them. I hope that in the near future, the GWT Studio plugin will provide more functionality, but as it is at the moment, it has already made my life a whole lot easier.

PS: If someone in the know is reading this, it would also be nice to be able to specify the output path for compiled JavaScript in the GWT settings.