This annoyed me enough that I wanted to write an article about it. Mostly it’s because I wanted to help others, and also to have a reminder for myself on how to do this.

I was trying to get IntelliJ metadata stored outside of the content roots (i.e. the source code that can be checked out and run regardless of the IDE). This is similar to the workspace concept in Eclipse. There are plenty of people that agree with me given this question on StackOverflow, and on JetBrains site itself – this request has been going for some time.

Also, whilst I do have the ability to ignore metadata files in version control, I don’t want them polluting my workspace – just a matter of personal preference.

Since the suggested workarounds I could find were a bit outdated (you can see how long this feature request as been around for), I had to experiment myself.

Here are the steps I took.

Launch Intellij ‘fresh’

Create a brand new project.

I choose a Java project, because it allows me to specify a content root that is seperate from the metadata location. Here I have a project for learning aws app mesh. The content lives in ‘IdeaProjects’, but the metadata in ‘intellij_metadata’.

So far so good – a project without the pesky ‘.idea’ folder

Script up your workspace launch

In this instance I’ve created a util script that takes into account the metadata folder I created in the previous steps.

The content root will be found based on this this metadata when you launch from it.

The content root will be found based on this this metadata, i.e launching gives us just the content root, as before.

This image has an empty alt attribute; its file name is image-2.png

Add any additional modules

Maven and Gradle allow you to create modules that store the .iml outside of the content root. This contribution on StackOverflow helpfully explains that, and I’ve included the image from their contribution.


If you’re using a non java option, you can still work with that too. I’ll cover that next.