From 2ac30fa98041fcbc29a31e9d93132c31bd7358c9 Mon Sep 17 00:00:00 2001 From: Andreas Svanberg <andreass@dsv.su.se> Date: Tue, 18 Mar 2025 09:12:41 +0100 Subject: [PATCH] Add Checkstyle checking during Maven build (#138) So far no rules are activated and it just puts the infrastructure in place. Rules can be added in separately after discussion among the developers, along with fixing any violations of the rules. Co-authored-by: Nico Athanassiadis <nico@dsv.su.se> Reviewed-on: https://gitea.dsv.su.se/DMC/scipro/pulls/138 Reviewed-by: Nico Athanassiadis <nico@dsv.su.se> Co-authored-by: Andreas Svanberg <andreass@dsv.su.se> Co-committed-by: Andreas Svanberg <andreass@dsv.su.se> --- Dockerfile | 1 + checkstyle.xml | 7 +++++++ pom.xml | 22 ++++++++++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 checkstyle.xml diff --git a/Dockerfile b/Dockerfile index acf3c889a3..71ff8ba3a5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,6 +24,7 @@ COPY test-data/src/ test-data/src/ RUN ./mvnw package \ --define skipTests \ --activate-profiles branch,DEV \ + --define checkstyle.skip=true \ --define skip.npm \ --define skip.installnodenpm diff --git a/checkstyle.xml b/checkstyle.xml new file mode 100644 index 0000000000..bd24b31e31 --- /dev/null +++ b/checkstyle.xml @@ -0,0 +1,7 @@ +<?xml version="1.0"?> +<!DOCTYPE module PUBLIC + "-//Checkstyle//DTD Checkstyle Configuration 1.3//EN" + "https://checkstyle.org/dtds/configuration_1_3.dtd"> + +<module name="Checker"> +</module> diff --git a/pom.xml b/pom.xml index 3473242939..8567faf79d 100755 --- a/pom.xml +++ b/pom.xml @@ -211,6 +211,11 @@ <artifactId>maven-war-plugin</artifactId> <version>3.4.0</version> </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-checkstyle-plugin</artifactId> + <version>3.6.0</version> + </plugin> </plugins> </pluginManagement> <plugins> @@ -312,6 +317,23 @@ </execution> </executions> </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-checkstyle-plugin</artifactId> + <configuration> + <configLocation>checkstyle.xml</configLocation> + <failOnViolation>true</failOnViolation> + </configuration> + <executions> + <execution> + <id>validate</id> + <phase>process-sources</phase> + <goals> + <goal>check</goal> + </goals> + </execution> + </executions> + </plugin> </plugins> </build> </project> \ No newline at end of file