Get your CodeRanch badge!*
The moose likes Ant, Maven and Other Build Tools and the fly likes Change maven local repository in Sonatype plug for eclipse Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Change maven local repository in Sonatype plug for eclipse" Watch "Change maven local repository in Sonatype plug for eclipse" New topic
Author

Change maven local repository in Sonatype plug for eclipse

Oscar G. Rodriguez
Greenhorn

Joined: Nov 05, 2011
Posts: 13
Hi everybody.

I'm trying to change the default location of local repository (~/.m2) to a partition.

First, I added <localRepository>I:\.m2\repository</localRepository> in this file.

I change the settings.xml, pointed by "Global settings for embedded installation" for my modified one.

After this, I pointed in Eclipse > Preferences > Maven > User Settings > Local repository (From merged user and global settings) to my new repository path, and even created a user settings.xml at my new location.

I could achieve this with a external maven (3.0.3v), and I'm using the same settings.xml for the maven embedded (3.0.2v), but it didn't work in eclipse. When I do a maven install goal, my project goes to the default repository ~/.m2

Anybody knows what is wrong?

Thanks

Edit: Well, finally I did it, but I have to add my external maven to Maven > Installations. Isn't there any way to do it without a external Maven?
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2477
    
    7

Welcome to the Ranch, Oscar!


OCUP UML fundamental and ITIL foundation
youtube channel
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5779
    
    7

Not sure exactly what went wrong here. But the final solution of adding your installed copy of Maven to Eclipse and making it the default is really the best way to go. The version embedded in Eclipse is 3.0.2, while 3.0.3 is the latest. By using your installed 3.0.3 version, both Eclipse and the command line will be using the exact same Maven for building.

You should have been able to edit just the ~/.m2/settings.xml file to point to a local repository location, that should work for both the embedded and the external Maven.

I could achieve this with a external maven (3.0.3v), and I'm using the same settings.xml for the maven embedded (3.0.2v), but it didn't work in eclipse.

I am not sure what you mean by this. The embedded Maven settings.xml file is not the same one used by the external Maven, mainly because the M2_HOME location is different for both. The only common settings.xml file between multiple copies of Maven installed on a machine is the ~/.m2/settings.xml file.


JBoss In Action
Oscar G. Rodriguez
Greenhorn

Joined: Nov 05, 2011
Posts: 13
Hi Peter,

thanks for your comment and sorry for my English, it isn`t as good as I'd like.

Well, I've tried to explain that with an external maven installation, I can change the .m2 location, but not from eclipse plugin, even using the same settings.xml.

I change the settings.xml, pointed by "Global settings for embedded installation" for my modified one.


Finally, I add my external maven to eclipse maven plugin installations, and then it works.

I imagine that the settings.xml that the embedded maven uses, can't be modified by pointing to another one from "Global settings for embedded installation"

This is the configuration that works for me, but if I mark the embedded one, it uses the ~/.m2 folder.






 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Change maven local repository in Sonatype plug for eclipse
 
Similar Threads
how to run a project using maven
Unable to change the local repository settings
How to set an output directory
Settings XML file changes
maven / web inf