Best way to create a maven artifact from existing jar

后端 未结 5 1952
死守一世寂寞
死守一世寂寞 2021-02-02 08:01

I\'m mavenizing some projects.

These projects all depend on a number of libraries, most of them are available in the maven repo. For the other libraries, I\'d like to cr

5条回答
  •  南笙
    南笙 (楼主)
    2021-02-02 08:56

    If you're not using a remote repository (which is a common situation for personal development), simply install these artifacts in your local repository using the install:install-file mojo:

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

    But obviously, this will make your build non portable (this might not be an issue though). To not sacrifice the portability, you'll have to make the artifacts available in a remote repository. In a corporate context, the common way to deal with that is to install an enterprise repository (and in that case, to deploy the artifacts indeed).

    Update: Once your artifact is installed in your local repository, simply declare a element in your pom like for any other dependency, e.g.:

    
      aGroupId
      aArtifactId
      1.0.12a
      jar
    
    

提交回复
热议问题