Uploading artifacts to Archiva with webdav
Archiva natively supports webdav to upload artifacts on a managed repository.
Pre-requisites
- Create a managed repository
- Add to a user the Manager Role for this repository
- Then you'll need to tell maven's settings.xml file about your username and password (this file belongs in ~/.m2):
Code Block |
---|
|
<settings>
<servers>
<server>
<id>YOUR_REPO_ID</id>
<username>USERNAME</username>
<password>PASSWORD</password>
</server>
</servers>
</settings>
|
- Below we suppose that you defined two repositories, one for releases (YOUR_REPOSITORY_FOR_RELEASES_ID, YOUR_REPOSITORY_FOR_RELEASES_URL) and one for snapshots (YOUR_REPOSITORY_FOR_SNAPSHOTS_ID, YOUR_REPOSITORY_FOR_SNAPSHOTS_URL)
Maven 1.x
Upload third party artifact
- This feature isn't yet supported by the artifact plugin. We'll had it ASAP.
Upload project's artifact
- The webdav protocol isn't yet supported by the artifact plugin. It's quite easy to had (And I already succeded to do it). I'll commit the change and publish a snapshot soon....
- Sample of settings :
Code Block |
---|
# Repository to deploy to
#maven.repo.list=YOUR_REPOSITORY_FOR_SNAPSHOTS_ID
#maven.repo.YOUR_REPOSITORY_FOR_RELEASES_ID=dav:YOUR_REPOSITORY_FOR_RELEASES_URL
#maven.repo.YOUR_REPOSITORY_FOR_RELEASES_ID.directory=/
# These must be set elsewhere
#maven.repo.YOUR_REPOSITORY_FOR_RELEASES_ID.username=
#maven.repo.YOUR_REPOSITORY_FOR_RELEASES_ID.password=
# Repository to deploy snapshots
#maven.repo.YOUR_REPOSITORY_FOR_SNAPSHOTS_ID=dav:YOUR_REPOSITORY_FOR_SNAPSHOTS_URL
#maven.repo.YOUR_REPOSITORY_FOR_SNAPSHOTS_ID.directory=/
#maven.repo.YOUR_REPOSITORY_FOR_SNAPSHOTS_ID.username=${maven.repo.YOUR_REPOSITORY_FOR_RELEASES_ID.username}
#maven.repo.YOUR_REPOSITORY_FOR_SNAPSHOTS_ID.password=${maven.repo.YOUR_REPOSITORY_FOR_RELEASES_ID.password}
|
Maven 2.x
Upload third party artifact
Maven 2.0.x does not yet natively support the webdav protocol to upload artifacts. See http://jira.codehaus.org/browse/MNG-2664 for more information.
Meanwhile, you can use a simple pom.xml file containing the wagon-webdav build extension, as described here: http://maven.apache.org/archiva/guides/getting-started/maven-configuration.html
And then deploy your artifact:
Code Block |
---|
mvn deploy:deploy-file \
-DrepositoryId=<YOUR_REPO_ID> \
-Durl=dav:<YOUR_REPO_URL> \
-DgroupId=<GROUP_ID> \
-DartifactId=<ARTIFACT_ID> \
-Dversion=<VERSION> \
-Dpackaging=<PACKAGING> \
-Dfile=<FILE_PATH>
|
or (note that pomFile is pom that goes with the artifact, not the simple one mentioned above.)
Code Block |
---|
mvn deploy:deploy-file \
-DrepositoryId=<YOUR_REPO_ID> \
-Durl=dav:<YOUR_REPO_URL> \
-DpomFile=<POM_FILE_PATH>\
-Dfile=<FILE_PATH>
|
Upload project's artifact
You need to tell the <build> section about the Wagon WebDAV plugin:
Code Block |
---|
|
<build>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-webdav</artifactId>
<version>1.0-beta-1</version>
</extension>
</extensions>
...
</build>
|
Next you'll need to update your distributionManagement section:
Code Block |
---|
|
<distributionManagement>
<repository>
<id>YOUR_REPOSITORY_FOR_RELEASES_ID</id>
<name>Central Repository</name>
<url>dav:YOUR_REPOSITORY_FOR_RELEASES_URL</url>
</repository>
<snapshotRepository>
<id>YOUR_REPOSITORY_FOR_SNAPSHOTS_ID</id>
<name>Central Development Repository</name>
<url>dav:YOUR_REPOSITORY_FOR_SNAPSHOTS_URL</url>
</snapshotRepository>
</distributionManagement>
|
You can put <distributionManagement> in the parent pom for a multi-module project. It will be inherited by the child projects, which can override it if necessary.
- Now you can use the normal maven deploy command:
- Your SNAPSHOT repository will be viewable at: YOUR_REPOSITORY_FOR_RELEASES_URL
- Your release repository will viewable at: YOUR_REPOSITORY_FOR_SNAPSHOTS_URL
- You will need to navigate down to the appropriate location for your artifacts.