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.
This commit is contained in:
Jason Tedor 2018-03-20 09:08:12 -04:00 committed by GitHub
parent ff09c82319
commit d766b68f7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -22,6 +22,7 @@ import de.thetaphi.forbiddenapis.gradle.ForbiddenApisPlugin
import org.gradle.api.Project import org.gradle.api.Project
import org.gradle.api.Task import org.gradle.api.Task
import org.gradle.api.plugins.JavaBasePlugin import org.gradle.api.plugins.JavaBasePlugin
import org.gradle.api.plugins.quality.Checkstyle
/** /**
* Validation tasks which should be run before committing. These run before tests. * Validation tasks which should be run before committing. These run before tests.
@ -142,7 +143,7 @@ class PrecommitTasks {
] ]
toolVersion = 7.5 toolVersion = 7.5
} }
for (String taskName : ['checkstyleMain', 'checkstyleTest']) { for (String taskName : ['checkstyleMain', 'checkstyleJava9', 'checkstyleTest']) {
Task task = project.tasks.findByName(taskName) Task task = project.tasks.findByName(taskName)
if (task != null) { if (task != null) {
project.tasks['check'].dependsOn.remove(task) project.tasks['check'].dependsOn.remove(task)
@ -154,6 +155,11 @@ class PrecommitTasks {
} }
} }
} }
project.tasks.withType(Checkstyle) {
dependsOn(copyCheckstyleConf)
}
return checkstyleTask return checkstyleTask
} }