From 9151e2c897acebe57d09c8c3e69c7ace0718c5f3 Mon Sep 17 00:00:00 2001
From: Emmanuel Bruno <emmanuel.bruno@univ-tln.fr>
Date: Wed, 15 Dec 2021 19:24:39 +0100
Subject: [PATCH] improves sonar plugins.

---
 .github/workflows/docker-image.yml |  8 ++++----
 docker-compose.yml                 |  2 +-
 docker/Dockerfile                  |  5 +++++
 docker/settings-docker.xml         |  2 +-
 pom.xml                            | 22 ++++++++++++++++++++++
 5 files changed, 33 insertions(+), 6 deletions(-)

diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml
index fb2e064..1190aee 100644
--- a/.github/workflows/docker-image.yml
+++ b/.github/workflows/docker-image.yml
@@ -19,9 +19,9 @@ jobs:
     - uses: actions/checkout@v2
     - name: Build the Docker image for branch ${GITHUB_REF##*/}
       run: DOCKER_BUILDKIT=1 docker build . \
-            --env GITHUBLOGIN="$GITHUBLOGIN" \
-            --env GITHUBPASSWORD="$GITHUBPASSWORD" \
-            --env SONAR_HOST="$SONAR_HOST" \
-            --env SONAR_TOKEN="$SONAR_TOKEN" \
+            --build-arg GITHUBLOGIN \
+            --build-arg GITHUBPASSWORD \
+            --build-arg SONAR_URL \
+            --build-arg SONAR_TOKEN \
             --file ./docker/Dockerfile \
             --tag brunoe/samplejee91:${GITHUB_REF##*/}
diff --git a/docker-compose.yml b/docker-compose.yml
index 87c0dee..6784285 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -5,7 +5,7 @@ services:
       args:
         - GITHUBLOGIN
         - GITHUBPASSWORD
-        - SONAR_HOST
+        - SONAR_URL
         - SONAR_TOKEN
       context: .
       dockerfile: docker/Dockerfile
diff --git a/docker/Dockerfile b/docker/Dockerfile
index 8cf64ea..880e779 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -1,5 +1,10 @@
 ### First we build the application in docker in a controlled env
 FROM maven:3.8.4-eclipse-temurin-11 as build
+ARG GITHUBLOGIN
+ARG GITHUBPASSWORD
+ARG SONAR_HOST
+ARG SONAR_TOKEN
+
 WORKDIR /app
 
 #see https://www.jrebel.com/blog/how-to-speed-up-your-maven-build
diff --git a/docker/settings-docker.xml b/docker/settings-docker.xml
index fc533f8..3ccf09a 100644
--- a/docker/settings-docker.xml
+++ b/docker/settings-docker.xml
@@ -28,7 +28,7 @@
         <profile>
             <id>sonar</id>
             <properties>
-                <sonar.host.url>${env.SONAR_HOST}</sonar.host.url>
+                <sonar.host.url>${env.SONAR_URL}</sonar.host.url>
                 <sonar.login>${env.SONAR_TOKEN}</sonar.login>
             </properties>
         </profile>
diff --git a/pom.xml b/pom.xml
index ebb140a..6c8b48b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -173,6 +173,7 @@
             <dependency>
                 <groupId>org.jboss.logging</groupId>
                 <artifactId>jboss-logging-annotations</artifactId>
+                <version>2.2.1.Final</version>
                 <exclusions>
                     <exclusion>
                         <groupId>org.jboss.logging</groupId>
@@ -298,4 +299,25 @@
         </repository>
     </repositories>
 
+    <profiles>
+        <profile>
+            <id>sonar</id>
+            <build>
+                <plugins>
+                    <!--Sonarquve -->
+                    <plugin>
+                        <groupId>org.sonarsource.scanner.maven</groupId>
+                        <artifactId>sonar-maven-plugin</artifactId>
+                        <version>3.9.1.2184</version>
+                    </plugin>
+                    <plugin>
+                        <groupId>io.github.r0bb3n</groupId>
+                        <artifactId>sonar-quality-gate-maven-plugin</artifactId>
+                        <version>1.1.0</version>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+    </profiles>
+
 </project>
-- 
GitLab