This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Ant, Maven and Other Build Tools and the fly likes Including Local  Jar Files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Including Local  Jar Files" Watch "Including Local  Jar Files" New topic
Author

Including Local Jar Files

Praful Thakare
Ranch Hand

Joined: Feb 10, 2001
Posts: 614
Hi,

I have some jar files those are not part of any global repos, i have to include them in my war thats build by Maven, on some googling i found following task



but this does not put the jar file in war...also its not recommended solution, does any one have better way to achieve this?

-P


All desirable things in life are either illegal, banned, expensive or married to someone else !!!
Joachim Rohde
Ranch Hand

Joined: Nov 27, 2006
Posts: 423

Deploy the JAR file into your local repository:
http://maven.apache.org/plugins/maven-install-plugin/examples/custom-pom-installation.html
and/or
http://maven.apache.org/plugins/maven-install-plugin/examples/specific-local-repo.html

Or install a repository manager like, e.g. http://nexus.sonatype.org/
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5812
    
    7

Here is what I do. I add the dependencies to my pom.xml and run mvn. I then get an error about the missing dependencies along with the full command needed to register the JAR files in my local repository. I enter those commands, the JARs go into the local repository and then I run mvn again and everything compiles.

The easy part is coming up with a reasonable mechanism for specifying the group id (I usually use the first few levels of the class package), artifact id (I used the library name) and version in the dependency. The hard part is that you have to manually handle transitive dependencies (aaa.jar depends on bbb.jar, but the app needs only aaa.jar to compile).


JBoss In Action
Praful Thakare
Ranch Hand

Joined: Feb 10, 2001
Posts: 614
Thanks much Peter and Joachim, I am good now.

-P
 
Don't get me started about those stupid light bulbs.
 
subject: Including Local Jar Files
 
Similar Threads
Java Security Exception
add lib jars to war file using maven
Using jar without a shared repository in Maven
Maven build including jar files on local drive
Compile time Annotation Processing - Maven build problem