How to set project IDE config in a different directory from project codebase root?

I like to separate the location of my IDE project configuration files/dirs from the actual project source code. The way I used to do it in Eclipse was to locate the workspace config in /home/myuser/dev/ide-conf/myproject and the source code in /home/myuser/dev/project/myproject. That way, the IDE workspace configuration files do not clutter the same directory where the root of the project is for version control exclusion (without explicitly ignoring them) and it just is cleaner.

I tried to do the same in IntelliJ but was not able to. When I created a new project, it only asked me where the project location should be. I was hoping that would be the location where IntelliJ would just store the project configuration (the <MY_PROJECT>.iml file and the .idea directory) but it also situated the src directory there without asking me if I wanted to point to a different source code location.

Is there a way to set project IDE config in a different directory from project codebase root?

2 comments
Comment actions Permalink

Hello.

A couple of notes before answering the main question:
1. It's better to keep project and module configuration files under version control, because they contain definitions meaningful for the whole project team. E.g. library definitions. A few per-person files like workspace.xml are excluded by default.
2. .iml file is not a project config, it's a module config. A project is a unit that can include several modules. If necessary, the documentation is here: http://www.jetbrains.com/idea/help/basic-concepts.html

So, the answer. Yes, it's certainly possible. E.g. from new project wizard. Call New Project, get the wizard. Select Java at left. Next, Next to reach the page with project name / location. Here, for example:
. Project name = project-name.
. Project location = /some/super/path/project-name
Below, in More Settings:
. Module name = project-name
. Content root = /some/super/path/project-name-real-content // This is the key setting.
. Module file location = /some/super/path/project-name
Finish. You get project-name/ directory with config files and project-name-real-content/ directory with work files.

Same way, you can create the project with default settings, and maniplulate modules via Project Structure dialog. You can create many modules, and assign different and multiple content roots to them.

The *content root* of a module is conception you need here, please refer to documentation.

Regards,
Alexander.

0
Comment actions Permalink

Thanks, Alexander.  The reason I like to keep my project/module config outside VC is because not everyone on my team uses IntelliJ so I'd rather spare them of unnecessary items.

1

Please sign in to leave a comment.