I am trying to add the checkerframework to my multilevel project. All works well but I want to implement it by not creating tasks unnecessarily until needed.
See the official Gradle task avoidance page.
To keep things as simple as possible I created a empty Gradle project with no sub projects 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
Saying yes to upload it, click the link provided, enter email and opening the build scan link.
Navigating to:
- the performance tab
- the configuration tab
I can see next to the checker framework that 1 task was created.
We had a look and it looks 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
}
How to use the plugin to avoid this?