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.


Sadly not all module types in IntelliJ give you this option, so you might have to live with some .iml files in modules. My freeform Docker project for example, still has a learn_ssh_docker.iml file I can’t move:

But hey, better than nothing right? Still got a cleaner workspace that doesn’t grate with me by having the ‘.idea’ directory there.A case of the 80-20 principle, and all that.


Hope this helped at least some of you, I’ll be referring to it in a few months when I’ve forgotten this. I’m sure! Please feel free to share this article if it helped you.

By James