Every question is the same:
After running
$ mvn assembly:single
on myproject's pom.xml
with assembly configuration
<assembly> ... <dependencySets> <dependencySet> <outputDirectory/> </dependencySet> </dependencySets> </assembly>
<project> <artifactId>myproject</artifactId> ... <dependencies> <dependency> <groupId>javassist</groupId> <artifactId>javassist</artifactId> <version>3.12.1.GA</version> </dependency> <dependency> <groupId>org.javassist</groupId> <artifactId>javassist</artifactId> <version>3.16.1-GA</version> </dependency> </dependencies> </project>
Which jars on the classpath?
Which jars on the classpath?
Ban outdated GAVs (groupId - artifactId)
<dependencies> <dependency> ... <exclusions> <exclusion> <groupId>javassist</groupId> <artifactId>javassist</artifactId> </exclusion> </exclusions> </dependency> ... </dependencies>
<project> <modelVersion>4.0.0</modelVersion> <groupId>javassist</groupId> <artifactId>javassist</artifactId> <version>3.16.1-GA</version> <distributionManagement> <relocation> <groupId>org.javassist</groupId> </relocation> </distributionManagement> </project>
<project> <artifactId>myparent</artifactId>... <dependencyManagement><dependencies> <dependency>... <artifactId>commons-lang</artifactId> <version>2.4</version> </dependency> </dependencies></dependencyManagement> <dependencies> <dependency>... <artifactId>commons-io</artifactId> <version>2.4</version> </dependency> </dependencies> </project> <project> <parent>... <artifactId>myparent</artifactId>... </parent> <artifactId>myproject</artifactId>... <dependencies> <dependency>... <artifactId>commons-lang</artifactId> <version>2.3</version> </dependency> <dependency>... <artifactId>commons-io</artifactId> <version>2.3</version> </dependency> </dependencies> </project>
Which jars on the classpath?
Which jars on the classpath?
<project> <artifactId>myparent</artifactId>... <dependencyManagement><dependencies> <dependency>... <artifactId>commons-lang</artifactId> <version>2.4</version> </dependency> <dependency>... <artifactId>commons-io</artifactId> <version>2.4</version> </dependency> </dependencies></dependencyManagement> </project> <project> <parent>... <artifactId>myparent</artifactId>... </parent> <artifactId>myproject</artifactId>... <dependencies> <dependency>... <artifactId>commons-lang</artifactId> <!-- No version specified --> </dependency> <dependency>... <artifactId>commons-io</artifactId> <!-- No version specified --> </dependency> </dependencies> </project>
<project> <artifactId>a</artifactId>... <dependencies> <dependency>... <artifactId>slf4j-api</artifactId> <version>1.7.0</version> </dependency> </dependencies> </project> <project> <artifactId>myproject</artifactId>... <dependencies> <dependency>... <artifactId>a</artifactId>... </dependency> <dependency>... <artifactId>slf4j-api</artifactId> <version>1.5.0</version> </dependency> </dependencies> </project>
Which jars on the classpath?
Which jars on the classpath?
Enforce that every (transitive) dependency is resolved to its specified version or higher.
<plugin> <artifactId>maven-enforcer-plugin</artifactId> <executions> <execution> <goals><goal>enforce</goal></goals> <configuration> <rules> <requireUpperBoundDeps/> </rules> </configuration> </execution> </executions> </plugin>
Failed while enforcing RequireUpperBoundDeps. The error(s) are [ Require upper bound dependencies error for org.slf4j:slf4j-api:1.5.0 paths to dependency are: +-...:myproject:1.0.0 +-org.slf4j:slf4j-api:1.5.0 and +-...:myproject:1.0.0 +-...:a:1.0.0 +-org.slf4j:slf4j-api:1.7.0 ]
<project>...<artifactId>a</>... <dependencies> <dependency>... <artifactId>drools-core</artifactId> <version>5.2.0.CR1</version> </dependency> </dependencies> </project> <project>...<artifactId>b</>... <dependencies> <dependency>... <artifactId>drools-core</artifactId> <version>5.2.0.M2</version> </dependency> </dependencies> </project> <project>...<artifactId>c</>... <dependencies> <dependency>... <artifactId>drools-core</artifactId> <version>5.2.0.Final</version> </dependency> </dependencies> </project> <project>...<artifactId>myproject</>... <dependencies> <dependency>...<artifactId>a</>...</> <dependency>...<artifactId>b</>...</> <dependency>...<artifactId>c</>...</> </dependencies> </project>
Which jars on the classpath?
Which jars on the classpath?
Later drools releases (5.3, 5.4, 5.5, ...)
no longer use M in version numbering.
Common sense solution:
Retain the highest version (using lexicographic comparison)
Maven 3.1 or Tesla could fix this with pluggable conflict resolution?
<project>...<artifactId>a</>... <dependencies> <dependency>... <artifactId>jbpm-flow</artifactId> <version>5.1.0.Final</version> </dependency> </dependencies> </project> <project>...<artifactId>yourparent</>... <dependencyManagement><dependencies> <dependency>... <artifactId>jbpm-flow</artifactId> <version>5.3.0.Final</version> </dependency> </dependencies></dependencyManagement> </project> <project>...<artifactId>yourproject</>... <parent>...<artifactId>yourparent</>...</parent> <dependencies> <dependency>... <artifactId>a</artifactId> </dependency> </dependencies> </project> <project>...<artifactId>myproject</>... <dependencies> <dependency>... <artifactId>yourproject</artifactId>... </dependency> </dependencies> </project>
Which jars on the classpath?
Which jars on the classpath?
<project> <artifactId>myproject</artifactId> ... <dependencies> <dependency> <-- Depends on: slf4j-api 1.6.1 ... --> <groupId>org.jboss.weld.se</groupId> <artifactId>weld-se-core</artifactId> <version>1.1.8.Final</version> </dependency> <dependency> <-- Duplicates: weld-se-core 1.1.4.Final slf4j-api 1.5.10 ... --> <groupId>org.jboss.weld.se</groupId> <artifactId>weld-se</artifactId> <version>1.1.4.Final</version> </dependency> </dependencies> </project>
Which jars on the classpath?
Which jars on the classpath?
Don't depend on fat jars.
<project> <artifactId>myproject</artifactId> ... <dependencies> <dependency> <groupId>org.jboss.weld.se</groupId> <-- <artifactId>weld-se</artifactId> is evil --> <artifactId>weld-se-core</artifactId> <version>1.1.8.Final</version> </dependency> </dependencies> </project>