From 04803dbbf407af4f951ab0d7f9b2a0caee666a8f Mon Sep 17 00:00:00 2001
From: Olivier Maury <olivier.maury@inrae.fr>
Date: Tue, 19 Dec 2023 15:20:20 +0100
Subject: [PATCH 1/9] Add new file

---
 .gitlab-ci.yml | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)
 create mode 100644 .gitlab-ci.yml

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
new file mode 100644
index 00000000..40a03261
--- /dev/null
+++ b/.gitlab-ci.yml
@@ -0,0 +1,53 @@
+variables:
+  MAVEN_OPTS: -Dmaven.repo.local=.m2/repository
+
+image: maven:latest
+
+stages:
+    - build
+    - test
+    - package
+    - deploy
+
+
+cache:
+  paths:
+    - .m2/repository
+    - target
+
+build_job:
+  stage: build
+  tags:
+    - docker 
+
+  script: 
+    - echo "Maven compile started"
+    - "mvn compile"
+
+
+test_job:
+  stage: test
+  tags:
+    - docker 
+
+  script: 
+    - echo "Maven test started"
+    - "mvn test"
+
+package_job:
+  stage: package
+  tags:
+    - docker 
+
+  script: 
+    - echo "Maven packaging started"
+    - "mvn package"
+
+
+Deploy_job:
+  stage: deploy
+  tags:
+    - docker 
+
+  script: 
+    - echo "Maven deploy started"
-- 
GitLab


From a8cc15ee635cb77d5874561231e19d8039e52ca5 Mon Sep 17 00:00:00 2001
From: Olivier Maury <olivier.maury@inrae.fr>
Date: Tue, 19 Dec 2023 15:43:56 +0100
Subject: [PATCH 2/9] =?UTF-8?q?Mettre=20=C3=A0=20jour=20le=20fichier=20.gi?=
 =?UTF-8?q?tlab-ci.yml?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .gitlab-ci.yml | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 40a03261..c8652469 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,7 +1,7 @@
 variables:
   MAVEN_OPTS: -Dmaven.repo.local=.m2/repository
 
-image: maven:latest
+image: maven:3.8-openjdk-17
 
 stages:
     - build
@@ -9,27 +9,22 @@ stages:
     - package
     - deploy
 
-
 cache:
   paths:
     - .m2/repository
-    - target
 
 build_job:
   stage: build
   tags:
     - docker 
-
   script: 
     - echo "Maven compile started"
     - "mvn compile"
 
-
 test_job:
   stage: test
   tags:
     - docker 
-
   script: 
     - echo "Maven test started"
     - "mvn test"
@@ -38,16 +33,15 @@ package_job:
   stage: package
   tags:
     - docker 
-
   script: 
     - echo "Maven packaging started"
     - "mvn package"
 
-
-Deploy_job:
+deploy_job:
   stage: deploy
+  only:
+    - main
   tags:
     - docker 
-
-  script: 
+  script:
     - echo "Maven deploy started"
-- 
GitLab


From fa79397bd23b42d1cdeb779bdf3c5bc6006b5cca Mon Sep 17 00:00:00 2001
From: Olivier Maury <olivier.maury@inrae.fr>
Date: Tue, 19 Dec 2023 16:37:08 +0100
Subject: [PATCH 3/9] Update .gitlab-ci.yml

---
 .gitlab-ci.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index c8652469..cbed1e0e 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,7 +1,7 @@
 variables:
   MAVEN_OPTS: -Dmaven.repo.local=.m2/repository
 
-image: maven:3.8-openjdk-17
+image: registry.forgemia.inra.fr/agroclim/common/docker-projets-java:latest
 
 stages:
     - build
-- 
GitLab


From fcf919579fcb761f77ce33d3b4340155a498fa9c Mon Sep 17 00:00:00 2001
From: Olivier Maury <olivier.maury@inrae.fr>
Date: Tue, 19 Dec 2023 16:44:36 +0100
Subject: [PATCH 4/9] Update sloccount.sh

---
 bin/sloccount.sh | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/bin/sloccount.sh b/bin/sloccount.sh
index 17ac45ee..788f2fa4 100755
--- a/bin/sloccount.sh
+++ b/bin/sloccount.sh
@@ -1,16 +1,22 @@
 #!/bin/bash
 TOKEI2CLOC=$(dirname $0)/tokei2cloc.py
-TOKEITGZ=tokei-v7.0.3-x86_64-unknown-linux-gnu.tar.gz
-if [ ! -f bin/tokei ]; then
-	mkdir -p ~/tmp
-	if [ ! -f ~/tmp/$TOKEITGZ ]; then
-		wget "https://github.com/Aaronepower/tokei/releases/download/v7.0.3/$TOKEITGZ" -O ~/tmp/$TOKEITGZ
+TOKEI=$(command -v tokei)
+if [ -x "$TOKEI" ]; then
+	echo "tokei is installed"
+else
+	TOKEITGZ=tokei-v7.0.3-x86_64-unknown-linux-gnu.tar.gz
+	if [ ! -f bin/tokei ]; then
+		mkdir -p ~/tmp
+		if [ ! -f ~/tmp/$TOKEITGZ ]; then
+			wget "https://github.com/Aaronepower/tokei/releases/download/v7.0.3/$TOKEITGZ" -O ~/tmp/$TOKEITGZ
+		fi
+		tar zxf ~/tmp/$TOKEITGZ -C bin
 	fi
-	tar zxf ~/tmp/$TOKEITGZ -C bin
+	TOKEI=bin/tokei
 fi
-if [ -f bin/tokei ]; then
+if [ -f $TOKEI ]; then
 	mkdir -p target
-	bin/tokei -f -o json src | $TOKEI2CLOC > target/cloc.xml
+	$TOKEI -f -o json src | $TOKEI2CLOC > target/cloc.xml
 	exit
 fi
 
-- 
GitLab


From bcef5bd496804810817fbae55f37eb6f701b54a8 Mon Sep 17 00:00:00 2001
From: Olivier Maury <olivier.maury@inrae.fr>
Date: Tue, 19 Dec 2023 16:52:12 +0100
Subject: [PATCH 5/9] Update sloccount.sh

---
 bin/sloccount.sh | 25 +++++++------------------
 1 file changed, 7 insertions(+), 18 deletions(-)

diff --git a/bin/sloccount.sh b/bin/sloccount.sh
index 788f2fa4..ddcf9cb0 100755
--- a/bin/sloccount.sh
+++ b/bin/sloccount.sh
@@ -1,9 +1,7 @@
 #!/bin/bash
 TOKEI2CLOC=$(dirname $0)/tokei2cloc.py
 TOKEI=$(command -v tokei)
-if [ -x "$TOKEI" ]; then
-	echo "tokei is installed"
-else
+if [ ! -x "$TOKEI" ]; then
 	TOKEITGZ=tokei-v7.0.3-x86_64-unknown-linux-gnu.tar.gz
 	if [ ! -f bin/tokei ]; then
 		mkdir -p ~/tmp
@@ -14,20 +12,11 @@ else
 	fi
 	TOKEI=bin/tokei
 fi
-if [ -f $TOKEI ]; then
-	mkdir -p target
-	$TOKEI -f -o json src | $TOKEI2CLOC > target/cloc.xml
-	exit
+if [ ! -f $TOKEI ]; then
+	echo "Strange, $TOKEI does not exist!"
+	exit 1
 fi
 
-SLOCCOUNT=$(which sloccount);
-if [ "$SLOCCOUNT" != "" ]; then
-	DATADIR=$(dirname $0)/.slocdata;
-	if [ ! -f $DATADIR ]; then
-		mkdir -p $DATADIR;
-	fi
-	mkdir -p target ;
-	/usr/bin/sloccount --datadir $DATADIR --duplicates --wide --details src > target/sloccount.sc;
-else 
-	echo "sloccount not found!";
-fi
+echo "tokei is installed at $TOKEI"
+mkdir -p target
+$TOKEI -f -o json src | $TOKEI2CLOC > target/cloc.xml
-- 
GitLab


From 376807a6910242ffd8c8f3f15948d83214c6771a Mon Sep 17 00:00:00 2001
From: Olivier Maury <olivier.maury@inrae.fr>
Date: Tue, 19 Dec 2023 16:58:09 +0100
Subject: [PATCH 6/9] Update .gitlab-ci.yml

---
 .gitlab-ci.yml | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index cbed1e0e..b958231a 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -15,24 +15,20 @@ cache:
 
 build_job:
   stage: build
-  tags:
-    - docker 
   script: 
     - echo "Maven compile started"
-    - "mvn compile"
+    - mvn compile
+    - ls -lha /usr/bin/tokei
+    - /usr/bin/tokei --version
 
 test_job:
   stage: test
-  tags:
-    - docker 
   script: 
     - echo "Maven test started"
     - "mvn test"
 
 package_job:
   stage: package
-  tags:
-    - docker 
   script: 
     - echo "Maven packaging started"
     - "mvn package"
@@ -41,7 +37,5 @@ deploy_job:
   stage: deploy
   only:
     - main
-  tags:
-    - docker 
   script:
     - echo "Maven deploy started"
-- 
GitLab


From 8df4b9d6f251bb560021dcda1c5db3995fad7658 Mon Sep 17 00:00:00 2001
From: Olivier Maury <Olivier.Maury@inrae.fr>
Date: Tue, 19 Dec 2023 17:10:55 +0100
Subject: [PATCH 7/9] Version de tokei

---
 bin/sloccount.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/bin/sloccount.sh b/bin/sloccount.sh
index ddcf9cb0..96f38d84 100755
--- a/bin/sloccount.sh
+++ b/bin/sloccount.sh
@@ -18,5 +18,6 @@ if [ ! -f $TOKEI ]; then
 fi
 
 echo "tokei is installed at $TOKEI"
+$TOKEI --version
 mkdir -p target
 $TOKEI -f -o json src | $TOKEI2CLOC > target/cloc.xml
-- 
GitLab


From b2633a0dde09641d6d27cc3523e984a9edc83d7a Mon Sep 17 00:00:00 2001
From: Olivier Maury <Olivier.Maury@inrae.fr>
Date: Tue, 19 Dec 2023 17:30:19 +0100
Subject: [PATCH 8/9] tokei-12.1.2

---
 .gitignore        |  1 +
 .gitlab-ci.yml    | 22 ++++++++++++++++++++--
 bin/sloccount.sh  |  4 ++--
 bin/tokei2cloc.py | 14 ++++++++------
 4 files changed, 31 insertions(+), 10 deletions(-)

diff --git a/.gitignore b/.gitignore
index 714101f9..93256b38 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
+bin/tokei
 .checkstyle
 .classpath
 logs
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index b958231a..119da58a 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -6,6 +6,9 @@ image: registry.forgemia.inra.fr/agroclim/common/docker-projets-java:latest
 stages:
     - build
     - test
+    - checkstyle
+    - pmd
+    - cpd
     - package
     - deploy
 
@@ -25,13 +28,28 @@ test_job:
   stage: test
   script: 
     - echo "Maven test started"
-    - "mvn test"
+    - mvn test
+
+checkstyle_job:
+  stage: checkstyle
+  script:
+    - mvn checkstyle:checkstyle
+
+pmd_job:
+  stage: pmd
+  script:
+    - mvn pmd:pmd
+
+cpd_job:
+  stage: cpd
+  script:
+    - mvn pmd:cpd
 
 package_job:
   stage: package
   script: 
     - echo "Maven packaging started"
-    - "mvn package"
+    - mvn package -DskipTests
 
 deploy_job:
   stage: deploy
diff --git a/bin/sloccount.sh b/bin/sloccount.sh
index 96f38d84..ccca432d 100755
--- a/bin/sloccount.sh
+++ b/bin/sloccount.sh
@@ -2,11 +2,11 @@
 TOKEI2CLOC=$(dirname $0)/tokei2cloc.py
 TOKEI=$(command -v tokei)
 if [ ! -x "$TOKEI" ]; then
-	TOKEITGZ=tokei-v7.0.3-x86_64-unknown-linux-gnu.tar.gz
+	TOKEITGZ=tokei-x86_64-unknown-linux-gnu.tar.gz
 	if [ ! -f bin/tokei ]; then
 		mkdir -p ~/tmp
 		if [ ! -f ~/tmp/$TOKEITGZ ]; then
-			wget "https://github.com/Aaronepower/tokei/releases/download/v7.0.3/$TOKEITGZ" -O ~/tmp/$TOKEITGZ
+			wget "https://github.com/Aaronepower/tokei/releases/download/v12.1.2/$TOKEITGZ" -O ~/tmp/$TOKEITGZ
 		fi
 		tar zxf ~/tmp/$TOKEITGZ -C bin
 	fi
diff --git a/bin/tokei2cloc.py b/bin/tokei2cloc.py
index a6ec8993..bc41a978 100755
--- a/bin/tokei2cloc.py
+++ b/bin/tokei2cloc.py
@@ -35,8 +35,10 @@ results = json.loads(sys.stdin.read())
 nb_files = 0
 nb_lines = 0
 for lang in results:
-    nb_files += len(results[lang]['stats'])
-    nb_lines += int(results[lang]['lines'])
+    nb_files += len(results[lang]['reports'])
+    nb_lines += int(results[lang]['blanks'])
+    nb_lines += int(results[lang]['code'])
+    nb_lines += int(results[lang]['comments'])
 
 print("""<?xml version="1.0"?><results>
 <header>
@@ -56,10 +58,10 @@ total_blank = 0
 total_comment = 0
 total_code = 0
 for lang in results:
-    for result in results[lang]['stats']:
-        blank = int(result['blanks'])
-        comment = int(result['comments'])
-        code = int(result['code'])
+    for result in results[lang]['reports']:
+        blank = int(result['stats']['blanks'])
+        comment = int(result['stats']['comments'])
+        code = int(result['stats']['code'])
         print("""  <file name="%s" blank="%d" comment="%d" code="%d"  language="%s" />""" % 
             (result['name'], blank, comment, code, lang))
         total_blank += blank
-- 
GitLab


From 029ce13202c3459705f0d8afa7bc447ce679e274 Mon Sep 17 00:00:00 2001
From: Olivier Maury <Olivier.Maury@inrae.fr>
Date: Tue, 19 Dec 2023 17:37:46 +0100
Subject: [PATCH 9/9] checkstyle.failsOnError

---
 pom.xml | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/pom.xml b/pom.xml
index 3a751a42..d6e135a2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -83,9 +83,6 @@ along with Indicators. If not, see <https://www.gnu.org/licenses/>.
     <properties>
         <build.date>${maven.build.timestamp}</build.date>
         <checkstyle.config.location>file://${basedir}/config/sun_checks.xml</checkstyle.config.location>
-        <checkstyle.failsOnError>false</checkstyle.failsOnError>
-        <checkstyle.includeResources>false</checkstyle.includeResources>
-        <checkstyle.includeTestResources>false</checkstyle.includeTestResources>
         <compiler-plugin.version>3.8.1</compiler-plugin.version>
         <!-- Fix checkstyle version to ensure sun_checks.xml matches. -->
         <checkstyle.version>3.3.1</checkstyle.version>
@@ -408,10 +405,13 @@ along with Indicators. If not, see <https://www.gnu.org/licenses/>.
                     <version>${checkstyle.version}</version>
                     <configuration>
                         <excludes>**/module-info.java</excludes>
+                        <failsOnError>true</failsOnError>
+                        <failOnViolation>true</failOnViolation>
                         <includeResources>false</includeResources>
                         <includeTestResources>false</includeTestResources>
                         <includeTestSourceDirectory>true</includeTestSourceDirectory>
                         <propertyExpansion>basedir=${basedir}</propertyExpansion>
+                        <violationSeverity>warning</violationSeverity>
                     </configuration>
                 </plugin>
                 <plugin>
-- 
GitLab