Skip to content

Commit d766b68

Browse files
authored
Set Java 9 checkstyle to depend on checkstyle conf (#28383)
We need to configure the Java 9 checkstyle task to depend on the checkstyle configuration task or the task could run before the checkstyle conf has been copied leading to runtime failures. We have to do this after projects have been evaluated because the configuration of these tasks can occur before the Java 9 source set has been added to a project.
1 parent ff09c82 commit d766b68

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

buildSrc/src/main/groovy/org/elasticsearch/gradle/precommit/PrecommitTasks.groovy

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import de.thetaphi.forbiddenapis.gradle.ForbiddenApisPlugin
2222
import org.gradle.api.Project
2323
import org.gradle.api.Task
2424
import org.gradle.api.plugins.JavaBasePlugin
25+
import org.gradle.api.plugins.quality.Checkstyle
2526

2627
/**
2728
* Validation tasks which should be run before committing. These run before tests.
@@ -142,7 +143,7 @@ class PrecommitTasks {
142143
]
143144
toolVersion = 7.5
144145
}
145-
for (String taskName : ['checkstyleMain', 'checkstyleTest']) {
146+
for (String taskName : ['checkstyleMain', 'checkstyleJava9', 'checkstyleTest']) {
146147
Task task = project.tasks.findByName(taskName)
147148
if (task != null) {
148149
project.tasks['check'].dependsOn.remove(task)
@@ -154,6 +155,11 @@ class PrecommitTasks {
154155
}
155156
}
156157
}
158+
159+
project.tasks.withType(Checkstyle) {
160+
dependsOn(copyCheckstyleConf)
161+
}
162+
157163
return checkstyleTask
158164
}
159165

0 commit comments

Comments
 (0)