We are trying to use Archiva as a Maven proxy for central and other external repositories and also as a snapshot storage for our artifacts which are automatically built by Hudson from SVN and installed to the snapshot repository.
I can't setup my Maven client to use the internal and snapshots repositories together. My project has some external dependencies (like log4j
) which are downloaded from the Archiva internal repository correctly. Also my project has a dependency to an own project which's artifact is already built and installed to the snapshot repository. However if i try to build the project Maven can't find my snapshot artifact.
My configuration file had originally this setting:
<mirror>
<id>company-internal</id>
<name>Company's Archiva - Internal Repository</name>
<url>http://www.mycompany.hu/archiva/repository/internal</url>
<mirrorOf>*</mirrorOf>
</mirror>
and then i added the following:
<mirror>
<id>company-snapshots</id>
<name>Company Archiva - Snapshots Repository</name>
<url>http://www.mycompany.hu/archiva/repository/snapshots</url>
<mirrorOf>apache.snapshots</mirrorOf>
</mirror>
However Maven doesn't tries to look up the snaphot repository at build.
What did i do wrong? By the way i don't really get the <mirrorOf>
elements purpose. I've tried to replace this at internal mirror settings to central
but this still doesn't fix my problem.
The following configuration worked for me after some trial and error. Here I used the default archiva configuration - internal
to hold releases and snapshots
to hold only the internal snapshots.
Essentially unlike nexus we need two separate <mirror>
and <repository>
declarations - one for the normal artifacts and the other for snapshot artifacts.
<mirrors>
<mirror>
<id>archiva</id>
<mirrorOf>*</mirrorOf>
<url>http://localhost:8080/archiva/repository/internal</url>
</mirror>
<mirror>
<id>snapshots</id>
<mirrorOf>snapshots</mirrorOf>
<url>http://localhost:8080/archiva/repository/snapshots</url>
</mirror>
</mirrors>
<profiles>
<profile>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>internal</id>
<name>Archiva Managed Internal Repository</name>
<url>http://localhost:8080/archiva/repository/internal/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>snapshots</id>
<name>Archiva Managed Internal Repository</name>
<url>http://localhost:8080/archiva/repository/snapshots/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
Through much trial and error I came to a configuration quite similar to Raghuram's. Yet, using archiva, I found one or two things that might still be noteworthy. Also, I used the mirrors in my configuration to be accessed by my projects (set in <distributionManagement/>
in the pom.xml), instead of directly accessing the repositories.
This is the relevant part of my maven settings.xml:
<!-- set up servers to point to mirror, for use in project pom -->
<servers>
<server>
<id>my.snapshots</id> <!-- use name of the mirror here -->
<username>user</username>
<password>pwd</password>
</server>
</servers>
<!-- map mirror names to actual repositories -->
<mirrors>
<!-- leave the default mirror in place -->
<mirror>
<id>archiva.default</id>
<mirrorOf>*</mirrorOf>
<url>http://server:port/archiva/repository/internal/</url>
</mirror>
<!-- enter my own -->
<mirror>
<id>my.snapshots</id>
<mirrorOf>archiva.snapshots</mirrorOf>
<url>http://server:port/archiva/repository/snapshots/</url>
</mirror>
<mirrors>
<!-- activate the repo for artifact downloads by setting profile -->
<profiles>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository> <!-- mirror will be used during runtime instead of this -->
<id>archiva.snapshots</id> <!-- do not use mirror name here -->
<url>http://server:port/archiva/repository/snapshots/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
I found out that I had to give different ids in the <mirrors>
section than in the <profiles>
section, so I seemingly wasn't allowed to give them the same name as Raghuram did.
Now, with the settings.xml in place, I set out to change the <distributionManagement>
section in my project's pom.xml. To be precise, I changed this setting in a pom that is parent to all my projects: It chiefly contains the <distributionManagement>
section and little else. This parent pom is itself deployed to archiva.
This is the relevant section of the parent pom.xml:
<distributionManagement>
<repository>
...
</repository>
<snapshotRepository>
<id>my.snapshots</id>
<name>Archiva Managed Snapshot Repository</name>
<url>http://server:port/archiva/repository/snapshots</url>
<layout>default</layout>
</snapshotRepository>
</distributionManagement>
This kind of streamlined things, and it has, I think, some benefits:
I am now able to build projects depending on my own artifacts (including parent pom), without having either of those artifacts in my local build repository (I wiped my local repository for testing this).
Downloads (the
<dependencies>
sections of the pom.xml) as well as uploads (the<distributionManagement>
sections of the pom.xml) are now handled via the mirrors.
Through much trial and error I too came to a configuration quite similar above one but things didnt workout for me until I did this below configuration. Hence am posting it in an attempt to improve answer if you are using maven with the help of your organisation repository instead of using in your localhost.
This answer is for those who need multiple mirror configurations for multiple repositories maintained b your organisation, then this would serve as an example.
my.snapshots user pwd
<!-- map mirror names to actual repositories -->
<mirrors>
<!-- enter my own -->
<mirror>
<id>my.snapshots</id>
<mirrorOf>archiva.snapshots</mirrorOf> <!-- this name should be the same as configured for the below repository id.>
<url>http://server:port/archiva/repository/snapshots/</url>
</mirror>
<!-- leave the default mirror in place -->
<mirror>
<id>archiva.default</id>
<mirrorOf>central</mirrorOf> < !-- Instead of *, replace it with "central"-->
<url>http://server:port/archiva/repository/internal/</url>
</mirror>
<mirrors>
<!-- activate the repo for artifact downloads by setting profile -->
<profiles>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository> <!-- mirror will be used during runtime instead of this -->
<id>archiva.snapshots</id> <!-- do not use mirror name here -->
<url>http://server:port/archiva/repository/snapshots/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
来源:https://stackoverflow.com/questions/7427831/how-to-setup-archiva-internalsnapshot-repository-for-maven