From b66eb642415ec81c490887a09df1368870c4951c Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Thu, 4 Apr 2024 22:04:33 +0200 Subject: [PATCH] Re-enable checkstyle configuration in project See gh-943 --- build.gradle | 2 +- buildSrc/build.gradle | 8 ++-- buildSrc/gradle.properties | 2 +- .../graphql/build/ConventionsPlugin.java | 2 + .../conventions/FormattingConventions.java | 10 ++-- src/checkstyle/checkstyle-suppressions.xml | 12 ++++- src/checkstyle/checkstyle.xml | 47 ++++--------------- 7 files changed, 31 insertions(+), 52 deletions(-) diff --git a/build.gradle b/build.gradle index 885b6496..c183d9f9 100644 --- a/build.gradle +++ b/build.gradle @@ -39,7 +39,7 @@ configure(moduleProjects) { } configurations { - dependencyManagement {6 + dependencyManagement { canBeConsumed = false canBeResolved = false visible = false diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index cbedf431..c7338a65 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -18,16 +18,16 @@ ext { } dependencies { - checkstyle "io.spring.javaformat:spring-javaformat-checkstyle:${javaFormatVersion}" + checkstyle("com.puppycrawl.tools:checkstyle:${checkstyle.toolVersion}") + checkstyle("io.spring.javaformat:spring-javaformat-checkstyle:${javaFormatVersion}") + implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}") implementation("org.jetbrains.kotlin:kotlin-compiler-embeddable:${kotlinVersion}") implementation("io.spring.javaformat:spring-javaformat-gradle-plugin:${javaFormatVersion}") } checkstyle { - def archive = configurations.checkstyle.filter { it.name.startsWith("spring-javaformat-checkstyle")} - config = resources.text.fromArchiveEntry(archive, "io/spring/javaformat/checkstyle/checkstyle.xml") - toolVersion = 8.11 + toolVersion = "10.12.4" } gradlePlugin { diff --git a/buildSrc/gradle.properties b/buildSrc/gradle.properties index 9a7bd463..f9c62e7e 100644 --- a/buildSrc/gradle.properties +++ b/buildSrc/gradle.properties @@ -1 +1 @@ -javaFormatVersion=0.0.28 \ No newline at end of file +javaFormatVersion=0.0.41 \ No newline at end of file diff --git a/buildSrc/src/main/java/org/springframework/graphql/build/ConventionsPlugin.java b/buildSrc/src/main/java/org/springframework/graphql/build/ConventionsPlugin.java index 59da5043..28479254 100644 --- a/buildSrc/src/main/java/org/springframework/graphql/build/ConventionsPlugin.java +++ b/buildSrc/src/main/java/org/springframework/graphql/build/ConventionsPlugin.java @@ -23,6 +23,7 @@ import org.gradle.api.plugins.JavaBasePlugin; import org.gradle.api.publish.maven.plugins.MavenPublishPlugin; import org.springframework.graphql.build.conventions.DeploymentConventions; +import org.springframework.graphql.build.conventions.FormattingConventions; import org.springframework.graphql.build.conventions.JavaConventions; import org.springframework.graphql.build.conventions.KotlinConventions; @@ -42,6 +43,7 @@ public class ConventionsPlugin implements Plugin { @Override public void apply(Project project) { + new FormattingConventions().apply(project); new JavaConventions().apply(project); new KotlinConventions().apply(project); new DeploymentConventions().apply(project); diff --git a/buildSrc/src/main/java/org/springframework/graphql/build/conventions/FormattingConventions.java b/buildSrc/src/main/java/org/springframework/graphql/build/conventions/FormattingConventions.java index 55471f46..30fb9b31 100644 --- a/buildSrc/src/main/java/org/springframework/graphql/build/conventions/FormattingConventions.java +++ b/buildSrc/src/main/java/org/springframework/graphql/build/conventions/FormattingConventions.java @@ -16,7 +16,6 @@ package org.springframework.graphql.build.conventions; -import io.spring.javaformat.gradle.FormatTask; import io.spring.javaformat.gradle.SpringJavaFormatPlugin; import org.gradle.api.Project; import org.gradle.api.artifacts.DependencySet; @@ -26,8 +25,7 @@ import org.gradle.api.plugins.quality.CheckstylePlugin; /** * Conventions that are applied in the presence of the {@link JavaBasePlugin}. When the - * plugin is applied, the {@link SpringJavaFormatPlugin Spring Java Format} and - * {@link CheckstylePlugin Checkstyle}. + * plugin is applied, {@link CheckstylePlugin Checkstyle} is applied and configured. * * @author Brian Clozel */ @@ -38,14 +36,14 @@ public class FormattingConventions { } private void applySpringJavaFormat(Project project) { - project.getPlugins().apply(SpringJavaFormatPlugin.class); - project.getTasks().withType(FormatTask.class, (formatTask) -> formatTask.setEncoding("UTF-8")); project.getPlugins().apply(CheckstylePlugin.class); CheckstyleExtension checkstyle = project.getExtensions().getByType(CheckstyleExtension.class); - checkstyle.setToolVersion("8.43"); + checkstyle.setToolVersion("10.12.4"); checkstyle.getConfigDirectory().set(project.getRootProject().file("src/checkstyle")); String version = SpringJavaFormatPlugin.class.getPackage().getImplementationVersion(); DependencySet checkstyleDependencies = project.getConfigurations().getByName("checkstyle").getDependencies(); + checkstyleDependencies + .add(project.getDependencies().create("com.puppycrawl.tools:checkstyle:" + checkstyle.getToolVersion())); checkstyleDependencies .add(project.getDependencies().create("io.spring.javaformat:spring-javaformat-checkstyle:" + version)); } diff --git a/src/checkstyle/checkstyle-suppressions.xml b/src/checkstyle/checkstyle-suppressions.xml index f21b4613..25a746ca 100644 --- a/src/checkstyle/checkstyle-suppressions.xml +++ b/src/checkstyle/checkstyle-suppressions.xml @@ -1,7 +1,15 @@ - + - \ No newline at end of file + + + + + + + diff --git a/src/checkstyle/checkstyle.xml b/src/checkstyle/checkstyle.xml index 2853a86c..dacac5c7 100644 --- a/src/checkstyle/checkstyle.xml +++ b/src/checkstyle/checkstyle.xml @@ -6,48 +6,19 @@ - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + - \ No newline at end of file +