3

I need to hand over a project to a third person. The project uses Maven for dependency management and we have a Nexus repository manager installed.

I thought it would be easy to generate a repository with all dependencies needed by the project using the dependency:go-offline plugin/goal like

mvn dependency:go-offline -Dmaven.repo.local=c:/handOver/.m2/repository

The repository is created as expected by this command. I copied this repository to the target machine and set the localRepository (settings.xml) to the repository folder.

Trying to build the project on the target machine unfortunatly fails. The build process complains about missing artifacts although they are at the path that can be found in the maven logs (even using the -o / offline switch).

There still seems to be a relation to our Nexus server. We therefore deleted all _maven.repositories files in the repository but that does not helped either.

I wonder if my approach of handing over a repository could work and what I did wrong or missed. I fear it has something to do with the remote repository settings.

It would be a great help if anybody could point me to the right direction on how to hand over a maven repository to someone else.


from the logs

(the jar that should be resolved can be found under the logged path (C:\handOver.m2\repository{myPathToJar}) but can not be resolved at the end.

[DEBUG] Using local repository at C:\handOver\.m2\repository
...
[DEBUG] Verifying availability of C:\handOver\.m2\repository\{myPathToJar}
from [central (https://repo.maven.apache.org/maven2, default, releases)]
...
[ERROR] Failed to execute goal on project {myProject}: Could not resolve dependencies for project {myProject}: 
The following artifacts could not be resolved: {myDependency}: Cannot access central (https://repo.maven.
apache.org/maven2) in offline mode and the artifact {myDependency} has not been downloaded from it be
fore. -> [Help 1]
FrVaBe
  • 47,963
  • 16
  • 124
  • 157
  • 1
    Are you saying that even with `-o` option, Maven tries to download an artifact that is present in the local repo? Are you sure the local repo Mavenn is using is the correct one? – Tunaki Oct 21 '15 at 10:36
  • 1
    @Tunaki I think it is no download attempt but the file can not be resolved although it is there. The origin of the file is not Maven Central but our internal Release Repository configured inside Nexus. I do not know why 'central' appears in the logs. Probably because this is the default repository on the target machine. – FrVaBe Oct 21 '15 at 11:16
  • This [answer](http://stackoverflow.com/a/16870552/367285) seems to be the hint in the right direction. Using the `-llr` (legacy-local-repository) flag to avoid the consideration of the artifact source looks promising. – FrVaBe Oct 21 '15 at 11:48

1 Answers1

1

dependency:go-offline misses some transitive dependencies.

What works best is mvn -Dmaven.repo.local=local-repo clean install. Then you can zip the folder local-repo to someone else and they will be able to run mvn -o clean install after having unzipped the local-repo.zip to $HOME/.m2/repository.

If you want them to be able to run other goals, just substitute "clean install".

Maddin
  • 957
  • 1
  • 11
  • 21