Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<blockquote> <p>If there were a way to execute this lazily only when the artifact is not installed, that might be ideal.</p> </blockquote> <p>I will give a straight answer to your question even knowing of it's inherent ugliness. I've been using a workaround recipe with success for a while, but be warned that personally I don't think this is any better than system dependencies. Maven people consider abusing profiles a bad practice.</p> <p>Create a separate <a href="http://maven.apache.org/guides/introduction/introduction-to-profiles.html" rel="nofollow">profile</a> to install the libs and bind the <code>maven-install-plugin</code> as proposed in your question.</p> <p>You could activate the profile manually with <code>-P myprofile</code>. Another option if you feel like going 100% hackish, is adapting @vlf "check for file" suggestion to pure Maven. Just use a activation trigger for the profile. Maybe something like this (<strong>WARNING</strong>: untested):</p> <pre><code>&lt;activation&gt; &lt;file&gt; &lt;missing&gt;${user.home}/.myapp/.mylibisinstalled&lt;/missing&gt; &lt;/file&gt; &lt;/activation&gt; </code></pre> <p>If you have a common set of libraries that are used by many projects, just create a separate <em>installer</em> artifact with it's own pom.xml. This way you don't need to carry the same jar files for multiple projects. </p> <p>I personally have a <code>install-extra-libs</code> artifact with this purpose. It has some jar files in a lib folder (and also some jars of javadocs and source code), some dependencies to obscure / password protected repositories, and even download some files directly using <a href="http://maven.apache.org/plugins/maven-antrun-plugin/run-mojo.html" rel="nofollow">antrun:run</a> and ANT <a href="http://ant.apache.org/manual/Tasks/get.html" rel="nofollow">get task</a>. For the lib folder and downloaded jars, there're some massive<code>install-file</code> bidings. It is ugly and hackish but works when you commonly needs to install the same set of libraries / javadocs over and over again into multiple repositories.</p> <p><strong>PROS:</strong> </p> <ul> <li>All the hackery happens inside this artifact. My projects uses clean dependency syntax.</li> <li>No jar files duplication. No JAR files in SCM.</li> <li>I consider it a way to create new Maven repositories "on the fly".</li> </ul> <p><strong>CONS:</strong></p> <ul> <li>It defeats Maven purpose. If you find yourself doing it for public open source projects, consider uploading it to a public repository and syncing with the Maven Central... Here's a <a href="https://docs.sonatype.org/display/Repository/Sonatype+OSS+Maven+Repository+Usage+Guide" rel="nofollow">guide</a> explaining how to do that from Sonatype repository. It takes some time, but at least other people may benefit from your effort.</li> <li>It defeats Maven purpose x2. If you don't be careful, soon you lose track of which dependencies are on Central Repository. Most of my projects uses one or more custom installed dependencies, making any of then public would be a pain. </li> </ul> <p>Cheers,</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload