Gradle build clean-ups

- fix forbidden-apis task config
This commit is contained in:
Steve Ebersole 2022-03-15 16:24:07 -05:00
parent 8c052054a8
commit 58d4d8a6e1
1 changed files with 10 additions and 1 deletions

View File

@ -512,15 +512,24 @@ task forbiddenApisNonPortable(type: CheckForbiddenApis, dependsOn: compileJava)
task forbiddenApis
project.tasks.withType( CheckForbiddenApis ).each { task ->
task.outputs.dirs project.sourceSets.main.output.classesDirs
def outputFile = project.file( "${buildDir}/forbidden-apis/${task.name}-output.txt" )
task.classesDirs = project.sourceSets.main.output.classesDirs
task.classpath = project.sourceSets.main.compileClasspath + project.sourceSets.main.runtimeClasspath
task.targetCompatibility = project.forbiddenAPITargetJDKCompatibility
task.outputs.file outputFile
// This slows down the checks a little, but is necessary to avoid the gradle deamon holding on
// to class definitions loaded previously - even possibly in a previous build.
task.disableClassloadingCache = true
tasks.forbiddenApis.finalizedBy task
task.doLast {
outputFile.parentFile.mkdirs()
outputFile.createNewFile()
}
}
project.tasks.check.finalizedBy tasks.forbiddenApis