The Deploy Plugin has two basic functions. In most project builds, the deploy phase of the build lifecycle is implemented using the deploy:deploy mojo. Also, artifacts which are not built using Maven can be added to any remote repository using the deploy:deploy-file mojo.
In most cases, this mojo is invoked when you call the deploy phase of the default build lifecycle.
To enable this mojo to function, you must include a valid <distributionManagement/> section POM, which at the minimum provides a <repository/> defining the remote repository location for your artifact. To separate snapshot artifacts from release artifacts, you can also specify a <snapshotRepository/> location. Finally, to deploy a project website, you must specify a <site/> section here as well. It's also important to note that this section can be inherited, allowing you to specify the deployment location one time for a set of related projects.
If your repository is secured, you may also want to configure your settings.xml file to define corresponding <server/> entries which provides authentication information. Server entries are matched to the different parts of the distributionManagement using their <id/> elements. For example, your project may have a distributionManagement section similar to the following:
[...] <distributionManagement> <repository> <id>internal.repo</id> <name>MyCo Internal Repository</name> <url>Host to Company Repository</url> </repository> </distributionManagement> [...]
In this case, you can specify a server definition in your settings.xml to provide authentication information for both of these repositories at once. Your server section might look like this:
[...] <server> <id>internal.repo</id> <username>maven</username> <password>foobar</password> </server> [...]
Unfortunately, Maven doesn't currently support hashed or encrypted passwords in the settings.xml.
Once you've configured your repository deployment information correctly deploying your project's artifact will only require invocation of the deploy phase of the build:
The deploy:deploy-file mojo is used primarily for deploying artifacts to which were not built by Maven. The project's development team may or may not provide a POM for the artifact, and in some cases you may want to deploy the artifact to an internal remote repository. The deploy-file mojo provides functionality covering all of these use cases, and offers a wide range of configurability for generating a POM on-the-fly. Additionally, you can specify what layout your repository uses. The full usage statement of the deploy-file mojo can be described as:
mvn deploy:deploy-file -Durl=file://C:\m2-repo \ -DrepositoryId=some.id \ -Dfile=your-artifact-1.0.jar \ [-DpomFile=your-pom.xml] \ [-DgroupId=org.some.group] \ [-DartifactId=your-artifact] \ [-Dversion=1.0] \ [-Dpackaging=jar] \ [-Dclassifier=test] \ [-DgeneratePom=true] \ [-DgeneratePom.description="My Project Description"] \ [-DrepositoryLayout=legacy] \ [-DuniqueVersion=false]
If the following required information is not specified in some way, the goal will fail: