Does the maven-dependency-plugin use some other kind of artifact resolution than the rest of maven?

后端 未结 4 1402
礼貌的吻别
礼貌的吻别 2020-12-29 11:39

If I use the maven-dependency-plugin plugin, than I can\'t use a version range. Also it seems the version of a there defined artifact doesn\'t get updated though a newer ver

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-29 12:12

    The dependency plugin uses the same resolution mechanism as everything else. It may be that your repositories are not updating the metadata because the is set to never or weekly or something. You can force Maven to refresh all the remote repository metadata by running with a -U.

    The dependency plugin also doesn't overwrite downloaded dependencies by default if they already exist in the target. You can do a clean or configure the goal to force overwrites. There are three parameters you can set to true: overWriteIfNewer, overWriteReleases, and overWriteSnapshots. See the documentation for more details.

    Edit: based on your updated question, the problem is that you are using a dependency range. Ranges are fine as long as there is something to resolve the version (for example you have the version defined in the parent project or in your dependencies section). If you change the range to an exact version, or use one of the LATEST or RELEASE keywords, Maven will be able to resolve the version number (though be aware that those keywords carry their own risks.

    I'd recommend defining a dependencyManagement section in your parent with the versions you use, then your projects can inherit those versions. I answered another question about this recently, I'll post a link if I find it

提交回复
热议问题