title: How to copy the latest version of a Maven dependency from the local repository?
body: <p>I have a specific use case for Continuous Integration with Jenkins in mind for this, but the answer could be a general Maven solution.</p>
  
  <p>I would like to copy the latest version (could be a SNAPSHOT) of a Maven artifact to a local directory. Some more details:</p>
  
  <ul>
  <li>I have a Jenkins build plan that builds a Java project using Maven, resulting in an artifact installed into the local Maven repo (<code>mvn clean install</code>).</li>
  <li>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).</li>
  </ul>
  
  <p>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.</p>
  
  <p>What I've tried is to use the Maven Dependency Plugin, but I haven't found a good solution for this yet:</p>
  
  <pre><code>mvn dependencies:copy -Dartifact=foogroup:artifact:1.2.3-SNAPSHOT:jar -DoutputDir=.
  </code></pre>
  
  <p>This copies version <code>1.2.3-SNAPSHOT</code> of the specified artifact into the current directory, but the version number needs to be known in this case.</p>
  
  <p>I've also tried to use the <code>LATEST</code> identifier as in </p>
  
  <pre><code>mvn dependencies:copy -Dartifact=foogroup:artifact:LATEST:jar -DoutputDir=.
  </code></pre>
  
  <p>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.</p>
  
  <p>Is there a way to get the latest version from the local Maven repo, not from the remote one?</p>