Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use Maven just to fetch some library jars

We are using ANT for our build process and don't have plans to change this in the near future.

Is it possible to use Maven to just fetch common Open Source jar files (e.g. Log4J, SWT, JFace) and put them in the right location of our project, so we don't have to store them in our version control — preferable without creating the typical Maven-cache in the home directory?

like image 998
Mot Avatar asked Dec 31 '10 06:12

Mot


2 Answers

NO NO NO Everyone!

If you're using Ant, the best way to use Maven repositories to download jar dependencies is to use Ivy with Ant. That's exactly what Ivy is for.

Installing Ivy and getting to work with current Ant projects is simple to do. It works with Nexus and Artifactory if you use those as your local Maven repositories.

Take a look at Ivy. It is probably exactly what you want.

like image 67
David W. Avatar answered Oct 21 '22 18:10

David W.


In variation of org.life.java's answer, I would not do mvn install.

Instead, in the pom.xml I would add the following bit:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.1</version>
            <executions>
                <execution>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>copy-dependencies</goal>
                    </goals>
                    <configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

Now you just need to do mvn generate-sources, which is a lot faster than the full mvn install, and all dependencies will be copied to the specified directory.


Oh btw, isn't that what Apache Ivy is about? Extending Ant to understand Maven's dependency management?

like image 36
Sean Patrick Floyd Avatar answered Oct 21 '22 20:10

Sean Patrick Floyd