Maven deploy Plugin: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 30: Line 30:
=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]].
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.
 
 
 
However, the name won't propagate upon installation or deploy.


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):
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>
            <plugin>
<plugin>
                <!--
    <artifactId>maven-install-plugin</artifactId>
                    Installing the final artifact as "archimedes-*.ear" for convenience; it
    <executions>
                    will be available under 'archimedes' module, not 'ear'.
        <execution>
                -->
            <id>install-ear-as-archimedes</id>
                <artifactId>maven-install-plugin</artifactId>
            <phase>install</phase>
                <executions>
            <configuration>
                    <execution>
                <file>${project.build.directory}/${project.build.finalName}.ear</file>
                        <id>install-ear-as-archimedes</id>
                <groupId>com.numberdog.archimedes</groupId>
                        <phase>install</phase>
                <artifactId>archimedes</artifactId>
                        <configuration>
                <version>${parent.version}</version>
                            <file>${project.build.directory}/${project.build.finalName}.ear</file>
                <packaging>ear</packaging>
                            <groupId>com.numberdog.archimedes</groupId>
            </configuration>
                            <artifactId>archimedes</artifactId>
            <goals>
                            <version>${parent.version}</version>
                <goal>install-file</goal>
                            <packaging>ear</packaging>
            </goals>
                        </configuration>
        </execution>
                        <goals>
    </executions>
                            <goal>install-file</goal>
</plugin>
                        </goals>
</pre>
                    </execution>
                </executions>
            </plugin>
 
}}}

Revision as of 16:31, 18 November 2016

External

Internal

Overview

The deploy plugin copies artifacts into a remote repository (the install plugin copies artifacts into the local repository).

Examples

Install Arbitrary Files as Binaries and Sources

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
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

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 Artifact Name. However, the name won't propagate to the local or remote repository upon installation or deploy.

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):

<plugin>
    <artifactId>maven-install-plugin</artifactId>
     <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>