1

I'm trying to generate an offline local maven repository folder for my project, which includes both remote dependencies, and a few dependencies to local projects.

When I run mvn install in my project, Maven succeeds in resolving both remote and local dependencies. Now, in order to have all dependencies available offline, I want to have a local repository folder in my project. Using the command mvn dependency:go-offline -D"maven.repo.local"="./maven-local" I try to achieve this. However, Maven manages to place all remote dependencies in the local folder, but not the local dependencies to my local projects (which have been installed already).

The error I get is:

Failed to execute goal on project genericgateway: Could not resolve dependencies for project org.my:ownproject:jar:1.0.1: The following artifacts could not be resolved: org.my:otherproject:jar:1.0.1: Could not find artifact org.my:otherproject:jar:1.0.1 in central (https://repo.maven.apache.org/maven2)

How can I tell Maven to also search in my local ~/.m2 repository for these projects?

Amira Bedhiafi
  • 8,088
  • 6
  • 24
  • 60
aeror_
  • 49
  • 7

1 Answers1

0

Basically you should work with one local repository for compilation of maven project.

So, you have three options:

Option 1 Don't specify a local repo while executing mvn dependency:go-offline. Let it download into you regular local repo (~/.m2 by default) Install the local artifact there as well and compile against this repository.

Option 2 Compile local projects into ./maven-local with maven.repo.local flag as you did. The point is that that both local and downloaded artifacts will be in the same repo.

If you want, you can configure a local repo in the settings.xml (see this answer

Option 3

IMO Overkill for local dev env, but still...

If you absolutely have to separate the repositories you can install a software like Nexus/Artifactory locally - it can provide a flexible repository management and then configure different repositories, but then again, it will be like a remote repo residing in your local PC, maven will create a local cache with both local and remote artifacts, still in the same repo.

Mark Bramnik
  • 39,963
  • 4
  • 57
  • 97