From a620aa11370bf6fd8d546dc13921868d0601bbb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20Kalici=C5=84ski?= Date: Mon, 16 Sep 2024 15:33:02 +0200 Subject: [PATCH] Move checkstyle settings to plugin --- .../pubnub/gradle/PubNubJavaLibraryPlugin.kt | 23 +++++++++++++++++++ pubnub-gson/build.gradle.kts | 16 ------------- pubnub-gson/pubnub-gson-api/build.gradle.kts | 18 --------------- pubnub-gson/pubnub-gson-impl/build.gradle.kts | 17 -------------- 4 files changed, 23 insertions(+), 51 deletions(-) diff --git a/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubJavaLibraryPlugin.kt b/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubJavaLibraryPlugin.kt index 9017fed50..2748525e6 100644 --- a/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubJavaLibraryPlugin.kt +++ b/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubJavaLibraryPlugin.kt @@ -3,8 +3,14 @@ package com.pubnub.gradle import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.api.plugins.JavaLibraryPlugin +import org.gradle.api.plugins.quality.Checkstyle +import org.gradle.api.plugins.quality.CheckstyleExtension +import org.gradle.api.plugins.quality.CheckstylePlugin +import org.gradle.api.tasks.SourceSetContainer import org.gradle.api.tasks.compile.JavaCompile import org.gradle.kotlin.dsl.apply +import org.gradle.kotlin.dsl.configure +import org.gradle.kotlin.dsl.getByType import org.gradle.kotlin.dsl.withType class PubNubJavaLibraryPlugin : Plugin { @@ -12,10 +18,27 @@ class PubNubJavaLibraryPlugin : Plugin { with(target) { apply() apply() + apply() tasks.withType().configureEach { it.options.compilerArgs.add("-parameters") } + + extensions.configure { + toolVersion = "8.14" + configFile = rootProject.file("config/checkstyle/checkstyle.xml") + sourceSets = listOf(extensions.getByType().getByName("main")) + } + + tasks.withType().configureEach { + it.exclude("**/vendor/**", "**/*Test*") + + it.reports { report -> + report.xml.required.set(true) + report.html.required.set(true) + } + } + } } } \ No newline at end of file diff --git a/pubnub-gson/build.gradle.kts b/pubnub-gson/build.gradle.kts index 820ad92f4..8d6adc4fe 100644 --- a/pubnub-gson/build.gradle.kts +++ b/pubnub-gson/build.gradle.kts @@ -1,5 +1,4 @@ plugins { - checkstyle alias(libs.plugins.benmanes.versions) alias(libs.plugins.lombok) id("pubnub.java-library") @@ -10,18 +9,3 @@ dependencies { api(project(":pubnub-gson:pubnub-gson-api")) implementation(project(":pubnub-gson:pubnub-gson-impl")) } - -checkstyle { - toolVersion = "8.14" - configFile = rootProject.file("config/checkstyle/checkstyle.xml") - sourceSets = listOf(project.sourceSets.getByName("main")) -} - -tasks.withType().configureEach { - exclude("**/vendor/**", "**/*Test*") - - reports { - xml.required = true - html.required = true - } -} diff --git a/pubnub-gson/pubnub-gson-api/build.gradle.kts b/pubnub-gson/pubnub-gson-api/build.gradle.kts index e3e6f8554..26b655734 100644 --- a/pubnub-gson/pubnub-gson-api/build.gradle.kts +++ b/pubnub-gson/pubnub-gson-api/build.gradle.kts @@ -1,5 +1,4 @@ plugins { - checkstyle alias(libs.plugins.benmanes.versions) alias(libs.plugins.lombok) id("pubnub.java-library") @@ -9,23 +8,6 @@ plugins { dependencies { api(project(":pubnub-kotlin:pubnub-kotlin-api")) -// implementation(project(":pubnub-core:pubnub-core-impl")) - implementation(libs.slf4j) implementation(libs.jetbrains.annotations) } - -checkstyle { - toolVersion = "8.14" - configFile = rootProject.file("config/checkstyle/checkstyle.xml") - sourceSets = listOf(project.sourceSets.getByName("main")) -} - -tasks.withType().configureEach { - exclude("**/vendor/**", "**/*Test*") - - reports { - xml.required = true - html.required = true - } -} diff --git a/pubnub-gson/pubnub-gson-impl/build.gradle.kts b/pubnub-gson/pubnub-gson-impl/build.gradle.kts index 63db7389e..6149efe4a 100644 --- a/pubnub-gson/pubnub-gson-impl/build.gradle.kts +++ b/pubnub-gson/pubnub-gson-impl/build.gradle.kts @@ -1,5 +1,4 @@ plugins { - checkstyle alias(libs.plugins.benmanes.versions) alias(libs.plugins.lombok) id("pubnub.java-library") @@ -10,7 +9,6 @@ plugins { } dependencies { -// api(project(":pubnub-kotlin:pubnub-kotlin-api")) api(project(":pubnub-gson:pubnub-gson-api")) implementation(project(":pubnub-kotlin:pubnub-kotlin-impl")) @@ -32,18 +30,3 @@ dependencies { testImplementation("com.google.guava:guava:33.3.0-jre") "integrationTestImplementation"(libs.owner) } - -checkstyle { - toolVersion = "8.14" - configFile = rootProject.file("config/checkstyle/checkstyle.xml") - sourceSets = listOf(project.sourceSets.getByName("main")) -} - -tasks.withType().configureEach { - exclude("**/vendor/**", "**/*Test*") - - reports { - xml.required = true - html.required = true - } -}