maven install and deploy 3rd party dependencies with simple command line

后端 未结 3 978
独厮守ぢ
独厮守ぢ 2021-02-09 14:38

We have a number of third party dependencies that aren\'t hosted anywhere. For each of these we have a jar file that we\'d like to be able to install and/or deploy to our reposi

3条回答
  •  梦谈多话
    2021-02-09 14:58

    I meet this problem in my work:

    Now I have a target.jar (it has a dependencies list : a.jar, b.jar, c.jar...), I want to use mvn install:install-file to put it into my local repo, but when I run the command blow

    mvn install:install-file -Dfile=/Users/username/.../target.jar -DgroupId=com.cnetwork.relevance  -DartifactId=target  -Dversion=1.0.0
    

    but when I use it I found there are many error, the jar which use target.jar cannot find a.jar, b.jar, c.jar, such as:

    com.cnetwork.a does not exist
    com.cnetwork.b does not exist
    com.cnetwork.c does not exist
    

    Then I went to ~/.m2/repository/.../target/1.0.0/target.pom to find the pom file of the target, but nothing in it!

    ...
    com.cnetwork.relevance
    target
    1.0.0
    ....
    # no dependencies about a/b/c.jar !!!
    

    This is what going wrong, the install:file -Dfile -DgroupId -D.. does not add dependencies into pom, I correct the answer by this method

    1. if you already have this maven project source, just install it into local repo

      mvn clean install

    2. if you have the jar and the pom of it, install jar with pom

      mvn install:install-file -Dfile=/.../.../target.jar -DpomFile=/.../../target.pom

    3. if you don't have a pom with target jar, write one and use upper command.

    4. if you cannot recover the pom file of it, may be you should give up.

提交回复
热议问题