user833970
user833970

Reputation: 2799

have maven download a jar as a dependency

There is a website with a jar I want to use in my project. I could download it, and make a local dependency on it, but that is lame.

Other people will build this project. I don't want to clutter source control by checking it in. I want to comunicate where the resource can be downloaded from and to easily change the versions. At some point I would like to attach the sources and javadocs.

Is there a plugin that will let me use the URL and download it to my .m2 with a spoofed pom?

Upvotes: 1

Views: 1691

Answers (3)

Evgeniy Dorofeev
Evgeniy Dorofeev

Reputation: 136112

maven-install-plugin can install files in local repo and generate poms, usage example:

mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc14 -Dversion=10.2.0.3.0 -Dpackaging=jar -Dfile=ojdbc6_g.jar -DgeneratePom=true

Upvotes: 0

Vidya
Vidya

Reputation: 30310

I think the best solution is to set up a Nexus or Artifactory repo for the team available over the network. Download the jar from the third-party location, and then upload it with the proper pom GAV values to your new local repo. Then add the URL of this repo to the repositories section of the pom. Everyone will get it when they sync up with version control.

Upvotes: 0

RicardoE
RicardoE

Reputation: 1725

The way I do it, is to search for the jars in Maven's central repo:

http://search.maven.org/

This gives you enough data to build the dependency in your pom.xml file

Example:

If I wanted to add jSoup to my project as dependency, then I go and search in the central repo

and add the dependency to the pom file with the info that's in there:

http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.jsoup%22%20AND%20a%3A%22jsoup%22

   <dependencies>
      <dependency>
         <groupId>org.jsoup</groupId>
         <artifactId>jsoup</artifactId>
         <version>1.7.3</version>
         <scope>test</scope>
      </dependency>
   </dependencies>

I think maven2 repo is included by default when creating the super pom, so you don't have to write it, it will look there by default.

Upvotes: 1

Related Questions