Thursday, June 14, 2018

Pushing Your Local Copy of JAR into the Local Maven Repository

$\mathtt{REFERENCE}$ @ Reference

If you understand the layout of the Maven repository, you can copy the jar directly into where it is meant to go. Maven will find this file next time it is run.

If you are not confident about the layout of the Maven repository, then you can adapt the following command to load in your jar file, all on one line.

     mvn install:install-file
          -Dfile=<path-to-file>
          -DgroupId=<group-id>
          -DartifactId=<artifact-id>
          -Dversion=<version>
          -Dpackaging=<packaging>
          -DgeneratePom=true
 
  Where: <path-to-file>  the path to the file to load
            <group-id>      the group that the file should be registered under
            <artifact-id>   the artifact name for the file
            <version>       the version of the file
            <packaging>     the packaging of the file e.g. jar
  

Example

If you have a jar file example.jar, then following command

     mvn install:install-file
          -Dfile=path/to/example.jar
          -DgroupId=com.hogwart
          -DartifactId=sample
          -Dversion=1.0.0
          -Dpackaging=jar
          -DgeneratePom=true

  
will generate following directory structure in the local maven repository:

~/.m2/repository/com/hogwart/sample/1.0.0/sample-1.0.0.jar






No comments:

Post a Comment