download newest build of an artifact using maven in the command line

All I want at the end of the day is for the puppet-managed servers in our development environment to always pull the latest build of the latest version of whatever application they are running. While maven isn’t exactly intended for that, since all the shadowjars live in the same repository as their dependencies, and all come with md5 checksums to compare files that maven already generated, it seemed an obvious choice.

Trouble is, while I managed to pull the latest version through the command line, I have miserably failed in getting maven to check the pom.md5 to decide whether it needs to update a local jar or not. I tried some things with the dependency plugin, but when it already has a file with the same version locally, it just refuses to update it, even though the repository holds a newer build of that version.
So I’ve tried some things with the versions plugin, but again all I ever got are version numbers. I looked at the checksum plugin, but it seems dedicated to generating checksums. There’s one check goal, but it requires some csv that I don’t have, and I’m not sure how to get.

Really, all I want to do is for maven to compare the remote .jar.md5 with the local copy, and re-download the jar if they don’t match, even if it’s the same version. And I’d like to do it from the command line. But my hair is getting gray trying to do it…

Answer

Maven is very efficient in dependency management. Thus is never re-downloads release jars.

Option 1

Make the version to be SNAPSHOT

Option 2
specify a version range

<version>[1.0,)</version>

At the end run

mvn -U -C clean package (or what ever you need)

Attribution
Source : Link , Question Author : UncleBob , Answer Author : kofemann

Leave a Comment