Reputation: 1340
I have a project that it has a directory named repo
in which artifacts are stored. When I build it with maven, nexus says that the dependencies cannot be resolved; and when I remove nexus from maven settings, it can find the artifacts.
I want maven to look into this directory before asking nexus, or sth like that, so that I can build this without diactivating nexus every time. How can I do that? My current maven settings (~/.m2/settings.xml):
<settings>
<localRepository>/home/a/.m2/repository</localRepository>
<mirrors>
<mirror>
<!--This sends everything else to /public -->
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<!--<url>http://nexus.yourdomain.nl/content/groups/public</url> -->
<url>http://localhost:8081/nexus/content/groups/public</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<!--Enable snapshots for the built in central repo to direct -->
<!--all requests to nexus via the mirror -->
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
<!-- if you want to be able to switch to the defaultprofile profile put this in the active profile -->
<profile>
<id>defaultprofile</id>
<repositories>
<repository>
<id>maven.default</id>
<name>default maven repository</name>
<url>http://repo1.maven.org/maven2</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>maven.snapshot</id>
<name>Maven snapshot repository</name>
<url>http://people.apache.org/repo/m2-snapshot-repository</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles>
<!--make the profile active all the time -->
<activeProfile>defaultprofile</activeProfile>
</activeProfiles>
</settings>
Upvotes: 1
Views: 1350
Reputation: 1340
Nexus website says the mirrorOf pattern of *
causes any repository request to be redirected to this mirror and to your single repository group, which in the example is the public group.
It is possible to use other patterns in the mirrorOf field. A possible valuable setting is to use external:*
. This matches all repositories except those using localhost or file based repositories.
Putting external:*
instead of *
solved my problem.
Update:
Second Solution: Pass this option to maven works fine too:
mvn -Dmaven.repo.local=/path/to/repo
Upvotes: 3