I have a specific use case for Continuous Integration with Jenkins in mind for this, but the answer could be a general Maven solution.
I would like to copy the latest version (could be a SNAPSHOT) of a Maven artifact to a local directory. Some more details:
- I have a Jenkins build plan that builds a Java project using Maven, resulting in an artifact installed into the local Maven repo (
mvn clean install
). - In a separate build plan (which can't be triggered by the first one for separate reasons), I want to use the latest result of the first build plan and copy it into a local directory (from where I deploy it into a Docker container).
This means that a) the first build plan installs an artifact (could be a SNAPSHOT version) into the local Maven repo, and b) I don't know the exact version number of the latest artifact.
What I've tried is to use the Maven Dependency Plugin, but I haven't found a good solution for this yet:
mvn dependencies:copy -Dartifact=foogroup:artifact:1.2.3-SNAPSHOT:jar -DoutputDir=.
This copies version 1.2.3-SNAPSHOT
of the specified artifact into the current directory, but the version number needs to be known in this case.
I've also tried to use the LATEST
identifier as in
mvn dependencies:copy -Dartifact=foogroup:artifact:LATEST:jar -DoutputDir=.
but it only tries to resolve the artifact from the remote repos, not from my local repo on the same machine. Using this approach, I can get the latest artifact that someone uploaded, but not the one that was just built on the machine.
Is there a way to get the latest version from the local Maven repo, not from the remote one?