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 .
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