Maven install Plugin

From NovaOrdis Knowledge Base
Revision as of 16:01, 18 November 2016 by Ovidiu (talk | contribs) (→‎Overview)
Jump to navigation Jump to search

External

Internal

Overview

The install plugin copies artifacts into the local 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


!!!Command Line: Deployment

"deploy" sends an artifact into a remote 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\ofeodoro\.m2" -DrepositoryId=repository }}}

!!!Deploying a third party artifact in http://repository.novaordis.org

In order to do that, you will need to log in on Template:Raiatea and become the user Template:Repository.

{{{

    /usr/local/maven/bin/mvn deploy:deploy-file -DgroupId=javax.jms -DartifactId=jms -Dversion=1.1 \
                                                -Dpackaging=jar -Dfile=./javax.jms.jar \
                                                -Durl=file:///home/repository/maven2 \
                                                -DrepositoryId=repository.novaordis.org
    /usr/local/maven/bin/mvn deploy:deploy-file -DgroupId=javax.jms -DartifactId=jms -Dversion=1.1 \
                                                -Dpackaging=jar -Dclassifier=source -Dfile=./somesourcejar.jar \
                                                -Durl=file:///home/repository/maven2 \
                                                -DrepositoryId=repository.novaordis.org

}}}

!!!Deploy a third party artifact under an arbitrary group into a remote https:// repository

{{{

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

}}}

This will create (with appropriate permissions) https://calt.cms.gov/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 the artifact that is being built can be changed with {{<finalName>}} as follows: {{{

    <build>
           <finalName>simple-webapp</finalName>
    </build>

}}} or {{{

   <build>
       <finalName>${artifactId}</finalName>
   </build>

}}} or {{{

   <build>       
        <finalName>archimedes-${project.version}</finalName>
   </build>

}}} or {{{

   <build>
       <finalName>${parent.artifactId}-${artifactId}</finalName>
   </build>

}}}

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

{{{

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

}}}







|[Maven Plugin Deploy]