Albert
Albert

Reputation: 543

Using Maven to just download JARs

I would like to have Maven download the JARs listed in a pom.xml file. How do I do that? Currently, Maven wants to compile the project (and it fails). I don't care about compiling it because I'm compiling manually. I just want the JARS. Help?

Albert

ps: Background, I am compiling it manually because I can easily debug the project in Eclipse. I've manually downloaded a bunch of JAR files, but I suspect there's a JAR version mismatch as there's a mysterious error at runtime. I would do this checking manually, but there are hundreds of associated JAR files. Ideally, I want to download all the JAR files, point my Eclipse project to the newly download JARS, and get on with my life. :)

Upvotes: 48

Views: 50010

Answers (5)

gratinierer
gratinierer

Reputation: 2498

Additionally to some other correct answers, it should be enough to invoke

mvn  dependency:copy-dependencies

you can the adjust the way, the download should be done, add

    <build>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <configuration>
                    <excludeTransitive>true</excludeTransitive>
                </configuration>
            </plugin>
        </plugins>

    </build>

to your pom with a configuration, that fits your needs. In the case here e.g. transitive downloads are not done. You will find your downloaded stuff in target/dependency

Upvotes: 0

schnarbies
schnarbies

Reputation: 61

If you are using eclipse, I believe you can just right click on the project --> maven --> update project

Upvotes: 0

Rajeev
Rajeev

Reputation: 61

Try

mvn install dependency:copy-dependencies

You will see all the jars under 'target/dependency' folder

Upvotes: 6

Pierre
Pierre

Reputation: 1367

Your best approach is to use m2eclipse and import your pom into eclipse. It will download and link all dependencies to your project, and as an added bonus, it will also download and associate their source and javadoc jars. It does not really matter if the project has hundreds or just few dependencies, it will work the same.

Sometimes, we want to do something quickly and be done with it, but it ends up taking longer than doing the right away especially when there hundreds of dependencies.

Upvotes: 5

Mr.Eddart
Mr.Eddart

Reputation: 10273

You can try this command:

mvn dependency:resolve

Or just invoke the "install" life cycle as follows:

mvn install

Upvotes: 103

Related Questions