-1

I cannot build the project again on the new machine as I do not have access to the Maven repository, nor do I have the access to the git repository. How would I accomplish this? I would assume that I would only need to copy the project directory along with the c:\users\...\.m2\repository over to the new machine, but I'm sure there is more to it than just these two steps.

Asked another way, the question is: How do I share/host/daisy-chain a private Git repository so that I can easily access it when I'm not on the network?

I copied over my eclipse directory, my .m2 directory, as well as my project directory. I have tons of "Cannot be resolved to a type" errors. Clearly, something is missing here.

Ebony Maw
  • 494
  • 7
  • 20
  • these are mostly what you need to do, given that I assume you have already properly setup your `settings.xml`. Give it a try first and ask here if you encountered any specific problem – Adrian Shum Nov 18 '16 at 01:33
  • what do you mean by saying "cannot build the object again"? what's the error information? – nail fei Nov 18 '16 at 02:40
  • @cainiaofei - Building the project requires access to an internal repository which I do not have access to. i.e. Maven tries to fetch dependencies from an intranet ip address. – Ebony Maw Nov 18 '16 at 15:32
  • What's in `.m2/repository` is portable, you can zip it and copy it on some USB-drive for example that should be all you need –  Nov 18 '16 at 16:38
  • @RC. If the original `.m2/repository` resided under `C:\Users\Ali` and the destination will be under `C:\Users\Shazia` wouldn't I need to make any changes to the pom file, or any other settings? – Ebony Maw Nov 18 '16 at 23:25
  • @AdrianShum I copied the `.m2` repository, my eclipse folder and my project folder. Everything shows up as expected except for many, many "Cannot be resolved to a Type" errors. Clearly, a simple copying over of files does not work. Can you please elaborate on what changes need to be made to this `settings.xml`? Thank you. – Ebony Maw Nov 19 '16 at 00:10

2 Answers2

1

If you copy the USER/.m2/ folder from the machine which you built the project on to the new machine then maven will be able to find the dependencies without going to an external repository.

Eddie Curtis
  • 1,167
  • 6
  • 20
  • I copied over my eclipse folder, along with my project folder, and also my .m2 repository in an effort to replicate the same environment on another machine. I now have tons of "cannot be resolved to a type" errors. Clearly, something is missing. – Ebony Maw Nov 19 '16 at 00:18
1

reconfigure repository tag in your pom.xml like this

<repositories>
    <!-- make this repository at the first item in the list -->

    <repository>
        <id>local</id>
        <url>file://[your custom .m2 path]</url>
    </repository>

    <repository>
        <!-- other repositories here -->
    </repository>

</repositories>
phuong
  • 206
  • 4
  • 4