Maven deploy Plugin: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
 
(11 intermediate revisions by the same user not shown)
Line 9: Line 9:
=Overview=
=Overview=


The deploy plugin copies artifacts into a ''remote repository'' (the [[Maven install Plugin|install plugin]] copies artifacts into the local repository).
The deploy plugin copies artifacts into a ''remote repository'' (the [[Maven install Plugin|install plugin]] copies artifacts into the local repository). The remote repository to upload to is configured in the <distributionManagment> section:
 
<syntaxhighlight lang='xml'>
 
<distributionManagement>
    <repository>
        <id>nexus</id>
<url>https://nexus-cicd.apps.openshift.novaordis.io/content/repositories/releases</url>
    </repository>
    <snapshotRepository>
        <id>nexus</id>
<url>https://nexus-cicd.apps.openshift.novaordis.io/content/repositories/snapshots</url>
    </snapshotRepository>
</distributionManagement>
 
</syntaxhighlight>
 
=Running as Part of a Lifecycle=
 
See:
 
<blockquote style="background-color: #f9f9f9; border: solid thin lightgrey;">
:[[Maven_install_Plugin#Running_as_Part_of_a_Lifecycle|The install plugin - Running as Part of a Lifecycle]]
</blockquote>


=Examples=
=Examples=


==Install Arbitrary Files as Binaries and Sources==
==Deploy Arbitrary Files in the Local Repository==


<pre>
<pre>
Line 20: Line 43:
     -Durl="file://C:\Documents and Settings\user1\.m2" -DrepositoryId=repository
     -Durl="file://C:\Documents and Settings\user1\.m2" -DrepositoryId=repository
</pre>
</pre>
==Deploy Arbitrary Files in a Remote Repository==


<pre>
<pre>
Line 27: Line 52:


This will create (with appropriate permissions) https://example.com/nexus/content/repositories/libs-release-local/blah/ec/template/test/1/test-1.zip
This will create (with appropriate permissions) https://example.com/nexus/content/repositories/libs-release-local/blah/ec/template/test/1/test-1.zip
Note that if the source file is in the local maven repository, deploy:deploy-file will fail:
<syntaxhighlight lang='text'>
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy-file (default-cli) on project standalone-pom: Cannot deploy artifact from the local repository: /Users/someuser/.m2/repository/com/example/something/1.0.0/something-8.0.0.jar -> [Help 1]
</syntaxhighlight>


=Deploying Programmatically an Artifact under a Different Name than its artifactId=
=Deploying Programmatically an Artifact under a Different Name than its artifactId=


The name of an artifact as created in ./target can be changed using <finalName>. For more details on changing the artifact name see [[Maven_Concepts#Artifact_Name|Artifact Name]]. However, the name won't propagate to the local or remote repository upon installation or deploy.
See:
 
To install the artifact under a different name, do the following (please be aware that the artifact won't be deployed under the current module's directory, but under whatever is specified as "artifactId" below):


<pre>
<blockquote style="background-color: #f9f9f9; border: solid thin lightgrey;">
<plugin>
:[[Maven_install_Plugin#Deploying_Programmatically_an_Artifact_under_a_Different_Name_than_its_artifactId|install plugin - Deploying Programmatically an Artifact under a Different Name than its artifactId]]
    <artifactId>maven-install-plugin</artifactId>
</blockquote>
    <executions>
        <execution>
            <id>install-ear-as-archimedes</id>
            <phase>install</phase>
            <configuration>
                <file>${project.build.directory}/${project.build.finalName}.ear</file>
                <groupId>com.numberdog.archimedes</groupId>
                <artifactId>archimedes</artifactId>
                <version>${parent.version}</version>
                <packaging>ear</packaging>
            </configuration>
            <goals>
                <goal>install-file</goal>
            </goals>
        </execution>
    </executions>
</plugin>
</pre>

Latest revision as of 20:34, 13 January 2021

External

Internal

Overview

The deploy plugin copies artifacts into a remote repository (the install plugin copies artifacts into the local repository). The remote repository to upload to is configured in the <distributionManagment> section:

<distributionManagement>
    <repository>
        <id>nexus</id>
	<url>https://nexus-cicd.apps.openshift.novaordis.io/content/repositories/releases</url>
    </repository>
    <snapshotRepository>
        <id>nexus</id>
	<url>https://nexus-cicd.apps.openshift.novaordis.io/content/repositories/snapshots</url>
    </snapshotRepository>
</distributionManagement>

Running as Part of a Lifecycle

See:

The install plugin - Running as Part of a Lifecycle

Examples

Deploy Arbitrary Files in the Local Repository

mvn deploy:deploy-file -DgroupId=javax.transaction -DartifactId=jta -Dversion=1.0.1B \
     -Dpackaging=jar -Dfile="C:\tmp\jta-1.0.1B.jar" \
     -Durl="file://C:\Documents and Settings\user1\.m2" -DrepositoryId=repository

Deploy Arbitrary Files in a Remote Repository

mvn deploy:deploy-file -DgroupId=ec.template -DartifactId=test -Dversion=1 -Dpackaging=zip \
   -Dfile=./test.zip -Durl=https://username:mypasswd@example.com/nexus/content/repositories/libs-release-local/blah

This will create (with appropriate permissions) https://example.com/nexus/content/repositories/libs-release-local/blah/ec/template/test/1/test-1.zip

Note that if the source file is in the local maven repository, deploy:deploy-file will fail:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy-file (default-cli) on project standalone-pom: Cannot deploy artifact from the local repository: /Users/someuser/.m2/repository/com/example/something/1.0.0/something-8.0.0.jar -> [Help 1]

Deploying Programmatically an Artifact under a Different Name than its artifactId

See:

install plugin - Deploying Programmatically an Artifact under a Different Name than its artifactId