3

I just want to know if there is an easier way to change the build path of the .jar files and other libraries in Eclipse when I import a project from another computer?

Lets say my path to the m2 file is: C:\Users\Bill\.m2\repository but the same path of another computer is C:\Users\Steve\.m2\repository. So now when I import a maven project from Bills computer to Steves I have like 50+ missing jar files (such as this one C:\Users\Bill\.m2\repository\jtidy\jtidy\4aug2000r7-dev) just because the path is stuck at Bill and I have to manually have to change all of those to \Steve.

My question is, is there a faster way to do this or a way to prevent this from happening in the first place?

Vrankela
  • 1,162
  • 3
  • 16
  • 39
  • Are those computers connected in a network? – Grim May 20 '15 at 09:25
  • .m2 is maven local repo, every maven installation have a settings.xml where you can define the location of .m2 repo – Fran Montero May 20 '15 at 09:26
  • run mvn clean install. it will fetch missing jar to his local machine – Sasikumar Murugesan May 20 '15 at 09:29
  • How has Bill got the Maven artefacts into his repository? Has he built them from his local projects? Do you have the same projects? Then just build them locally, they will be installed into *your* local repository and your project will see them. – Honza Zidek May 20 '15 at 09:39
  • @PeterRader yes they are – Vrankela May 20 '15 at 10:01
  • @HonzaZidek both bill and steve have the exact same project, but when I copy the project from bills to steves machine the project is still looking for the .jar files in the /bill/.m2....... instead of /steve/.mv2. Both Bill and Steve have the necessary .jar. I am currently solving the problem by manually pointing each and every .jar path from a non existing /Bill/.m2 path to the existing /Steve/.m2 path – Vrankela May 20 '15 at 10:05
  • @SasikumarMurugesan the .jar files are there, they are just pointing to the wrong directory because the project is imported from a previous computer where the file path is slightly different – Vrankela May 20 '15 at 10:11
  • Remove the local repository completely from pom. It will poit correctly to your default local repo – Honza Zidek May 20 '15 at 10:16
  • @HonzaZidek How do I do that? – Vrankela May 20 '15 at 10:18
  • Most probably in your `pom.xml` file there is something like that: `C:\Users\Bill\.m2\repository`. Remove that completely. – Honza Zidek May 20 '15 at 10:40
  • @HonzaZidek I was searching for that and couldn't find it, that why I asked how do I do it. – Vrankela May 20 '15 at 10:43

2 Answers2

1

First make sure that your Eclipse is having the maven plugin. If not please install that from Eclipse Marketplace

You can set the Local Repository in your local machine Eclipse from:

Window -> Preference -> Maven -> User Settings -> 

Then you can put your user setting and you can re index the path where you want to put your JAR files

Local repository should be .../.m2/repository and reindex the repository. User settings can be .../.m2/settings.xml

Estimate
  • 1,421
  • 1
  • 18
  • 31
  • User settings file doesn't exist – Vrankela May 20 '15 at 10:09
  • You need to put a settings.xml file. Please refer https://maven.apache.org/settings.html. I put the setting file in the path .../.m2. – Estimate May 20 '15 at 10:26
  • yeah I just found that as well, but I dont know what to do with it - I copied the first part and I am not sure if I should edit something there? – Vrankela May 20 '15 at 10:35
  • If you already have something in the setting.xml then i don't think that you need to edit. For me I'm downloading jars from internal server. So I'm having the settings.file with the content of internal-repository http://.../repository/internal/ *. But this is user specific. You can edit your changes as you preferred. But if you already have this then u don't need but just add the file. – Estimate May 20 '15 at 10:43
1

If you have files that are in .m2/repository, then you're running a Maven project and should be using m2eclipse to manage classpaths and similar configuration.

chrylis -cautiouslyoptimistic-
  • 75,269
  • 21
  • 115
  • 152