Because of reasons, I need to have a local, not-connected-to-anything copy of all dependencies for a certain app. I have a script that downloads those dependencies and stores them in a structure not unlike a local Maven repository (like in .m2/repository
).
Now, I want to make a sort of "dummy app" that checks my codebase against that repository, looking only there and nowhere else. The dummy app contains the real app's pom.xml files, and a few Java files so that (among other things) the Swagger generator is actually triggered.
In my the parent pom.xml
of the dummy, I added
<repositories>
<repository>
<id>central</id>
<url>http://repo1.maven.org/maven2</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>downloaded</id>
<name>Downloaded dependencies</name>
<url>file://path/to/local/repository</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://repo1.maven.org/maven2</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>downloaded</id>
<name>Downloaded dependencies</name>
<url>file://path/to/local/repository</url>
</pluginRepository>
</pluginRepositories>
This doesn't work, because the local repo is empty and the dummy app build (mvn package
) still succeeds.
I also tried adding a settings.xml
to the dummy app, but that doesn't seem to do anything either:
<settings>
<localRepository>path/to/local/repository</localRepository>
</settings>
For reference, I've done the same thing in Gradle, and that works fine:
in settings.gradle
pluginManagement {
repositories {
maven {
url 'path/to/local/repository'
}
}
}
and in build.gradle
buildscript {
repositories {
maven {
name 'local'
url "file://path/to/local/repository"
}
}
}
allprojects {
repositories {
maven {
name 'local'
url "file://path/to/local/repository"
}
}
}
So, how do I achieve the above Gradle config using only Maven?
CodePudding user response:
Have you tried to use mvn -Dmaven.repo.local=<location>
which defines the location of the local cache via command line option.