Skip to content

Commit

Permalink
Merge pull request #38 from Coreoz/29-replace-travis-by-github-actions
Browse files Browse the repository at this point in the history
#29 - [CI] Replacing Travis by GithubActions
  • Loading branch information
amanteaux authored Sep 17, 2024
2 parents f1af297 + 322c958 commit e15b2fd
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 24 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 0 additions & 4 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
--------------------
Expand Down
1 change: 1 addition & 0 deletions lombok.config
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lombok.log.fieldname = logger
2 changes: 1 addition & 1 deletion plume-framework-dependencies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<dagger.version>2.43.2</dagger.version>
<guava.version>32.1.1-jre</guava.version>
<javax-inject.version>1</javax-inject.version>
<lombok.version>1.18.24</lombok.version>
<lombok.version>1.18.34</lombok.version>
<logback.version>1.4.0</logback.version>
<slf4j.version>2.0.0</slf4j.version>
<config.version>1.4.2</config.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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();
}

Expand All @@ -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;
}
}
Expand All @@ -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;
}
}
Expand Down
6 changes: 5 additions & 1 deletion plume-web-jersey/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>

<dependency>
<groupId>com.google.inject</groupId>
Expand Down Expand Up @@ -109,4 +113,4 @@
</dependencies>
</dependencyManagement>

</project>
</project>
Original file line number Diff line number Diff line change
@@ -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());
}
}

}
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<javadoc.java-version>8</javadoc.java-version>
<additionalparam>-Xdoclint:none</additionalparam>
</properties>
Expand Down

0 comments on commit e15b2fd

Please sign in to comment.