Skip to content

Commit 7d61f2c

Browse files
authored
Simplify test artifact compile classpath (#78238) (#78429)
- This fixes having transitive compile only dependencies on the classpath for consumers of test artifacts - We remove compile dependencies from the testArtifact configuration dependencies here as this leaks implementation and compile only deps to consuming projects
1 parent 30f0bd8 commit 7d61f2c

File tree

32 files changed

+105
-18
lines changed

32 files changed

+105
-18
lines changed

build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/InternalTestArtifactExtension.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ public void registerTestArtifactFromSourceSet(SourceSet sourceSet) {
3939
featureSpec.disablePublication();
4040
});
4141

42-
Configuration testApiElements = project.getConfigurations().getByName(sourceSet.getApiElementsConfigurationName());
43-
testApiElements.extendsFrom(project.getConfigurations().getByName(sourceSet.getCompileClasspathConfigurationName()));
4442
DependencyHandler dependencies = project.getDependencies();
4543
project.getPlugins().withType(JavaPlugin.class, javaPlugin -> {
4644
Dependency projectDependency = dependencies.create(project);

x-pack/plugin/analytics/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ esplugin {
88
archivesBaseName = 'x-pack-analytics'
99

1010
dependencies {
11-
compileOnly project(":server")
12-
11+
api 'org.apache.commons:commons-math3:3.6.1'
1312
compileOnly project(path: xpackModule('core'))
13+
compileOnly project(":server")
1414
testImplementation(testArtifact(project(xpackModule('core'))))
15-
api 'org.apache.commons:commons-math3:3.6.1'
15+
testImplementation(project(":client:rest-high-level"))
1616
}
1717

x-pack/plugin/async-search/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ dependencies {
1616
compileOnly project(path: xpackModule('core'))
1717
testImplementation(testArtifact(project(xpackModule('core'))))
1818
testImplementation project(path: xpackModule('async'))
19+
20+
internalClusterTestImplementation project(":modules:reindex")
1921
}
2022

2123

x-pack/plugin/async-search/qa/security/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ dependencies {
44
javaRestTestImplementation(testArtifact(project(xpackModule('core'))))
55
javaRestTestImplementation project(xpackModule('async-search'))
66
javaRestTestImplementation project(':test:framework')
7+
javaRestTestImplementation project(":client:rest-high-level")
78
}
89

910
testClusters.configureEach {

x-pack/plugin/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ archivesBaseName = 'x-pack'
1313

1414
dependencies {
1515
testImplementation(testArtifact(project(xpackModule('core'))))
16+
testImplementation project(':test:framework')
1617
}
1718

1819
// let the yamlRestTest see the classpath of test

x-pack/plugin/ccr/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ dependencies {
3333
compileOnly project(path: xpackModule('core'))
3434
testImplementation(testArtifact(project(xpackModule('core'))))
3535
testImplementation(testArtifact(project(xpackModule('monitoring'))))
36+
testImplementation(project(":modules:analysis-common"))
3637
}
3738

3839
tasks.named("testingConventions").configure {

x-pack/plugin/eql/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ dependencies {
3131
testImplementation project(path: ':plugins:transport-nio') // for http in RestEqlCancellationIT
3232

3333
testImplementation 'io.ous:jtoml:2.0.0'
34+
35+
internalClusterTestImplementation project(":client:rest-high-level")
3436
}
3537

3638

x-pack/plugin/eql/qa/common/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ dependencies {
66
api project(path: xpackModule('core'))
77
api(testArtifact(project(xpackModule('core'))))
88
api project(xpackModule('ql:test-fixtures'))
9-
9+
implementation project(":client:rest-high-level")
1010
// TOML parser for EqlActionIT tests
1111
api 'io.ous:jtoml:2.0.0'
1212
}

x-pack/plugin/eql/qa/correctness/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ dependencies {
1010
javaRestTestImplementation project(':test:framework')
1111
javaRestTestImplementation(testArtifact(project(xpackModule('core'))))
1212
javaRestTestImplementation project(xpackModule('ql:test-fixtures'))
13+
javaRestTestImplementation project(":client:rest-high-level")
1314
javaRestTestImplementation 'io.ous:jtoml:2.0.0'
1415
}
1516

x-pack/plugin/identity-provider/build.gradle

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ archivesBaseName = 'x-pack-identity-provider'
1313

1414
dependencies {
1515
compileOnly project(path: xpackModule('core'))
16-
testImplementation(testArtifact(project(xpackModule('core'))))
17-
// So that we can extend LocalStateCompositeXPackPlugin
18-
testImplementation(testArtifact(project(xpackModule('security'))))
16+
1917
// the following are all SAML dependencies - might as well download the whole internet
2018
api "org.opensaml:opensaml-core:3.4.5"
2119
api "org.opensaml:opensaml-saml-api:3.4.5"
@@ -49,6 +47,12 @@ dependencies {
4947

5048
testImplementation 'org.elasticsearch:securemock:1.2'
5149
testImplementation "org.elasticsearch:mocksocket:${versions.mocksocket}"
50+
testImplementation(testArtifact(project(xpackModule('core'))))
51+
// So that we can extend LocalStateCompositeXPackPlugin
52+
testImplementation(testArtifact(project(xpackModule('security'))))
53+
testImplementation project(':modules:lang-mustache')
54+
internalClusterTestImplementation project(":modules:analysis-common")
55+
5256
}
5357

5458
tasks.named("dependencyLicenses").configure {

0 commit comments

Comments
 (0)