Skip to content

Commit d2aceef

Browse files
committed
add support to extend eager test task classpaths
1 parent 87c2493 commit d2aceef

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

buildSrc/src/main/java/org/elasticsearch/gradle/util/GradleUtils.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,19 @@ public static void extendSourceSet(Project project, String parentSourceSetName,
196196
child.setRuntimeClasspath(project.getObjects().fileCollection().from(child.getRuntimeClasspath(), parent.getOutput()));
197197
}
198198

199+
/**
200+
* Extends one configuration from another and refreshes the classpath of a provided Test.
201+
* The Test parameter is only needed for eagerly defined test tasks.
202+
*/
203+
public static void extendSourceSet(Project project, String parentSourceSetName, String childSourceSetName, Test test) {
204+
extendSourceSet(project, parentSourceSetName, childSourceSetName);
205+
if (test != null) {
206+
SourceSetContainer sourceSets = project.getExtensions().getByType(SourceSetContainer.class);
207+
SourceSet child = sourceSets.getByName(childSourceSetName);
208+
test.setClasspath(child.getRuntimeClasspath());
209+
}
210+
}
211+
199212
public static Dependency projectDependency(Project project, String projectPath, String projectConfig) {
200213
if (project.findProject(projectPath) == null) {
201214
throw new GradleException("no project [" + projectPath + "], project names: " + project.getRootProject().getAllprojects());

qa/die-with-dignity/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ esplugin {
1010
}
1111

1212
// let the javaRestTest see the classpath of main
13-
GradleUtils.extendSourceSet(project, "main", "javaRestTest")
13+
GradleUtils.extendSourceSet(project, "main", "javaRestTest", javaRestTest)
1414

1515
javaRestTest {
1616
systemProperty 'tests.security.manager', 'false'

x-pack/plugin/deprecation/qa/rest/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ dependencies {
1414
}
1515

1616
// let the javaRestTest see the classpath of main
17-
GradleUtils.extendSourceSet(project, "main", "javaRestTest")
17+
GradleUtils.extendSourceSet(project, "main", "javaRestTest", javaRestTest)
1818

1919

2020
restResources {

x-pack/plugin/ilm/qa/multi-node/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ dependencies {
77
}
88

99
// let the javaRestTest see the classpath of main
10-
GradleUtils.extendSourceSet(project, "main", "javaRestTest")
10+
GradleUtils.extendSourceSet(project, "main", "javaRestTest", javaRestTest)
1111

1212

1313
File repoDir = file("$buildDir/testclusters/repo")

0 commit comments

Comments
 (0)