From b3468594516a9c116ba2a316ca41bec9a05381e9 Mon Sep 17 00:00:00 2001 From: Lucas Pedroza Date: Mon, 4 Nov 2024 13:49:29 +0100 Subject: [PATCH] Add checkstyle config --- .github/workflows/gradle-test.yml | 3 + build.gradle | 22 +- config/checkstyle/checkstyle.xml | 433 ++++++++++++++++++++++++++++++ 3 files changed, 455 insertions(+), 3 deletions(-) create mode 100644 config/checkstyle/checkstyle.xml diff --git a/.github/workflows/gradle-test.yml b/.github/workflows/gradle-test.yml index e9d1ac5e..8220f95d 100644 --- a/.github/workflows/gradle-test.yml +++ b/.github/workflows/gradle-test.yml @@ -23,6 +23,9 @@ jobs: java-version: '17' distribution: corretto + - name: Run checkstyle + run: ./gradlew checkstyleMain + - name: Run Gradle test run: ./gradlew test -i diff --git a/build.gradle b/build.gradle index 1ac2222e..e9599676 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,9 @@ +import com.vanniktech.maven.publish.SonatypeHost + plugins { + id 'checkstyle' id 'java' + // this is a hopefully temporary plugin until maven central can add official gradle support id 'com.vanniktech.maven.publish' version '0.29.0' } @@ -47,7 +51,7 @@ dependencies { } mavenPublishing { - publishToMavenCentral(com.vanniktech.maven.publish.SonatypeHost.CENTRAL_PORTAL) + publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) signAllPublications() coordinates(project.group, project.name, project.version) @@ -88,13 +92,13 @@ mavenPublishing { // tasks -task printVersion { +tasks.register('printVersion') { doLast { println project.version } } -task writeProps(type: WriteProperties) { +tasks.register('writeProps', WriteProperties) { destinationFile = file("src/main/resources/version.properties") encoding = 'UTF-8' property('version', project.version) @@ -109,5 +113,17 @@ tasks.register('packageJar', Zip) { } } +checkstyle { + toolVersion = '10.19.0' // Latest Checkstyle version at the time of writing + ignoreFailures = false +} + +tasks.withType(Checkstyle).configureEach { + reports { + xml.required = false + html.required = true + } +} + processResources.dependsOn(writeProps) sourcesJar.dependsOn(writeProps) diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml new file mode 100644 index 00000000..0b4e9122 --- /dev/null +++ b/config/checkstyle/checkstyle.xml @@ -0,0 +1,433 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file