Skip to content

Commit e441c6b

Browse files
authored
Fix deprecations in Gradle 8.7 (#247)
1 parent 6a42045 commit e441c6b

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

build.xml

+3
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@
111111
<property name="maven-plugin-plugin.version" value="3.4"/>
112112
<property name="maven-compiler-plugin.version" value="3.8.1"/>
113113

114+
<!-- extra properties (prefixed by "gradle." added to gradle.properties during testing: -->
115+
<property name="gradle.org.gradle.warning.mode" value="all"/>
116+
114117
<!-- with fork=false this somehow takes endless to download the internet, so let's fork - and slow down in an other way (startup) -->
115118
<property name="maven.fork" value="true"/>
116119

src/main/groovy/de/thetaphi/forbiddenapis/gradle/ForbiddenApisPlugin.groovy

+5-2
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,12 @@ public class ForbiddenApisPlugin extends ForbiddenApisPluginBase {
4646
group = JavaBasePlugin.VERIFICATION_GROUP;
4747
}
4848

49+
// retrieve Java Extension, if it is not available fallback to project convention:
50+
def javaExtension = project.extensions.findByName('java') ?: project
51+
4952
// 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:
50-
Closure targetCompatibilityGetter = { (project.targetCompatibility?.hasProperty('java11Compatible') && project.targetCompatibility?.java11Compatible) ?
51-
project.targetCompatibility.toString() : project.targetCompatibility?.majorVersion };
53+
Closure targetCompatibilityGetter = { (javaExtension.targetCompatibility?.hasProperty('java11Compatible') && javaExtension.targetCompatibility?.java11Compatible) ?
54+
javaExtension.targetCompatibility.toString() : javaExtension.targetCompatibility?.majorVersion };
5255

5356
// Define our tasks (one for each SourceSet):
5457
project.sourceSets.all{ sourceSet ->

src/test/gradle/build.gradle

+10-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,16 @@ buildscript {
2929
apply plugin: 'java'
3030
apply plugin: 'de.thetaphi.forbiddenapis'
3131

32-
sourceCompatibility = forbiddenSourceCompatibility
32+
if (project.extensions.findByName('java')) {
33+
34+
java {
35+
sourceCompatibility = JavaVersion.toVersion(forbiddenSourceCompatibility)
36+
}
37+
38+
} else {
39+
// TODO: Remove this after Gradle 4.10
40+
sourceCompatibility = JavaVersion.toVersion(forbiddenSourceCompatibility)
41+
}
3342

3443
sourceSets {
3544
main {

0 commit comments

Comments
 (0)