How to integrate between Apache Archiva and Maven
Apache Archiva is a great remote repository manager. It’s very important to implement it especially in large project, which involve many developers using same dependency libraries.
Why you need Apache Archiva?
Q : Let’s assume a new team member just joined your team, and for sure the new member will take a very long time in the first time building process because it’s required to download the dependency libraries from Maven central repository.
A : With help of Apache Archiva, you have own central repository in your team, you are connect to your own repository instead of Maven central repository. It cut off the long first time building process and good in centralize the dependency libraries in your project.
Integration
The Apache Archiva and Maven integration is quite straightforward is easy
1. Install Apache Archiva
Install the Apache Archiva
2. Default configuration
Two default remote repositories are configure automatically.
Basically, all the default settings are enough for the Maven integration.
3. Add mirror setting
Locale the Maven’s configuration file, “{mavendir}/conf/settings.xml “, update the mirror setting to your Apache Archiva repository.
<mirrors> <!-- mirror | Specifies a repository mirror site to use instead of a given repository. The repository that | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used | for inheritance and direct lookup purposes, and must be unique across the set of mirrors. | <mirror> <id>mirrorId</id> <mirrorOf>repositoryId</mirrorOf> <name>Human Readable Name for this Mirror.</name> <url>http://my.repository.com/repo/path</url> </mirror> --> <mirror> <id>internal</id> <name>Proxy Cache - Internal Repository</name> <url>http://localhost:8080/archiva/repository/internal</url> <mirrorOf>*</mirrorOf> </mirror> </mirrors>
* url tag – It is your Archiva remote repository sever address.
* mirrorOf tag – mirror everything
P.S More detail about Maven mirror settings
4. Done
The different!?
Here’s the different before and after the Apache Archiva integration.
Before integrate Archive
All the dependency libraries are download from Maven central repository.
E:\project\projectname>mvn compile [INFO] Scanning for projects... [INFO] ------------------------------------------------------------------------ [INFO] Building projectname Maven Webapp [INFO] task-segment: [compile] [INFO] ------------------------------------------------------------------------ [INFO] [resources:resources {execution: default-resources}] [INFO] Copying 0 resource Downloading: http://repo1.maven.org/maven2/log4j/log4j/1.2.14/log4j-1.2.14.pom Downloading: http://repo1.maven.org/maven2/log4j/log4j/1.2.14/log4j-1.2.14.jar [INFO] [compiler:compile {execution: default-compile}]
After integrated Archive
All the dependency libraries are download from your own remote repository (Archiva) server.
E:\project\projectname>mvn compile [INFO] Scanning for projects... [INFO] ------------------------------------------------------------------------ [INFO] Building projectname Maven Webapp [INFO] task-segment: [compile] [INFO] ------------------------------------------------------------------------ [INFO] [resources:resources {execution: default-resources}] [INFO] Copying 0 resource Downloading: http://localhost:8888/archiva/repository/internal/log4j/log4j/1.2.14/log4j-1.2.14.pom 2K downloaded (log4j-1.2.14.pom) Downloading: http://localhost:8888/archiva/repository/internal/log4j/log4j/1.2.14/log4j-1.2.14.jar 358K downloaded (log4j-1.2.14.jar) [INFO] [compiler:compile {execution: default-compile}]



[...] Integrate Apache Archiva and Maven A guide to integrate Maven and Apache Archiva together. [...]
[...] Make sure you configured the Maven mirror setting [...]