Storing .m2/repository in ${user.home} can not be prevented completely (even though the separate store location is specified in maven settings)

Answered

Hello,

I wish not to use my user's home directory to store my projects' dependencies there, I have a separate drive for all the things related to it.

Of course I've immediately set up appropriate settings in Build, Execution, Deployment -> Build Tools -> Maven in my project (changed Local Repository setting to use another drives' folder)

Besides of it I'm using a separate maven installation which also have localRepository instruction with the same folder in settings.xml

Also, I have found the maven installation in IntelliJ IDEA Community Edition 2022.3.1\plugins\maven\ and changes its' settings.xml file, so it uses the same localRepository folder.

And when I use maven configurations (or run it via command line interface) it works as expected.

But when I use built-in configurations (like Kotlin run configuration for main method) which include 'Before Launch - Build' action - it uses the same old ${user.home} and it creates .m2/repository folder there.

I could not found the setting that could prevent it from happening,

Any advices?

Thanks in advance.

0
6 comments

Hi - please share your project and the entire console output of running the built-in Kotlin configuration.

You can upload everything to https://uploads.jetbrains.com and provide the upload id here.

0

Hello,

Upload id: 2022_12_26_2BRB7UYkbDNcLFYAFTFZiw (files: test.zip and 2 more)

Project can be just like any, it is reproducible on a simple Hello World that I've just created (attached too).

run_conf_build.log shows that it uses C:\Users\db-pc\..., even though maven build settings has its repository set to other path.

0
Do you simply run 'Build -> Build Project' to get this output?

Is there an M2_HOME environment variable explicitly configured in your system? (cmd.exe -> "set")
0

I run 'Run - Run 'MainKT' (or any other kotlin class with main method there)

This output is produced when there is no .m2 folder under users' home thus it is downloading dependencies once again and recreate it there.

No, M2_HOME have not been set. I have just tried to configure it and set a path to my standalone maven installation with custom settings.xml, but nothing has been changed.

0

Do you mean the issue is that Kotlin compiler jars are still downloaded into default ~/.m2 directory? Or you have all the dependencies of the project downloaded there?

What value for the MAVEN_REPOSITORY do you have set in Settings (Preferences on macOS) | Appearance & Behavior | Path Variables? Does it help to check it there if it is set to a default ~/.m2 directory?

0

Andrey, thanks a lot for mentioning MAVEN_REPOSITORY setting in Path Variables.

I had to idea it is something like this there and changing it worked for me, no more of .m2/repository in ${user.home} folder.

The issue then can be considered as resolved.

0

Please sign in to leave a comment.