Maven Deploy and Release FAQ
Table of Contents
- What to do when a release fails?
- What do I need to do to get mvn release to work on Windows?
- How to cut a release when a dependency has not been released yet?
- How to deploy 3rd party artifacts to a DAV repository?
- How to use deploy (and site-deploy) on Windows?
- How do I skip tests when preparing a release?
- How can I skip site-deploy (or a exclude a certain plugin) when I do a release?
- Which distribution mechanisms are common for site-deploy?
- Use SSH-keys
How to cut a release?
See official documentation; Release guide and plugin documentation
- Make sure no dependencies or plugins use SNAPSHOT versions.
- Set up distributionManagement
<build>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-webdav</artifactId>
<version>1.0-beta-2</version>
</extension>
</extensions>
<!--necessary due to http://jira.codehaus.org/browse/MRELEASE-271 -->
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<configuration>
<preparationGoals>clean install</preparationGoals>
</configuration>
</plugin>
</plugins>
</build>
<distributionManagement>
<repository>
<id>libs-releases</id>
<name>Objectware Internal Release Repository</name>
<url>dav:${releaseRepoUrl}</url>
</repository>
<snapshotRepository>
<id>libs-snapshots</id>
<name>Objectware Internal Snapshot Repository</name>
<url>dav:${snapshotRepoUrl}</url>
</snapshotRepository>
</distributionManagement>
<properties>
<repoUrl>http://repo.objectware.no/artifactory</repoUrl>
<releaseRepoUrl>${repoUrl}/libs-releases</releaseRepoUrl>
<snapshotRepoUrl>${repoUrl}/libs-snapshots</snapshotRepoUrl>
</properties>
mvn release:prepare -DdryRun=true
mvn release:clean
What to do when a release fails?
-
Try reverting changes automatically with mvn release:rollback.
-
If 1 doesn't work, manual cleanup is needed. Run mvn release:clean first to delete files created by the release-plugin. Next, check the version control system and the maven repo for changes and revert them if necessary.
What do I need to do to get mvn release to work on Windows?
- Install commandline client
-
E.g. Use a binary from CollabNet Subversion Downloads or Slik SVN.
-
Set up ssh key
-
Configuration
How to cut a release when a dependency has not been released yet?
| This is a workaround to allow a snapshot dependency to be used when using maven-release-plugin. |
- Change the version to something that clearly explains that this is a workaround to be able to perform a release with a dependency on a snapshot.
- Add wagon webdav to the build section of the pom
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-webdav</artifactId>
<version>1.0-beta-2</version>
</extension>
</extensions>
-
Add authentication information to settings.xml.
-
Deploy to altDeploymentRepository:
mvn deploy -Dmaven.test.skip=true -DaltDeploymentRepository=plugins-releases::default::dav:http://repo.objectware.no/artifactory/plugins-releases/
How to deploy 3rd party artifacts to a DAV repository?
wagon-webdav extension is required to deploy to a DAV repository. It is therefore necessary to create a temporary pom.xml to able to perform deploy-file.
Temporary pom.xml:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>webdav-deploy</artifactId>
<packaging>pom</packaging>
<version>1</version>
<name>Webdav Deployment POM</name>
<build>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-webdav</artifactId>
<version>1.0-beta-2</version>
</extension>
</extensions>
</build>
</project>
Command:
mvn deploy:deploy-file -Dfile=myproject-1.0.jar -DrepositoryId=myrepo
-Durl=dav:https://server/dav/url
-DgroupId=no.objectware -DartifactId=myproject -Dversion=1.0 -Dpackaging=jar
How to use deploy (and site-deploy) on Windows?
See Maven, Windows and Deploying to a Remote Location
How do I skip tests when preparing a release?
You need to pass the test argument as a system variable when Maven forks the thread to perform the tests like this:
mvn release:perform -Darguments=-Dmaven.test.skip=true
How can I skip site-deploy (or a exclude a certain plugin) when I do a release?
This is workaround that allows cutting a release even though reporting-plugins fail (e.g. clirr).
mvn release:perform -Dgoals=deploy
Which distribution mechanisms are common for site-deploy?
File, scp and scpexe are common ways to distribute the site.
<distributionManagement>
<site>
<id>site</id>
<url>${siteUrl}</url>
</site>
</distributionManagement>
File : Works almost always, but will only "deploy" the site locally.
-
- Example url:
- Example url:
scp : Java implementation of scp based on JSCh .
-
- Example url:
scp://m2sites.company.com/var/www/html/sites
- Example url:
scpexe : Use external implementation of SSH. This can be more troublesome to set up on Windows, but works in general better than scp (at least on Unix systems
See Wagon Providers for other distribution providers.
| | If file protocol is set in site distributionManagement, the site for the release is lost unless the release is run from the server which hosts the sites. This problem should (IMHO) be possible to remedy by overriding the property commandline, but this doesn't seem to be supported yet according to MSITE-295 . |
How to authenticate when using site-deploy?
See the official docs for the
Username and password in settings.xml
<servers>
<server>
<id>site</id>
<username>user</username>
<password>pass</password>
<filePermissions>664</filePermissions>
<directoryPermissions>775</directoryPermissions>
<configuration></configuration>
</server>
</servers>
Use SSH-keys
<servers>
<server>
<id>site</id>
<username>user</username>
<privateKey>${user.home}/.ssh/id_dsa</privateKey>
<passphrase>passphrase</passphrase>
<filePermissions>664</filePermissions>
<directoryPermissions>775</directoryPermissions>
<configuration></configuration>
</server>
</servers>
Linux: OpenSSH Public Key Authentication
Windows with Putty: Public Key Authentication With PuTTY
Windows with Tortoise: TODO
TODO: Verify that these recipes are complete and work properly.