Maven install Plugin: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 18: Line 18:
mvn install:install-file -DgroupId=my.group -DartifactId=my-file -Dversion=1.0 -Dpackaging=jar -Dfile=./my-file.jar
mvn install:install-file -DgroupId=my.group -DartifactId=my-file -Dversion=1.0 -Dpackaging=jar -Dfile=./my-file.jar
mvn install:install-file -DgroupId=my.group -DartifactId=my-file -Dversion=1.0 -Dpackaging=jar -Dclassifier=sources -Dfile=./my-file-src.jar
mvn install:install-file -DgroupId=my.group -DartifactId=my-file -Dversion=1.0 -Dpackaging=jar -Dclassifier=sources -Dfile=./my-file-src.jar
</pre>
==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. 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>
    <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>
</pre>
</pre>

Revision as of 16:34, 18 November 2016

External

Internal

Overview

The install plugin copies artifacts into the local repository (the deploy plugin copies artifacts into a remote repository). It uses the information in the POM (groupId, artifactId, version) to determine the proper location for the artifact within the local repository. It can also be used as a detached tool to copy arbitrary files into the repository.

Examples

Install Arbitrary Files as Binaries and Sources

mvn install:install-file -DgroupId=my.group -DartifactId=my-file -Dversion=1.0 -Dpackaging=jar -Dfile=./my-file.jar
mvn install:install-file -DgroupId=my.group -DartifactId=my-file -Dversion=1.0 -Dpackaging=jar -Dclassifier=sources -Dfile=./my-file-src.jar

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>