File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Ant, Maven and Other Build Tools and the fly likes mavn and specific jars Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "mavn and specific jars" Watch "mavn and specific jars" New topic

mavn and specific jars

Gabriel Bjorn

Joined: Dec 13, 2003
Posts: 3
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?

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17410

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.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: mavn and specific jars
It's not a secret anymore!