I have a project with two seperate modules that uses sqlline and another library(say OtherLib) that depends on jline. However on different versions.
I found a an answer here using maven-dependency-plugin
In pom.xml
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<id>copy-model</id>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>jline</groupId>
<artifactId>jline</artifactId>
<version>2.10</version>
<type>jar</type>
</artifactItem>
<artifactItems>
<outputDirectory>../../resources/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugins>
<build>
And in assembly.xml
<fileSet>
<directory>../../resources/lib</directory>
<outputDirectory>${HOME}/lib/module1</outputDirectory>
<directoryMode>755</directoryMode>
<fileMode>644</fileMode>
<includes>
<include>jline-*</include>
</includes>
</fileSet>
jline-0.9.94
is included in a dependencySet
as any other dependency.
I hope this helps. :)
If you're absolutely sure, what you're doing, you can repackage one of the version using something like maven-shade-plugin. But please be absolutely sure, what you're doing.
With maven-shade-plugin you could create a new Maven module, say jline:jline_2_10:jar:1.0
and use jline:jline:jar:2.10
as a dependency. The maven-shade-plugin would then package it in your jline_2_10-1.0.jar
.
Since your new artifact has its own groupId:artifactId
combination, there will be no conflicts with the other jline:jline:jar:0.9.94
artifact, so you'll happily have both in the classpath.