From f7e5ea133595e911931f2a95b6fd99594f57261c Mon Sep 17 00:00:00 2001 From: Goooler Date: Wed, 6 Dec 2023 12:14:46 +0800 Subject: [PATCH] Use apply --- .../spotbugs/snom/SpotBugsBasePlugin.kt | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/main/kotlin/com/github/spotbugs/snom/SpotBugsBasePlugin.kt b/src/main/kotlin/com/github/spotbugs/snom/SpotBugsBasePlugin.kt index d487c8a3..c18fbe40 100644 --- a/src/main/kotlin/com/github/spotbugs/snom/SpotBugsBasePlugin.kt +++ b/src/main/kotlin/com/github/spotbugs/snom/SpotBugsBasePlugin.kt @@ -41,28 +41,28 @@ class SpotBugsBasePlugin : Plugin { } private fun createExtension(project: Project): SpotBugsExtension { - val extension = project.extensions.create(SpotBugsPlugin.EXTENSION_NAME, SpotBugsExtension::class.java) - extension.ignoreFailures.convention(false) - extension.showStackTraces.convention(false) - extension.projectName.convention(project.provider { project.name }) - extension.release.convention( - project.provider { - project.version.toString() - }, - ) + return project.extensions.create(SpotBugsPlugin.EXTENSION_NAME, SpotBugsExtension::class.java).apply { + ignoreFailures.convention(false) + showStackTraces.convention(false) + projectName.convention(project.provider { project.name }) + release.convention( + project.provider { + project.version.toString() + }, + ) - // ReportingBasePlugin should be applied before we create this SpotBugsExtension instance - val baseReportsDir = project.extensions.getByType(ReportingExtension::class.java).baseDirectory - extension.reportsDir.convention( - baseReportsDir.map { directory: Directory -> - directory.dir( - DEFAULT_REPORTS_DIR_NAME, - ) - }, - ) - extension.useAuxclasspathFile.convention(true) - extension.useJavaToolchains.convention(true) - return extension + // ReportingBasePlugin should be applied before we create this SpotBugsExtension instance + val baseReportsDir = project.extensions.getByType(ReportingExtension::class.java).baseDirectory + reportsDir.convention( + baseReportsDir.map { directory: Directory -> + directory.dir( + DEFAULT_REPORTS_DIR_NAME, + ) + }, + ) + useAuxclasspathFile.convention(true) + useJavaToolchains.convention(true) + } } private fun createConfiguration(