0

I am trying to start my tests in an environment without an internet connection. To do this, I need to save my dependencies in the project directory and specify Maven for this repository.

I copy repository folder from .m2 to project, write:

<repositories>
    <repository>
        <id>project-repository</id>
        <url>file:${project.basedir}/repository</url>
        <releases>
            <checksumPolicy>ignore</checksumPolicy>
            <enabled>true</enabled>
        </releases>
    </repository>
</repositories>

and hoped that the maven would ignore the local m2 repository. But when I remove all the dependencies from m2, the maven still downloads them from the Internet. If i disconnected - the maven ignores the local repository and does not start.

Could not transfer artifact org.apache.maven.plugins:maven-clean-plugin:pom:2.5 from/to central (https://repo.maven.apache.org/maven2): repo.maven.apache.org: nodename nor servname provided, or not known

How can I tell the maven to work only from the internal repository? Without custom setting.xml, only on *.pom .

Kornext
  • 45
  • 1
  • 9
  • you can once run a "mvn dependency:go-offline" wich will download all dependencies and plugins required. You can copy this one. Then run maven with -o in offline mode so it will not attempt to download anything. But it will need a local repository to work with. – wemu Apr 23 '20 at 10:32
  • Network/Firewall/Proxy issue `nodename nor servname provided, or `... or using an internal repository manager... – khmarbaise Apr 23 '20 at 17:54

1 Answers1

0

Maven is using the values from the settings.xml in {M2_HOME}\conf\settings.xml.

The issues here is that settings.xml allows you to override definitions in pom.xml, not the other way round. So you can override the tag <localRepository> in settings.xml, more on this here. Also This answer in another thread explains why.

The other option is to set the maven local repository on the command line:

mvn clean install -Dmaven.repo.local=repository
Aliaksei Stadnik
  • 1,692
  • 3
  • 15
  • 32