checkerframework-gradle-plugin
checkerframework-gradle-plugin copied to clipboard
Cannot implement checkerframework by using task avoidance
I want to implement the checker framework and not create unnecessary tasks until it is needed. Hence for any changes made to our gradle build we run a gradle build scan to try and avoid task creation. See Gradle's avoidance page.
To keep things as simple as possible I created an empty Gradle project and modified the build.gradle.kts file to look as follows:
plugins {
id("java")
id("org.checkerframework") version "0.6.35"
}
apply(plugin = "org.checkerframework")
checkerFramework {
checkers = listOf("org.checkerframework.checker.nullness.NullnessChecker")
excludeTests = true
}
dependencies {
compileOnly("org.checkerframework:checker-qual:3.41.0")
testCompileOnly("org.checkerframework:checker-qual:3.41.0")
checkerFramework("org.checkerframework:checker:3.41.0")
}
Running a build scan via the command line .\gradlew.bat help --scan
I can see that the task "createCheckerFrameworkManifest" gets created everytime. If it is a multi level project this gets created per subproject.
Had a look and it seems to be in the CheckerFrameworkPlugin.groovy
class where the findByName
method will go and create the task every time:
// To keep the plugin idempotent, check if the task already exists.
def createManifestTask = project.tasks.findByName(checkerFrameworkManifestCreationTaskName)
if (createManifestTask == null) {
createManifestTask = project.task(checkerFrameworkManifestCreationTaskName, type: CreateManifestTask)
createManifestTask.checkers = userConfig.checkers
createManifestTask.incrementalize = userConfig.incrementalize
}
Is there any future plans to make the plugin task avoidance
compliant?
Sorry you're running into some build performance degradation while using the plugin.
Is there any future plans to make the plugin task avoidance compliant?
While I would love to do so, it hasn't been a priority for us. I think this code is old enough now that it may predate the task avoidance API (or it was in preview at the time); as I recall, creating the manifest task (but not doing more) was the best we could do to lazily avoid configuration when this code was written. But, that was several years ago at this point, so I'm sure it could use an update.
I'd certainly welcome a PR that adds task avoidance, if this is something you're interested in contributing. If not, we can leave this issue open and I can try to make the upgrade when I get a chance (but that may not be for some time).