Maven specific version of a snapshot dependency

前端 未结 4 1894
我在风中等你
我在风中等你 2020-12-14 14:22

Is there a way to get Maven to download a specific snapshot version of a dependency? I know that specifying the dependency like this will download the lastest snapshot avail

相关标签:
4条回答
  • 2020-12-14 15:19

    To use a specific snapshot version of a dependency, the referenced artifact should be installed/deployed with a unique snapshot version number. See the uniqueVersion element in the POM reference/Repository. In this case you can reference it like:

    ...
    <dependency>
    <groupId>groupid</groupId>
    <artifactId>artifact-id</artifactId>
    <version>1.0.0-20090610.041042-5</version>
    </dependency>
    ...
    

    Maven repository manager servers may have additional related features, like overriding the pom.xml's uniqueVersion setting. For example see the Artifactory User Guide about this feature (additionally, you can read here some arguments against using unique snapshot version numbers).

    0 讨论(0)
  • 2020-12-14 15:21

    Use the Versions Maven plugin

    http://mojohaus.org/versions-maven-plugin/examples/lock-snapshots.html

    and

    http://mojohaus.org/versions-maven-plugin/examples/unlock-snapshots.html

    0 讨论(0)
  • 2020-12-14 15:22

    AFAIK the SNAPSHOT always refers to the latest build and there is no way to depend on specific version.

    To work around this issue, you could republish the exact version you want to depend on in your own maven repository and assign it a specific version.

    0 讨论(0)
  • 2020-12-14 15:24

    Yes, you can. Any version that is in your maven repositories can be used. I've ran into some problems where the trasnsitive dependencies mucked with the version though. That's where mvn dependency:tree came in handy.

    • Maven dependency mechanism
    • mvn dependency:tree
    0 讨论(0)
提交回复
热议问题