Install a 3:rd part lib in Maven

Filed under: Maven, — Tags: Automation, Install libs in Maven — Thomas Sundberg — 2011-06-10

Suppose that you have a dependency that looks something like this:

<dependency>
    <groupId>foo</groupId>
    <artifactId>bar</artifactId>
    <version>1.0</version>
</dependency>

that can't be resolved and the build fails with the error message below:

[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project regression: Could not resolve dependencies for project se.sigma.eduational:example:jar:1.0:
Could not find artifact foo:bar:jar:1.0-SNAPSHOT in Sigma Internal Repository (http://mavenrepo:8080/archiva/repository/internal/) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

To upload the missing jar manually, do like this:

mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> -DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>

A real world example could be

mvn install:install-file -Dfile=C:\temp\myThirdPartLib.jar -DgroupId=foo -DartifactId=bar -Dversion=1.0 -Dpackaging=jar

Running it could look something like this:

C:\example>mvn install:install-file -Dfile=C:\temp\myThirdPartLib.jar -DgroupId=foo -DartifactId=bar -Dversion=1.0 -Dpackaging=jar
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------
[INFO] Building Example 1.0
[INFO] ------------------------------
[INFO]
[INFO] --- maven-install-plugin:2.3.1:install-file (default-cli) @ regression ---
[INFO] Installing C:\temp\myThirdPartLib.jar to C:\java\maven-repository\foo\bar\1.0\bar-1.0.jar
[INFO] Installing C:\DOCUME~1\exttiy\LOKALA~1\Temp\mvninstall1957897313833162867.pom to C:\java\maven-repository\foo\bar\1.0\bar-1.0.pom
[INFO] ------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------
[INFO] Total time: 0.390s
[INFO] Finished at: Wed Feb 16 11:22:00 CET 2011
[INFO] Final Memory: 2M/15M
[INFO] ------------------------------

Re-run your build with the third party lib installed.

Resources



(less...)

Pages

About
Events
Why

Categories

Agile
Automation
BDD
Clean code
Continuous delivery
Continuous deployment
Continuous integration
Cucumber
Culture
Design
DevOps
Executable specification
Gradle
Guice
J2EE
JUnit
Java
Javascript
Kubernetes
Linux
Load testing
Maven
Mockito
New developers
Pair programming
PicoContainer
Presentation
Programming
Public speaking
Quality
React
Recruiting
Requirements
Scala
Selenium
Software craftsmanship
Software development
Spring
TDD
Teaching
Technical debt
Test automation
Tools
Web
Windows
eXtreme Programming

Authors

Thomas Sundberg
Adrian Bolboaca

Archives

Meta

rss RSS