Skip to content

Commit

Permalink
Add a hack for the broken JavaVersion enum in Gradle. It returns vers…
Browse files Browse the repository at this point in the history
…ion "1.9" and "1.10" (which are invalid targetCompatibility versions) and this problem is only fixed after Java 11. Before Java 11 we switch to plain "majorVersion" property. This closes #143
  • Loading branch information
uschindler committed Aug 29, 2018
1 parent 5772c9f commit 1a7d744
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ project.sourceSets.all{ sourceSet ->
}
classesDirs = { getSourceSetClassesDirs() }
classpath = { sourceSet.compileClasspath }
targetCompatibility = { project.targetCompatibility?.toString() }
// 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 }
}
// add dependency to compile task after evaluation, if the classesDirs collection has overlaps with our SourceSet:
project.afterEvaluate{
Expand Down

0 comments on commit 1a7d744

Please sign in to comment.