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:
parent
ff09c82319
commit
d766b68f7a
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue