Table of Contents
- Table of Contents
- How to cut a release?
- 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?
- How to authenticate when using site-deploy?
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> - Check out a copy of the source code with the protocol used in the scm element and run mvn clean install to make sure you have all dependencies in the local .m2 repository.
- Do a dry run, to check that everything seems ok:
mvn release:prepare -DdryRun=true mvn release:clean - Do the actual release (
Your Subversion commandline client version must be 1.6.5 or greater because of this bug.)
mvn release:prepare mvn release:perform
What to do when a release fails?
1. Try reverting changes automatically with mvn release:rollback.
2. 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
- svn-win32-1.6.6.zip or similar (see CollabNet Subversion Downloads , Slik SVN)
- Set up ssh keys if site-deploy use scp (and is not disabled)
- Subversion / TortoiseSVN SSH HowTo , see section SSH key generation and connection check (client).
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. |
1. 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.
2. 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>
3. Add authentication information to settings.xml.
4. 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: <siteUrl>file:///var/www/html/sites</siteUrl>
scp : Java implementation of scp based on JSCh .
-
- Example url: <siteUrl>scp://m2sites.company.com/var/www/html/sites</siteUrl>
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 <servers> element for more information. Some examples follow below. Note that username/password and privatekey/passphrase schemes are mutually exclusive.
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.
Your Subversion commandline client version must be 1.6.5 or greater bacause of this bug.