Maven Deploy Examples

The maven-deploy plugin goal can be used to deploy a buildmagic component to a maven repository. It is normally run from the command line using the following command.

  mvn org.jboss.maven.plugins:maven-buildmagic-thirdparty-plugin:maven-deploy \
        -Durl=<url to maven repository> \
        -DcomponentDir=<path to component info>

The url should be the url to the repository that you want to deploy to. This should be a full url and not a relative path. The componentDir is the path to the directory where component-info.xml is located. This will default to "." for the current directory if nothing is specified. This can be a relative path.

For example, the actual command might looks something like this.

  mvn org.jboss.maven.plugins:maven-buildmagic-thirdparty-plugin:maven-deploy \
        -Durl=file:///home/me/repository.jboss.org/maven2 \
        -DcomponentDir=/home/me/repository.jboss.org/jboss/messaging/1.4.1.Beta1

Basic Example

Consider the following existing buildmagic component directory structure.

 
  repository
  |
  +-ant/
    | 
    +-1.6.5/
      |
      +-component-info.xml
      |
      +-lib/
        |
        +-ant.jar

In order to deploy the ant.jar file to a maven repository, the above command would be run. The url paramenter could be set to the location of a local checkout of a maven repository (file:///home/me/maven-repo-checkout ), and the componentDir should be set to something like repository/ant/1.6.5

Example with POM files

Consider the following existing buildmagic component directory structure.

 
  repository
  |
  +-ant/
    | 
    +-1.6.5/
      |
      +-component-info.xml
      |
      +-lib/
        |
        |-ant.jar
        |
        +-ant.pom

The plugin will automatically look for an associate pom file for each artifact in a component lib directory. If the pom is found, the groupId, artifactId, and version will take priority over the information in component-info-xml. This pom will then be deployed to the maven repository along with the artifact.

Note: if the pom values such as groupId or version are overriden via the command line, the pomFile will be rewritten and some formatting information may be lost.

Deploying to a snapshot repository

Deploying a non-maven artifact to a snapshot repository normally uses the same process as deploying non snapshot artifacts. The only difference would be that the url parameter must point to the snapshot repository instead of the releases repository. You should also make sure that the artifact version is in the correct maven snapshot format (i.e. x.x.x-SNAPSHOT). If the version listed in component-info.xml is not in this format, you can override the version using the version parameter. For example:

  mvn org.jboss.maven.plugins:maven-buildmagic-thirdparty-plugin:maven-deploy \
        -Durl=<url to snapshot repository> \
        -DcomponentDir=repository/ant/1.6.5 \
        -Dversion=1.6.5-SNAPSHOT

Note: make sure that the correct url is used for the snapshot repository. For example, for deploying jboss artifacts, the url should be set to something like "dav:https://snapshots.jboss.org/maven2".

Deploying using webdav

The webdav protocol is not enabled by default in maven (versions less than 2.0.9). This can make deploying over webdav a little tricky in maven. In order to enable the webdav protocol, a basic pom.xml needs to be found in the same directory from which you run the maven-deploy goal. This pom can look something like this:

  <project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.jboss</groupId>
    <artifactId>webdav-loader</artifactId>
    <version>1</version>
    <name>JBoss Webdav Extension pom</name>
    <build>
      <extensions>
        <extension>
          <groupId>org.apache.maven.wagon</groupId>
          <artifactId>wagon-webdav</artifactId>
        </extension>
      </extensions>
    </build>
  </project>

Note that the groupId, artifactId, and version in this pom are not important. This pom only tells maven to load the webdav extension so that it will be available in the maven runtime while deploying to the snapshot repository.

Note about snapshot repository credentials

The jboss snapshot respository requires a username and password for uploading artifacts. In order to pass these credentials to the maven deployer the server must be configured in your settings.xml.

    <server>
      <id>snapshots.jboss.org</id>
      <username>jboss.org username</username>
      <password>password</password>
    </server>

The id of the repository should then be passed to the maven-deploy goal when deploying the project.

  mvn org.jboss.maven.plugins:maven-buildmagic-thirdparty-plugin:maven-deploy \
        -Durl=dav:https://snapshots.jboss.org/maven2 \
        -DcomponentDir=repository/ant/1.6.5 \
        -Dversion=1.6.5-SNAPSHOT
        -DrepositoryId=snapshots.jboss.org