Note that there are some explanatory texts on larger screens.

plurals
  1. POInstalling 3rd party JARs within Maven lifecycle vs system scoped dependency
    primarykey
    data
    text
    <p>My project depends on some 3rd-party JARs which are not available in Maven Central.</p> <p>Most information I see regarding this situation, including the official Maven <a href="http://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html" rel="nofollow noreferrer">Guide to installing 3rd party JARs</a>, advises installing the artifact into the local repository using <code>mvn install:install-file ...</code>. This works well when developing locally, but when the build needs to be performed on many different systems in an automated fashion, requiring this manual step is undesirable and impractical.</p> <p>Another solution often presented is to install the dependency into an organization-wide repository, however there are circumstances in which that isn't possible.</p> <p>With neither of those options being acceptable, I can think of two options:</p> <ol> <li>Store the JAR in a lib directory within the project and declare the dependency with a <code>system</code> scope (as suggested in <a href="https://stackoverflow.com/questions/364114/can-i-add-jars-to-maven-2-build-classpath-without-installing-them/364188#364188">several</a> <a href="https://stackoverflow.com/questions/396245/add-a-dependency-in-maven/765032#765032">answers</a>). This would seem to work on any system since the dependency is bundled with the project, but I've seen the use of <code>system</code> discouraged as a bad practice (typically with no more explanation than that).</li> <li>Bind the maven-install-plugin to the <code>initialize</code> lifecycle phase to install the artifact to the local repository. However, as pointed out <a href="https://stackoverflow.com/questions/6571022/is-it-best-to-mavenize-your-project-jar-files-or-put-them-in-web-inf-lib/6592613#6592613">here</a>, this would cause unnecessary overhead as it runs for each and every build. If there were a way to execute this lazily only when the artifact is not installed, that might be ideal.</li> </ol> <p>I would like a standard Maven project that can be built using the regular Maven lifecycle, without any out-of-band "run scripts/init-dependencies first" steps required.</p> <p>What is the best way forward?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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