Skip to content

Commit 84835b2

Browse files
authored
[Example Builds] Fix Jarhell in example build due to version conflict (#135598) (#135646)
* [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 faf1025 commit 84835b2

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
@@ -11,29 +11,29 @@ import org.elasticsearch.gradle.internal.info.BuildParams;
1111
apply plugin: 'elasticsearch.build'
1212
apply plugin: 'elasticsearch.publish'
1313

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

0 commit comments

Comments
 (0)