Reputation: 2357
I've just started a java project, in which I'd like to use the classes of another project.
My pom.xml
looks like this so far:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>...</groupId>
<artifactId>...</artifactId>
<version>...</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
What would be a good way to add that other project as a dependency in mine? Should I download all of its compiled jar
files and add them one by one in my pom.xml
as dependencies? Or is there a better option?
I was thinking of downloading all the jars
, putting them into a directory (e.g. lib
) and somehow referencing that entire directory in the pom.xml
, so if there's a new version of the project mine depends on, I only have to change the contents of that lib
folder for the new jars
, and don't have to edit the pom.xml
. Is it an option? If so, how to do that?
Or most importantly, what is the proper way you suggest doing it?
Upvotes: 1
Views: 111
Reputation: 7938
If you want to use the latest version of this project, I suggest you build it yourself. Because it seems they are releasing to Sourceforge and maintaining the code actively.
Each time you want to upgrade the version, you have to get the latest source code (via git) and use mvn install
command on this projects root pom.xml to install it to your local maven repo. This project is configured as multi module maven project, using install on the root pom.xml will install all the sub modules.
On your projects pom.xml you can use mvn versions:use-latest-releases
to update all your dependencies to the newest version. This command will automatically upgrade dependency versions for you.
To add a project as dependency follow Marvins link.
Upvotes: 3