Maven 3 does not update snapshot dependency from local repository

前端 未结 3 1911
轻奢々
轻奢々 2021-02-08 22:26

I am trying to use external library inside my maven project. Since I want the project to build out of the box on any machine, I don\'t want to use mvn install solut

3条回答
  •  鱼传尺愫
    2021-02-08 22:53

    The previous answerer (and one commenter) pointed out, that maven looks within the local project-repository only once, and on subsequent builds it gets the cached jar from the .m2-repository.

    I just found a workaround for the need to increment the version number (e.g. on small changes of a dev-library):

    First reinstall the jar into your local project-repository:

    mvn install:install-file -DlocalRepositoryPath=repo -DcreateChecksum=true -Dpackaging=jar -DgroupId=com.johndoe.dev -DartifactId=Helpers -Dversion=0.1 -Dfile=C:/path/to/helpers.jar
    

    (Where -Dfile could point to an external Project which produces the helpers.jar)

    Then purge just this specific artifact in the .m2-repository:

    mvn dependency:purge-local-repository -DmanualInclude=com.johndoe.dev:Helpers:0.1
    

    (With com.johndoe.dev as the GroupId, Helpers as the ArtifactId and the same version installed in the previous step)

    Executing the latter step, maven rebuilds the artifact inside .m2 using your local project-repository jar-file.

    Alternative and maybe dirty variant: Just copy helpers.jar to C:\Users\johndoe\.m2\repository\com\johndoe\dev\Helpers\0.1\Helpers-0.1.jar (don't know about linux as I haven't used mave there).

提交回复
热议问题