You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Java House <ja...@gmail.com> on 2012/11/06 20:24:19 UTC

.m2 location

Hello

I need to define another location for the .m2 folder.
My problem is that we are having network home directories. As a result the
.m2 folder is placed automatically on the network drive which is never
available when you are offline.
In addition to that slow network conditions makes its access very slow.

I am searching for days for a solution and as it appears several other
people on the net without success.
setting the MAVEN_OPTS to -Duser.home=c:\dev
does nothing.

I have even tryed to start it with a bat file so that I set variables for
my home directory somewhere else but without any succes.
It seems as the location of the .m2 is hardcoded.

Is there anyone who has solved the problem?

Please help

Re: .m2 location

Posted by John Prystash <st...@yahoo.com>.

If it helps with the issues you are running into, in addition to using --settings to define the location of your settings, you can also set your local repository location with the maven.repo.local property:

> mvn -Dmaven.repo.local=/tmp/repository install


________________________________
 From: Barrie Treloar <ba...@gmail.com>
To: Maven Users List <us...@maven.apache.org> 
Sent: Tuesday, November 6, 2012 6:51 PM
Subject: Re: .m2 location
 
On Wed, Nov 7, 2012 at 5:54 AM, Java House <ja...@gmail.com> wrote:

> Hello
>
> I need to define another location for the .m2 folder.
> My problem is that we are having network home directories. As a result the
> .m2 folder is placed automatically on the network drive which is never
> available when you are offline.
> In addition to that slow network conditions makes its access very slow.
>
> I am searching for days for a solution and as it appears several other
> people on the net without success.
> setting the MAVEN_OPTS to -Duser.home=c:\dev
> does nothing.
>
> I have even tryed to start it with a bat file so that I set variables for
> my home directory somewhere else but without any succes.
> It seems as the location of the .m2 is hardcoded.
>
> Is there anyone who has solved the problem?
>
> Please help
>

http://lmgtfy.com/?q=maven+new+.m2+location

The very first link http://maven.apache.org/settings.html shows you how to
set where the localRepository.

Since you also want your settings.xml file to be available offline you will
need to specify that to maven too.

mvn -h

shows you the options, you want --settings option

Unfortunately you can't set that in MAVEN_OPTS as the mvn.bat file passes
those options to the java executable.

@REM Start MAVEN2
:runm2
set CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
%MAVEN_JAVA_EXE% %MAVEN_OPTS% -classpath %CLASSWORLDS_JAR%
"-Dclassworlds.conf=%M2_HOME%\bin\m2.conf" "-Dmaven.home=%M2_HOME%"
%CLASSWORLDS_LAUNCHER% %MAVEN_CMD_LINE_ARGS%
if ERRORLEVEL 1 goto error
goto end

Your choices are:
* hack the bat file for all developers
* use doskey mvn=mvn.bat --settings C:\settings.xml (no idea how you get
this to be made permanent)
* stop using network drives for local user directories

Re: .m2 location

Posted by Barrie Treloar <ba...@gmail.com>.
On Wed, Nov 7, 2012 at 5:54 AM, Java House <ja...@gmail.com> wrote:

> Hello
>
> I need to define another location for the .m2 folder.
> My problem is that we are having network home directories. As a result the
> .m2 folder is placed automatically on the network drive which is never
> available when you are offline.
> In addition to that slow network conditions makes its access very slow.
>
> I am searching for days for a solution and as it appears several other
> people on the net without success.
> setting the MAVEN_OPTS to -Duser.home=c:\dev
> does nothing.
>
> I have even tryed to start it with a bat file so that I set variables for
> my home directory somewhere else but without any succes.
> It seems as the location of the .m2 is hardcoded.
>
> Is there anyone who has solved the problem?
>
> Please help
>

http://lmgtfy.com/?q=maven+new+.m2+location

The very first link http://maven.apache.org/settings.html shows you how to
set where the localRepository.

Since you also want your settings.xml file to be available offline you will
need to specify that to maven too.

mvn -h

shows you the options, you want --settings option

Unfortunately you can't set that in MAVEN_OPTS as the mvn.bat file passes
those options to the java executable.

@REM Start MAVEN2
:runm2
set CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
%MAVEN_JAVA_EXE% %MAVEN_OPTS% -classpath %CLASSWORLDS_JAR%
"-Dclassworlds.conf=%M2_HOME%\bin\m2.conf" "-Dmaven.home=%M2_HOME%"
%CLASSWORLDS_LAUNCHER% %MAVEN_CMD_LINE_ARGS%
if ERRORLEVEL 1 goto error
goto end

Your choices are:
* hack the bat file for all developers
* use doskey mvn=mvn.bat --settings C:\settings.xml (no idea how you get
this to be made permanent)
* stop using network drives for local user directories