Skip to content

Commit 4493e1f

Browse files
Merge pull request eugenp#17045 from martin-blazevic/article/BAEL-6373
[BAEL-6373] Why the Order of Maven Dependencies is Important
2 parents 75d606c + 01fb040 commit 4493e1f

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<artifactId>dependency-ordering</artifactId>
5+
6+
<parent>
7+
<artifactId>maven-modules</artifactId>
8+
<groupId>com.baeldung</groupId>
9+
<version>0.0.1-SNAPSHOT</version>
10+
</parent>
11+
12+
<dependencies>
13+
<dependency>
14+
<groupId>org.apache.poi</groupId>
15+
<artifactId>poi</artifactId>
16+
<version>5.3.0</version>
17+
</dependency>
18+
<!-- Change the order of dependencies to simulate the dependency ordering issue -->
19+
<dependency>
20+
<groupId>com.opencsv</groupId>
21+
<artifactId>opencsv</artifactId>
22+
<version>4.2</version>
23+
</dependency>
24+
</dependencies>
25+
26+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.baeldung.dependency.ordering;
2+
3+
import org.apache.commons.collections4.MapUtils;
4+
import org.junit.jupiter.api.Test;
5+
6+
import java.util.HashMap;
7+
8+
import static org.junit.jupiter.api.Assertions.assertEquals;
9+
10+
class DependencyOrderingUnitTest {
11+
12+
@Test
13+
void whenCorrectDependencyVersionIsUsed_thenShouldCompile() {
14+
assertEquals(0, MapUtils.size(new HashMap<>()));
15+
}
16+
}

maven-modules/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<modules>
1818
<module>animal-sniffer-mvn-plugin</module>
1919
<module>compiler-plugin-java-9</module>
20+
<module>dependency-ordering</module>
2021
<module>dependency-exclusion</module>
2122
<module>host-maven-repo-example</module>
2223
<module>jacoco-coverage-aggregation</module>

0 commit comments

Comments
 (0)