Project

General

Profile

Actions

MavenFaq » History » Revision 18

« Previous | Revision 18/44 (diff) | Next »
Andreas Kohlbecker, 12/05/2014 02:54 PM


Maven FAQ

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

Adding a bundle to a maven repository

Local

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) \
      -DgeneratePom=true

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

Remote

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@192.168.1.17/var/www/cybertaxonomy.eu/cdmlib/mavenrepo/org/aspectj/aspectjrt -DgeneratePom=true

Of course the 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="http://maven.apache.org/SETTINGS/1.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                      http://maven.apache.org/xsd/settings-1.0.0.xsd">

  <servers>
    <server>
        <id>wp5.e-taxonomy.eu</id>
        <username>edit-developer</username>
        <configuration>
        </configuration>
    </server>
  </servers>
</settings>

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

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                      http://maven.apache.org/xsd/settings-1.0.0.xsd">

  <servers>
    <server>
      <id>wp5.e-taxonomy.eu</id>
      <username>edit-developer</username>
    <!-- == Cygwin Configuration == -->
    <!--
      <configuration>
        <sshExecutable>ssh</sshExecutable>
        <scpExecutable>scp</scpExecutable>
      </configuration>
    -->
    <!-- == Putty Configuration == -->
      <configuration>
        <sshExecutable>plink</sshExecutable>
        <scpExecutable>pscp</scpExecutable>
      </configuration>
    </server>
  </servers>
</settings>

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> \
                    -DstripQualifier=true

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

For further information please refer to http://maven.apache.org/plugins/maven-eclipse-plugin/to-maven-mojo.html

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] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[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: http://jira.codehaus.org/browse/SCM-481

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

$USER-HOME\.subversion\config

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 Wagon (wagon-maven-plugin)

wagon-maven-plugin debugging connectivity upload problems

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 wp5.e-taxonomy.eu (scpexe://wp5.e-taxonomy.eu/var/www/wp5.e-taxonomy.eu/mavenrepo/): Exit code: 1 - scp: /var/www/wp5.e-taxonomy.eu/mavenrepo//eu/etaxonomy/cdmlib-parent/3.4.0-SNAPSHOT/cdmlib-parent-3.4.0-20141205.121434-86.pom: Permission denied -> [Help 1]

commands with my help debugging:

mvn -X -e wagon:upload-single -Dwagon.fromFile=/var/lib/jenkins/jobs/cdmlib-INTEGRATION/workspace/cdmlib/README.txt -Durl=scpexe://wp5.e-taxonomy.eu/ -Dwagon.toFile=/var/www/wp5.e-taxonomy.eu/mavenrepo/ -DserverId=wp5.e-taxonomy.eu

Updated by Andreas Kohlbecker over 9 years ago · 18 revisions