From 535e9868143564f1b54a7b0aebd14bccdc41f085 Mon Sep 17 00:00:00 2001 From: Josh Cummings Date: Tue, 21 Mar 2023 16:38:59 -0600 Subject: [PATCH] Add JavaFormat Checkstyle to Build Issue gh-744 --- build.gradle | 16 +++++++- etc/checkstyle/checkstyle-suppressions.xml | 46 ++++++++++++++++++++++ etc/checkstyle/checkstyle.xml | 30 ++++++++++++++ etc/checkstyle/header.txt | 16 ++++++++ gradle.properties | 1 + 5 files changed, 107 insertions(+), 2 deletions(-) create mode 100644 etc/checkstyle/checkstyle-suppressions.xml create mode 100644 etc/checkstyle/checkstyle.xml create mode 100644 etc/checkstyle/header.txt diff --git a/build.gradle b/build.gradle index ad64d384..7d860adf 100644 --- a/build.gradle +++ b/build.gradle @@ -17,7 +17,7 @@ buildscript { classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.28.2" classpath 'org.hidetake:gradle-ssh-plugin:2.10.1' classpath 'io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.30.0' - classpath 'io.spring.javaformat:spring-javaformat-gradle-plugin:0.0.38' + classpath "io.spring.javaformat:spring-javaformat-gradle-plugin:$springJavaformatVersion" } } @@ -67,10 +67,22 @@ s101 { allprojects { if (!['spring-ldap-bom', 'spring-security-docs'].contains(project.name)) { apply plugin: 'io.spring.javaformat' + apply plugin: 'checkstyle' + + pluginManager.withPlugin("io.spring.convention.checkstyle", { plugin -> + configure(plugin) { + dependencies { + checkstyle "io.spring.javaformat:spring-javaformat-checkstyle:$springJavaformatVersion" + } + checkstyle { + toolVersion = '8.34' + } + } + }) if (project.name.contains('sample')) { tasks.whenTaskAdded { task -> - if (task.name.contains('format') || task.name.contains('checkFormat')) { + if (task.name.contains('format') || task.name.contains('checkFormat') || task.name.contains('checkstyle')) { task.enabled = false } } diff --git a/etc/checkstyle/checkstyle-suppressions.xml b/etc/checkstyle/checkstyle-suppressions.xml new file mode 100644 index 00000000..b14c17dd --- /dev/null +++ b/etc/checkstyle/checkstyle-suppressions.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/etc/checkstyle/checkstyle.xml b/etc/checkstyle/checkstyle.xml new file mode 100644 index 00000000..1b825eca --- /dev/null +++ b/etc/checkstyle/checkstyle.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/etc/checkstyle/header.txt b/etc/checkstyle/header.txt new file mode 100644 index 00000000..1974e99b --- /dev/null +++ b/etc/checkstyle/header.txt @@ -0,0 +1,16 @@ +^\Q/*\E$ +^\Q * Copyright \E20\d\d-20\d\d the original author or authors.$ +^\Q *\E$ +^\Q * Licensed under the Apache License, Version 2.0 (the "License");\E$ +^\Q * you may not use this file except in compliance with the License.\E$ +^\Q * You may obtain a copy of the License at\E$ +^\Q *\E$ +^\Q * https://www.apache.org/licenses/LICENSE-2.0\E$ +^\Q *\E$ +^\Q * Unless required by applicable law or agreed to in writing, software\E$ +^\Q * distributed under the License is distributed on an "AS IS" BASIS,\E$ +^\Q * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\E$ +^\Q * See the License for the specific language governing permissions and\E$ +^\Q * limitations under the License.\E$ +^\Q */\E$ +^$ diff --git a/gradle.properties b/gradle.properties index f77617ab..90c4e3b7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,3 @@ version=3.1.0-SNAPSHOT +springJavaformatVersion=0.0.38 org.gradle.caching=true