diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..f35b3a9 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,49 @@ +# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +name: Java CI + +on: + push: + branches: [ "master" ] + pull_request: + types: [opened, synchronize, reopened] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + - name: Set up JDK + uses: actions/setup-java@v3 + with: + # The JDK 21 causes a compilation error: + # Error: Class com.sun.tools.javac.tree.JCTree$JCImport does not have member field 'com.sun.tools.javac.tree.JCTree qualid' + java-version: '17' + distribution: 'temurin' + cache: maven + - name: Cache SonarCloud packages + uses: actions/cache@v3 + with: + path: ~/.sonar/cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar + - name: Cache Maven packages + uses: actions/cache@v3 + with: + path: ~/.m2 + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-m2 + - name: Sonar analysis + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_HOST_URL: ${{ vars.SONAR_HOST_URL }} + run: mvn -B clean verify -P coverage org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=Coreoz_Plume -Dsonar.organization=coreoz diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 9e54ddd..0000000 --- a/.travis.yml +++ /dev/null @@ -1,4 +0,0 @@ -language: java - -jdk: - - openjdk8 \ No newline at end of file diff --git a/README.md b/README.md index dc964de..bf19b59 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ Getting started The best way to get started is to use a [Maven archetype for Plume](https://github.com/Coreoz/Plume-archetypes). -Plume requires at least Java 11. +Plume requires at least Java 17. Dependency injection -------------------- diff --git a/lombok.config b/lombok.config new file mode 100644 index 0000000..1ecfe98 --- /dev/null +++ b/lombok.config @@ -0,0 +1 @@ +lombok.log.fieldname = logger diff --git a/plume-framework-dependencies/pom.xml b/plume-framework-dependencies/pom.xml index fd76d26..7eaa1af 100644 --- a/plume-framework-dependencies/pom.xml +++ b/plume-framework-dependencies/pom.xml @@ -19,7 +19,7 @@ 2.43.2 32.1.1-jre 1 - 1.18.24 + 1.18.34 1.4.0 2.0.0 1.4.2 diff --git a/plume-web-jersey-monitoring/src/main/java/com/coreoz/plume/jersey/monitoring/utils/info/ApplicationInfoProvider.java b/plume-web-jersey-monitoring/src/main/java/com/coreoz/plume/jersey/monitoring/utils/info/ApplicationInfoProvider.java index ebec0e2..84da2d3 100644 --- a/plume-web-jersey-monitoring/src/main/java/com/coreoz/plume/jersey/monitoring/utils/info/ApplicationInfoProvider.java +++ b/plume-web-jersey-monitoring/src/main/java/com/coreoz/plume/jersey/monitoring/utils/info/ApplicationInfoProvider.java @@ -8,15 +8,12 @@ import lombok.extern.slf4j.Slf4j; import org.apache.maven.model.Model; import org.apache.maven.model.io.xpp3.MavenXpp3Reader; -import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import javax.inject.Inject; import javax.inject.Provider; import javax.inject.Singleton; -import javax.validation.constraints.Negative; import java.io.File; import java.io.FileReader; -import java.io.IOException; import java.io.InputStreamReader; import java.util.Map; @@ -47,7 +44,7 @@ private ApplicationInfo fetchApplicationInfo() { } if (model == null) { - log.warn("Failed to read pom.xml file on root project and in META-INF folder"); + logger.warn("Failed to read pom.xml file on root project and in META-INF folder"); model = new Model(); } @@ -66,7 +63,7 @@ private Model readPom() { try { return reader.read(new FileReader(POM_FILE_NAME)); } catch (Exception e) { - log.error("Failed to read {}", POM_FILE_NAME, e); + logger.error("Failed to read {}", POM_FILE_NAME, e); return null; } } @@ -85,7 +82,7 @@ private Model readMetaInfPom() { return reader.read(new InputStreamReader(resourceList.get(0).open())); } catch (Exception e) { - log.error("Failed to read {} from META-INF folder", POM_FILE_NAME, e); + logger.error("Failed to read {} from META-INF folder", POM_FILE_NAME, e); return null; } } diff --git a/plume-web-jersey/pom.xml b/plume-web-jersey/pom.xml index 669d4cb..69add61 100644 --- a/plume-web-jersey/pom.xml +++ b/plume-web-jersey/pom.xml @@ -60,6 +60,10 @@ com.google.guava guava + + org.projectlombok + lombok + com.google.inject @@ -109,4 +113,4 @@ - \ No newline at end of file + diff --git a/plume-web-jersey/src/main/java/com/coreoz/plume/jersey/jee/ErrorServlet.java b/plume-web-jersey/src/main/java/com/coreoz/plume/jersey/jee/ErrorServlet.java index 823954f..6a4e590 100644 --- a/plume-web-jersey/src/main/java/com/coreoz/plume/jersey/jee/ErrorServlet.java +++ b/plume-web-jersey/src/main/java/com/coreoz/plume/jersey/jee/ErrorServlet.java @@ -1,24 +1,22 @@ package com.coreoz.plume.jersey.jee; -import java.io.IOException; -import java.io.PrintWriter; +import lombok.extern.slf4j.Slf4j; -import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import java.io.PrintWriter; +@Slf4j public class ErrorServlet extends HttpServlet { - - private static final long serialVersionUID = 6186826368888103404L; - @Override - protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + protected void doGet(HttpServletRequest req, HttpServletResponse resp) { try(PrintWriter printWriter = resp.getWriter()) { int errorCode = resp.getStatus(); String errorMessage = HttpStatus.getStatusText(errorCode); printWriter.println("Error " + errorCode + " : " + errorMessage); - } + } catch (Exception e) { + logger.error("Error displaying error message for error code {}", resp.getStatus()); + } } - } diff --git a/pom.xml b/pom.xml index 8eb5b32..e8e2bec 100644 --- a/pom.xml +++ b/pom.xml @@ -63,8 +63,8 @@ UTF-8 - 11 - 11 + 17 + 17 8 -Xdoclint:none