Maven FAQ

Tips and hits for using maven. For other FAQ please check GeneralDev & DeveloperFaq

Adding a bundle to a maven repository


In order to install a file (e.g. a JAR) in you local repositry:

mvn install:install-file \
      -DgroupId=<group-id> \
      -DartifactId=<artifact-id> \
      -Dversion=<version> \
      -Dfile=<path-to-file> \
      -Dpackaging=<packaging> (i.e. jar) \

e.g. To install aspectjrt version 1.6.2 in your local repositry:

mvn install:install-file  -DgroupId=aspectj -DartifactId=aspectjrt -Dversion=1.6.2 -Dfile=aspectjrt.jar -Dpackaging=jar -DgeneratePom=true


In order to deploy a jar to a remote repository deploy:deploy-file should be used, since this plugin will also create the *.sha files with a hash.

Example: Prepare aspectjrt version 1.6.2 for a remote repository. With this command you in fact create the artifact in local temporary repository and then copy the resulting files to the remote repository:

mvn deploy:deploy-file -DgroupId=aspectj -DartifactId=aspectjrt -Dversion=1.6.2 -Dpackaging=jar -Dfile=aspectjrt.jar -Durl=file:///D:/tmp/repo

It is also possible to directy deploy to the remote repository via scp:

mvn deploy:deploy-file -DgroupId=aspectj -DartifactId=aspectjrt -Dversion=1.6.2 -Dpackaging=jar -Dfile=aspectjrt.jar -Durl=scp://you@ -DgeneratePom=true

maven settings.xml

The remote server must be configured in the ~/.m2/settings.xml file or in the {maven-home}/conf/settings.xml.

The repository is accessed with SCP, authentication is done with public/private key.

settings.xml for *NIX systems:

<settings xmlns=""


Setting for windows using pageant in order to provide the key to, so no key is specified explicitly in this configuration:

<settings xmlns=""

    <!-- == Cygwin Configuration == -->
    <!-- == Putty Configuration == -->

Also see: How do I install a file in my local repository along with a generic POM

Creating maven artifacts from eclipse bundles

The taxeditor poms require access to the latest eclipse bundles as maven artifacts. Luckily the maven-eclipse-plugin has a feature for that.

Please make sure that you have the deltapack installed before doing this.

$ mvn eclipse:to-maven -DeclipseDir=<path to your eclipse installation or target platform>/eclipse \
                    -DdeployTo=<repository server id as in settings.xml>::default::<your maven repository as configured in parent pom.xml> \

If you do not want to deploy to the maven repository skip the deployTo option.

For further information please refer to

Please note that this is a rather lengthy operation.

Using the maven release plugin

Test run release:prepare while editing the pom.xml files:

mvn -DdryRun=true -Dmaven.test.skip=true --batch-mode -DcheckModificationExcludeList=pom.xml release:prepare

prepare a release (non interactive)

mvn --batch-mode release:prepare

The release:prepare failed, what should I do now?

Usually you can re-execute release:prepare to resume the failed build.

If you are about to change something in the code or in the pom.xml's you should clean up the working space:

  1. remove all files which have been created by release:prepare
mvn release:clean
  1. Revert your local copy of the svn repository
 svn revert

mvn release:prepare failes with "The svn command failed" when using cygwin

detailed example output of this error:

[INFO] Working directory: D:\workspaces\cdmlib-trunk
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Unable to commit files
Provider message:
The svn command failed.
Command output:
svn: '/cygdrive/d/workspaces/cdmlib-trunk/D:/workspaces/cdmlib-trunk' is not a working copy
svn: '/cygdrive/d/workspaces/cdmlib-trunk/D:/workspaces/cdmlib-trunk' does not exist

This is due to a bug which is currently unsolved:

So it seems as if you cannot use the release plugin if you have cygwin installed.

Maven and svn

how can I configure maven to use my svn credentials

in maven 1 it was possible to store the credentials in $USER-HOME./scm/svn-settings.xml but this option is not further supported by maven 2, since credentials are usually stored by svn automatically

unless not configured differently in


So in order to use a specific svn account with maven

first perform a commit manually by svn ci -m "commit message"

and answer the question wether to store the credential

with yes.

There is no specific maven configuration required for

svn to work with maven!

Maven Deploy and Wagon (wagon-maven-plugin)

The wagon-maven-plugin for ssh uses the user account configured in the maven settings.xml

debugging problems which occur during deployment over ssh

helpful links:

example error messages:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project cdmlib-parent: 
Failed to deploy artifacts: Could not transfer artifact eu.etaxonomy:cdmlib-parent:pom:3.4.0-20141205.121434-86 from/to (scpexe:// 
Exit code: 1 - scp: /var/www/ 
Permission denied -> [Help 1]

commands which may help debugging

You may need to exchange the files and folder used in the examples below by valid values.

IMPORTANT: Do not forget to delete the uploaded artefacts from the repo!

1) test maven-deploy-plugin

mvn -e -X deploy:deploy-file -Dfile=/var/lib/jenkins/.m2/repository/log4j/log4j/1.2.17/log4j-1.2.17.jar \
  -DpomFile=/var/lib/jenkins/.m2/repository/log4j/log4j/1.2.17/log4j-1.2.17.pom \
ssh "rm -rf /var/www/"

2) test wagon-maven-plugin

Test for valid default configuration in the pom:

touch /tmp/testfile
mvn -X -e wagon:upload-single -Dwagon.fromFile=/tmp/testfile \
ssh "rm -f /var/www/"

If this command is failing with errors like

  • The parameters 'url' for goal org.codehaus.mojo:wagon-maven-plugin:1.0:upload-single are missing or invalid
  • Failed to execute goal org.codehaus.mojo:wagon-maven-plugin:1.0:upload-single (default-cli) on project xxx: Error handling resource: Error executing command for transfer: Exit code 255 - Permission denied (publickey)

the pom.xml most probably misses the default config for the wagon-maven-plugin.
Add the following to the plugins section:


This command can be used to test the wagon ssh connectivity without default configuration.
If you get an error with this the ~/m2/settings.xml might be missing the entry for the serverID (see above).

touch /tmp/testfile
mvn -X -e wagon:upload-single -Dwagon.fromFile=/tmp/testfile \
  -Dwagon.url=scpexe:// -Dwagon.toFile=/var/www/
ssh "rm -f /var/www/"

Updated by Andreas Kohlbecker almost 5 years ago ยท 41 revisions