Skip to content

Commit eeff8cc

Browse files
authored
[Example Builds] Fix Jarhell in example build due to version conflict (#135598) (#135647)
* [Example Builds] Fix Jarhell in example build due to version conflict In test framework we expose org.hamcrest:hamcrest. Transitively junit and the randomized runner expose hamcrest-core transitive dependencies. This makes jarHell task fail as those jars share common class files. We exclude hamcrest core now explicitly as transitive dependency in the generated pom for test framework as we already include a superset of this by having a direct dependency on hamcrest which includes hamcrest-core * Cleanup * Rework excluded transitive dependencies
1 parent 9f40e53 commit eeff8cc

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

test/framework/build.gradle

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,29 @@
1010
apply plugin: 'elasticsearch.build'
1111
apply plugin: 'elasticsearch.publish'
1212

13-
configurations {
14-
// we do not want to expose a version conflict in transitive dependencies by
15-
// bringing in different versions of hamcrest and hamcrest-core.
16-
// Therefore we exclude transitive deps on hamcrest-core here as we have a direct
17-
// dependency on a newer version.
18-
runtimeElements {
19-
exclude group: 'org.hamcrest', module: 'hamcrest-core'
20-
}
21-
}
2213
dependencies {
2314
api project(":client:rest")
2415
api project(':modules:transport-netty4')
2516
api project(':libs:ssl-config')
2617
api project(":server")
2718
api project(":libs:cli")
2819
api project(":libs:entitlement:bridge")
29-
api "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${versions.randomizedrunner}"
30-
api("junit:junit:${versions.junit}") {
31-
// exclude group: 'org.hamcrest'
20+
api ("com.carrotsearch.randomizedtesting:randomizedtesting-runner:${versions.randomizedrunner}") {
21+
exclude group: "junit", module: "junit"
3222
}
23+
24+
// we do not want to expose a version conflict in transitive dependencies by
25+
// bringing in different versions of dependencies.
26+
// Therefore we exclude mismatches in our transitive dependencies explicitly.
27+
// This also avoids jarHell issues with different hamcrest related dependencies
28+
// like hamcrest and hamcrest-core
3329
api "org.hamcrest:hamcrest:${versions.hamcrest}"
30+
api("junit:junit:${versions.junit}") {
31+
exclude group: 'org.hamcrest', module: 'hamcrest-core'
32+
}
3433
api("org.apache.lucene:lucene-test-framework:${versions.lucene}") {
35-
// exclude group: 'org.hamcrest'
34+
exclude group: "junit", module: "junit"
35+
exclude group: 'com.carrotsearch.randomizedtesting', module: 'randomizedtesting-runner'
3636
}
3737
api "org.apache.lucene:lucene-codecs:${versions.lucene}"
3838
api "commons-logging:commons-logging:${versions.commonslogging}"

0 commit comments

Comments
 (0)