0

There is problem with local maven repository. I want to change maven and local repository path. I use Intellij and did it in setting->build,execution,deployment->maven, just changed here user settings file and local_repository then choose override and apply.

If I put mvn install there is still default path (/.m2/repository/). How is it possible do solve this problem?

systemhalted
  • 818
  • 9
  • 24
barmi
  • 665
  • 6
  • 22
  • What does your questino have to do with Git? If nothing, please remove the tag. And where do you execute `mvn install`? On the commandline? If yes, why should changing settings in IJ influence `mvn` that is run on the commandline? – Vampire Dec 16 '16 at 15:18
  • @barmi From where are you running mvn install? Using Maven view or command line? – systemhalted Dec 16 '16 at 15:27

3 Answers3

1

Why don't you try to update the local repo path in the settings.xml inside 'conf' directory with a text editor?

<localRepository>{your-new-path}</localRepository> <!-- goes inside the settings tag -->

Once done, make sure that the maven location pointed to by MAVEN_HOME and the settings file you have configured are one and the same.

Prathap
  • 178
  • 1
  • 1
  • 9
  • I need to use settings.xml file from another path, how can I do it? – barmi Dec 19 '16 at 08:13
  • 'settings.xml file from another path' as in from another maven installation? Are you able to perform maven operations (such as mvn --version) from the command line? That's the location where you would find the "conf" directory which contains the settings.xml for the maven installed in your machine; which points to the repo path as well. – Prathap Dec 19 '16 at 10:32
0

Overrriding Local Repository preference in Intellij doesn't change the system-level settings. They only resonate well inside Intellij. You will have to use Maven Projects view inside intellij and run the maven goals from there for this setting to take effect. If you run from inside a terminal, whether from inside Intellij or outside it, you will have to explicitly specify the loca repo as an argument to the command. Check this: Can I add maven repositories in the command line?

Community
  • 1
  • 1
systemhalted
  • 818
  • 9
  • 24
  • probably `mvn packageb -Dmaven.repo.local="c:\test\repo" install` works fine(change local repo) but something is wrong with settings.xml (is incorrect) is there any way to set path for settings file in command line? – barmi Dec 19 '16 at 08:11
-1

It looks like you have only changed the maven path and not the repository path.

Your repository location is specified in the .m2/conf/settings.xml file. Once you change your MAVEN_HOME in your classpath to point to the right maven location, you should also change the repository location in the settings xml.

Hope this helps.

javaDeveloper
  • 1,403
  • 3
  • 28
  • 42
  • settings.xml uses MAVEN_HOME as repo lopcation (I mean file://${env.MAVEN_HOME}/repository) – barmi Dec 16 '16 at 15:22