How do I deploy an artifact to an Archiva repository?
Author: Deron Eriksson
Description: This tutorial describes how to deploy an artifact to an Archiva repository.
Tutorial created using: Windows Vista || JDK 1.6.0_04 || Eclipse Web Tools Platform 2.0.1 (Eclipse 3.3.1) || Tomcat 6.0.14


Page:    1 2 >

In a previous tutorial, we set up a standalone ArchivaS installation, and in another tutorial, we saw how we can use Archiva as a mirror of the central mavenSW repository. Since Archiva is a repository, we can deploy artifacts (jars, wars, ears) to the Archiva repository. This short tutorial will show how we can deploy an artifact snapshot to a standalone Archiva instance using the webdav protocol.

First off, to deploy to Archiva, you need an Archiva user that has the 'Repository Manager - internal' role for deploying to the internal repository of 'Repository Manager - snapshots' to deploy to the snapshots repository. Since I'm not too concerned about security here, I'll just user my superuser 'admin' user.

In my settings.xml file, I create server entries for "archiva.internal" and "archiva.snapshots". I use the username "admin" and password "admin1" for each of these, since this user is a superuser that has both the 'Repository Manager - internal' role and the 'Repository Manager - snapshots' role.

settings.xml entries for Archiva internal and snapshot repositories

		<server>
			<id>archiva.internal</id>
			<username>admin</username>
			<password>admin1</password>
		</server>
		<server>
			<id>archiva.snapshots</id>
			<username>admin</username>
			<password>admin1</password>
		</server>
		

Since I'm deploying using webdav, I added the build extension wagon-webdav to my project's pom.xml. In addition, I added a distributionManagement section where I defined the "archiva.internal" and "archiva.snapshots" repositories. The internal repository holds regular versioned versions of my artifact (ie, built project), such as versions 1.0, 1.1, etc. The snapshots repository holds snapshot versions of my project artifact. Maven will use the server entries we put in our settings.xml file for the name and password to connect to these repositories.

additions to pom.xml

	<build>
...
		<extensions>
			<!-- begin - needed for deploying to repository using webdav -->
			<extension>
				<groupId>org.apache.maven.wagon</groupId>
				<artifactId>wagon-webdav</artifactId>
				<version>1.0-beta-2</version>
			</extension>
			<!-- end - needed for deploying to repository using webdav -->
		</extensions>
	</build>
	<distributionManagement>
		<repository>
			<id>archiva.internal</id>
			<name>Internal Release Repository</name>
			<url>dav:http://192.168.1.7:8081/archiva/repository/internal</url>
		</repository>
		<snapshotRepository>
			<id>archiva.snapshots</id>
			<name>Internal Snapshot Repository</name>
			<url>dav:http://192.168.1.7:8081/archiva/repository/snapshots</url>
		</snapshotRepository>
	</distributionManagement>
	

My project's current version is 1.0-SNAPSHOT, so if I deploy the project, it will go into the snapshots repository. We are ready to go, so I'll perform a "mvn clean deploy" on the project, which generates the following console output:

Console output from 'mvn clean deploy'

[INFO] Scanning for projects...
WAGON_VERSION: 1.0-beta-2
[INFO] ------------------------------------------------------------------------
[INFO] Building mywebapp Maven Webapp
[INFO]    task-segment: [clean, deploy]
[INFO] ------------------------------------------------------------------------
[INFO] [clean:clean]
[INFO] Deleting directory C:\dev\workspace\mywebapp\target
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:compile]
[INFO] Compiling 1 source file to C:\dev\workspace\mywebapp\target\classes
[INFO] [jspc:compile {execution: jspc}]
[INFO] Built File: \index.jsp
[INFO] [resources:testResources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:testCompile]
[INFO] No sources to compile
[INFO] [surefire:test]
[INFO] No tests to run.
[INFO] [war:war]
[INFO] Packaging webapp
[INFO] Assembling webapp[mywebapp] in [C:\dev\workspace\mywebapp\target\mywebapp]
[INFO] Processing war project
[INFO] Webapp assembled in[87 msecs]
[INFO] Building war: C:\dev\workspace\mywebapp\target\mywebapp.war
[INFO] [install:install]
[INFO] Installing C:\dev\workspace\mywebapp\target\mywebapp.war to \dev\m2repo\com\maventest\mywebapp\1.0-SNAPSHOT\mywebapp-1.0-SNAPSHOT.war
[INFO] [deploy:deploy]
altDeploymentRepository = null
[INFO] Retrieving previous build number from archiva.snapshots
Uploading: http://192.168.1.7:8081/archiva/repository/snapshots/com/maventest/mywebapp/1.0-SNAPSHOT/mywebapp-1.0-20080208.214255-1.war
4096/?
6473/?
[INFO] Retrieving previous metadata from archiva.snapshots
[INFO] Uploading repository metadata for: 'snapshot com.maventest:mywebapp:1.0-SNAPSHOT'
[INFO] Retrieving previous metadata from archiva.snapshots
[INFO] Uploading project information for mywebapp 1.0-20080208.214255-1
[INFO] Retrieving previous metadata from archiva.snapshots
[INFO] Uploading repository metadata for: 'artifact com.maventest:mywebapp'
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7 seconds
[INFO] Finished at: Fri Feb 08 13:42:57 PST 2008
[INFO] Final Memory: 13M/24M
[INFO] ------------------------------------------------------------------------

(Continued on page 2)

Page:    1 2 >