Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

mavn and specific jars

 
Gabriel Bjorn
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I'm a newbie to Maven 2 so forgive me if this question is too basic.
I'm currently working on a project where we download code from an SVN repository; this code includes a bunch of jar files which are in a specific directory and which Maven should use. Some of these jars are proprietary and others are "standard" (for example, junit.jar). The thing is, for example, I need to use junit and would like to use this particular junit.jar (and not the one in maven's remote repository), mainly since the junit code is based on this junit.jar and the version number is not given to us (junit is just one of these jars, there are many other cases where this ocurrs). So I think I can't use the dependencies? Or maybe I can tell Maven to use this particular junit file in the dependencies section, instead of telling it which junit version to use?
Any idea on how I can achieve this?

thanks!
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18025
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your JUnit jar is a little worrisome. If you're using one of the stock releases of JUnit, there's probably a copy of it in the standard Maven public repositories, and I'd recommend using that, for simplicity's sake.

For custom jars and other non-supported artifacts you can enter them into your local Maven repository. Once you do that, Maven can reference them as dependencies in the same way it does for public repository items.

I have a project like that, with several third-party jars. Getting them into Maven is done like this:

# mvn install:install-file \
# -DgroupId=<your_group_name> \
# -DartifactId=<*your_artifact_name*> \ -Dversion=<SNAPSHT> \
# -Dfile=<*path_to_your_jar*> \ -Dpackaging=jar \
# -DgeneratePom=true
#

The angle brackets indicate complex arguments. A typical maven install might look like this:



The generatePom option is optional.

And, of course, the dependency would then be:


The artifactID and the actual jar filename don't have to match, but it's always helpful if they're at least closely-enough related that people can deduce the connection.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic