Windows 10 WSL - Maven config

Viewed 8251

Is there a way to configure Windows Maven and WSL Maven to use the same .m2/repository and settings.xml?

In my .bashrc from WSL I added the M2_HOME to use the same installation that Windows 10 use:

.bashrc:

export M2_HOME=/mnt/c/development/maven

Windows PATH:

C:\development\maven

But when I execute mvn clean install on Windows Bash, a .m2 folder is created in ~/.m2 (WSL folder system).

2 Answers

Found a possible solution.

I created a symbolic link from ~/.m2 to /mnt/c/Users/<username/.m2

Command: $ ln -s /mnt/c/Users/<username>/.m2 ~/.m2

Until the moment is working fine.

Just an amendment to @Vitor 's response: When you created the symbolic link once, the next time (e.g. if you specified a wrong directory and want to retry) you cannot create it and you will get failed to create a symbolic link: file exists error.

As a workaround when you want to recreate the symbolic link, you can use $ ln -f -s /mnt/c/Users/<username>/.m2 ~/.m2

[OPTION] 
-f, --force
          remove existing destination files
Related