How do I download a plugin from a remote Archiva repository?
Author: Deron Eriksson
Description: This maven tutorial describes how to download a plugin from a remote Archiva repository.
Tutorial created using: Windows XP || JDK 1.5.0_09 || Eclipse Web Tools Platform 2.0 (Eclipse 3.3.0)


In another tutorial, I deployed a snapshot of a mavenSW plugin called "maven-howdy-plugin" to a remote ArchivaS maven repository on my intranet so that other developers could use the plugin. Now, I'd like to use that plugin on a project called "aproject" on another machine, so I'd like to download it.

In the "aproject" project's pom.xml file, I need to specify the location of the plugin repository. It's located in the Archiva snapshots repository, so I'll include a reference to this repository in my pom.xml file. In addition, I added a reference to the "maven-howdy-plugin" plugin in the pom.xml file. (I also associated the "howdy-world" goal with the validate phase of the maven default lifecycle for this project).

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>com.maventest</groupId>
	<artifactId>aproject</artifactId>
	<packaging>jar</packaging>
	<version>1.0-SNAPSHOT</version>
	<name>aproject</name>
	<url>http://maven.apache.org</url>
	<dependencies>
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>3.8.1</version>
			<scope>test</scope>
		</dependency>
	</dependencies>
	<build>
		<plugins>
			<plugin>
				<groupId>com.maventest</groupId>
				<artifactId>maven-howdy-plugin</artifactId>
				<version>1.0-SNAPSHOT</version>
				<executions>
					<execution>
						<goals>
							<goal>howdy-world</goal>
						</goals>
						<phase>validate</phase>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>
	<pluginRepositories>
		<pluginRepository>
			<id>archiva.snapshots</id>
			<url>http://192.168.1.7:8081/archiva/repository/snapshots</url>
		</pluginRepository>
	</pluginRepositories>
</project>

Now, I'll perform a "mvn clean" on the "aproject" project.

Executing 'mvn clean' on 'aproject'

The console output of the "mvn clean" command is shown below. The "maven-howdy-plugin" 1.0-SNAPSHOT jarW file isn't in the local maven repository on this computer, so it gets downloaded to the local maven repository, as you can see from the console output.

Console output from 'mvn clean' on 'aproject' project

[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building aproject
[INFO]    task-segment: [clean]
[INFO] ------------------------------------------------------------------------
[INFO] artifact org.apache.maven.plugins:maven-clean-plugin: checking for updates from archiva.snapshots
[INFO] snapshot com.maventest:maven-howdy-plugin:1.0-SNAPSHOT: checking for updates from archiva.snapshots
Downloading: http://192.168.1.7:8081/archiva/repository/snapshots/com/maventest/maven-howdy-plugin/1.0-SNAPSHOT/maven-howdy-plugin-1.0-20080219.015105-1.pom
1/1K
1K downloaded
Downloading: http://192.168.1.7:8081/archiva/repository/snapshots/com/maventest/maven-howdy-plugin/1.0-SNAPSHOT/maven-howdy-plugin-1.0-20080219.015105-1.jar
2/2K
2K downloaded
[INFO] [clean:clean]
[INFO] Deleting directory C:\projects\workspace\aproject\target
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Mon Feb 18 18:39:02 PST 2008
[INFO] Final Memory: 3M/5M
[INFO] ------------------------------------------------------------------------

That's all there is to it! We needed to specify the plugin repository in our pom.xml file. In addition, we needed to specify the desired plugin in the pom.xml file. When we executed a "mvn clean" on the project, maven saw the reference to the plugin, so it downloaded it from the specified plugin repository.

For further information, you may want to investigate some of the options that can be specified in the plugin repository reference in pom.xml, such as the differences between enabling "releases" and "snapshots".