From d87a20aabcc9e79dbf7d684bfcdcd50f8209d275 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20August=C3=BDn?= Date: Fri, 22 Dec 2023 10:01:07 +0100 Subject: [PATCH] chore: deprecations handled --- build.gradle | 4 +++- .../groovy/cz/augi/gradle/scalafmt/ScalafmtPlugin.groovy | 7 +++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/build.gradle b/build.gradle index 7797faf..5fafc37 100644 --- a/build.gradle +++ b/build.gradle @@ -34,7 +34,9 @@ test { } } -sourceCompatibility = JavaVersion.VERSION_1_8 +java { + sourceCompatibility = JavaVersion.VERSION_1_8 +} project.ext.set('gradle.publish.key', System.getenv('GRADLE_PORTAL_KEY')) project.ext.set('gradle.publish.secret', System.getenv('GRADLE_PORTAL_SECRET')) diff --git a/src/main/groovy/cz/augi/gradle/scalafmt/ScalafmtPlugin.groovy b/src/main/groovy/cz/augi/gradle/scalafmt/ScalafmtPlugin.groovy index d34384e..96ba3e9 100644 --- a/src/main/groovy/cz/augi/gradle/scalafmt/ScalafmtPlugin.groovy +++ b/src/main/groovy/cz/augi/gradle/scalafmt/ScalafmtPlugin.groovy @@ -4,7 +4,7 @@ import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.api.Task import org.gradle.api.plugins.JavaBasePlugin -import org.gradle.api.plugins.JavaPluginConvention +import org.gradle.api.plugins.JavaPluginExtension class ScalafmtPlugin implements Plugin { @Override @@ -14,9 +14,8 @@ class ScalafmtPlugin implements Plugin { Task checkScalafmtAll = project.tasks.create('checkScalafmtAll') checkScalafmtAll.description = "Checks formatting of all source sets using scalafmt." PluginExtension extension = project.extensions.create('scalafmt', PluginExtension) - project.plugins.withType(JavaBasePlugin) { - def jpc = project.convention.getPlugin(JavaPluginConvention) - jpc.sourceSets.all { sourceSet -> + project.plugins.withType(JavaBasePlugin).configureEach { + project.extensions.getByType(JavaPluginExtension).sourceSets.configureEach { sourceSet -> def task = project.tasks.register(sourceSet.getTaskName("", "scalafmt"), ScalafmtTask, { it.sourceSet = sourceSet it.pluginExtension = extension