Skip to content

Commit

Permalink
Move checkstyle settings to plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
wkal-pubnub committed Sep 16, 2024
1 parent c89fee1 commit a620aa1
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,42 @@ 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<Project> {
override fun apply(target: Project) {
with(target) {
apply<PubNubSharedPlugin>()
apply<JavaLibraryPlugin>()
apply<CheckstylePlugin>()

tasks.withType<JavaCompile>().configureEach {
it.options.compilerArgs.add("-parameters")
}

extensions.configure<CheckstyleExtension> {
toolVersion = "8.14"
configFile = rootProject.file("config/checkstyle/checkstyle.xml")
sourceSets = listOf(extensions.getByType<SourceSetContainer>().getByName("main"))
}

tasks.withType<Checkstyle>().configureEach {
it.exclude("**/vendor/**", "**/*Test*")

it.reports { report ->
report.xml.required.set(true)
report.html.required.set(true)
}
}

}
}
}
16 changes: 0 additions & 16 deletions pubnub-gson/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
plugins {
checkstyle
alias(libs.plugins.benmanes.versions)
alias(libs.plugins.lombok)
id("pubnub.java-library")
Expand All @@ -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<Checkstyle>().configureEach {
exclude("**/vendor/**", "**/*Test*")

reports {
xml.required = true
html.required = true
}
}
18 changes: 0 additions & 18 deletions pubnub-gson/pubnub-gson-api/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
plugins {
checkstyle
alias(libs.plugins.benmanes.versions)
alias(libs.plugins.lombok)
id("pubnub.java-library")
Expand All @@ -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<Checkstyle>().configureEach {
exclude("**/vendor/**", "**/*Test*")

reports {
xml.required = true
html.required = true
}
}
17 changes: 0 additions & 17 deletions pubnub-gson/pubnub-gson-impl/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
plugins {
checkstyle
alias(libs.plugins.benmanes.versions)
alias(libs.plugins.lombok)
id("pubnub.java-library")
Expand All @@ -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"))

Expand All @@ -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<Checkstyle>().configureEach {
exclude("**/vendor/**", "**/*Test*")

reports {
xml.required = true
html.required = true
}
}

0 comments on commit a620aa1

Please sign in to comment.