Skip to content

Commit

Permalink
Set Java 9 checkstyle to depend on checkstyle conf (#28383)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jasontedor committed Mar 20, 2018
1 parent e7af643 commit d8654c3
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import de.thetaphi.forbiddenapis.gradle.ForbiddenApisPlugin
import org.gradle.api.Project
import org.gradle.api.Task
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.
Expand Down Expand Up @@ -142,7 +143,7 @@ class PrecommitTasks {
]
toolVersion = 7.5
}
for (String taskName : ['checkstyleMain', 'checkstyleTest']) {
for (String taskName : ['checkstyleMain', 'checkstyleJava9', 'checkstyleTest']) {
Task task = project.tasks.findByName(taskName)
if (task != null) {
project.tasks['check'].dependsOn.remove(task)
Expand All @@ -154,6 +155,11 @@ class PrecommitTasks {
}
}
}

project.tasks.withType(Checkstyle) {
dependsOn(copyCheckstyleConf)
}

return checkstyleTask
}

Expand Down

0 comments on commit d8654c3

Please sign in to comment.