Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to tell maven where to place the artifacts?

I am running both maven inside the m2eclipse plugin, windows command line and my cygwin command line.

cygwin's bash shell dumps artifacts into the cygwin /home/me/.m2 directory

but m2eclipse & windows shell (on vista) uses /Users/me/Documents/.m2

Is it possible to tell the mvn command to use one central .m2 directory ?

Thanks

like image 592
ashitaka Avatar asked Oct 16 '08 05:10

ashitaka


People also ask

What directory are build artifacts placed in by Maven?

Maven's local repository is a directory on the local machine that stores all the project artifacts. When we execute a Maven build, Maven automatically downloads all the dependency jars into the local repository. Usually, this directory is named . m2.

How does Maven know which repository?

Maven just goes through the list and looks into all the repositories. It is not possible to tie dependencies to special repositories.

What are the Maven coordinates?

Maven coordinates define a set of identifiers which can be used to uniquely identify a project, a dependency, or a plugin in a Maven POM.


2 Answers

Sure, several ways. The most typical is to specify this in your settings.xml file:

  • http://maven.apache.org/settings.html
<settings xmlns="http://maven.apache.org/POM/4.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
                      http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <localRepository>/my/secret/repository</localRepository>
</settings>
like image 64
Alex Miller Avatar answered Oct 20 '22 17:10

Alex Miller


For Cygwin, create a file called ~/.mavenrc and put the following text inside:

MAVEN_OPTS="-Dmaven.repo.local=c:\documents and settings\user\.m2\repository"
export MAVEN_OPTS

Alternatively, you can create the file under /etc/.mavenrc

Another option is to create NTFS junction between .m2 under your windows and your cygwin profile.

like image 43
2 revs Avatar answered Oct 20 '22 17:10

2 revs