Skip to content

Commit

Permalink
Workaround for #179
Browse files Browse the repository at this point in the history
  • Loading branch information
uschindler committed Mar 23, 2022
1 parent a7fe06c commit a70cb0e
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ forbiddenTask.configure {
group = JavaBasePlugin.VERIFICATION_GROUP;
}

// Gradle is buggy with it's JavaVersion enum: We use majorVersion property before Java 11 (6,7,8,9,10) and for later we use toString() to be future-proof:
Closure targetCompatibilityGetter = { (project.targetCompatibility?.hasProperty('java11Compatible') && project.targetCompatibility?.java11Compatible) ?
project.targetCompatibility.toString() : project.targetCompatibility?.majorVersion };

// Define our tasks (one for each SourceSet):
project.sourceSets.all{ sourceSet ->
String sourceSetTaskName = sourceSet.getTaskName(FORBIDDEN_APIS_TASK_NAME, null);
Expand All @@ -45,9 +49,7 @@ project.sourceSets.all{ sourceSet ->
}
classesDirs = { sourceSet.output.hasProperty('classesDirs') ? sourceSet.output.classesDirs : project.files(sourceSet.output.classesDir) }
classpath = { sourceSet.compileClasspath }
// Gradle is buggy with it's JavaVersion enum: We use majorVersion property before Java 11 (6,7,8,9,10) and for later we use toString() to be future-proof:
targetCompatibility = { (project.targetCompatibility?.hasProperty('java11Compatible') && project.targetCompatibility?.java11Compatible) ?
project.targetCompatibility.toString() : project.targetCompatibility?.majorVersion }
targetCompatibility = targetCompatibilityGetter
}
}
forbiddenTask.configure {
Expand Down

0 comments on commit a70cb0e

Please sign in to comment.