Skip to content

Commit

Permalink
Merge pull request #49 from KPMP/KPMP-5403_update-to-java21
Browse files Browse the repository at this point in the history
upgrade delphinus to use java21
  • Loading branch information
rlreamy authored Aug 22, 2024
2 parents fbd3c00 + dd39d89 commit 2d3ee31
Show file tree
Hide file tree
Showing 26 changed files with 153 additions and 142 deletions.
17 changes: 14 additions & 3 deletions .github/workflows/build-gradle-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on:

jobs:
build-gradle-project:
env:
IMAGE_TAG: 1.4
runs-on: ubuntu-latest
steps:
- name: Get branch names
Expand All @@ -19,12 +21,12 @@ jobs:
uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: '8'
java-version: '21'
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
gradle-version: 7.4
gradle-version: 8.5

- name: Login to Docker Hub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
Expand All @@ -34,5 +36,14 @@ jobs:

- name: Run build with Gradle Wrapper
run: |
./gradlew build docker
./gradlew build docker
- name: Push to Docker Hub if branch is develop
if: steps.branch-names.outputs.current_branch == 'develop'
run: |
docker push "kingstonduo/delphinus-data:${{env.IMAGE_TAG}}"
- name: Push to Docker Hub if branch is not develop
if: steps.branch-names.outputs.current_branch != 'develop'
run: |
docker push "kingstonduo/delphinus-data:${{ steps.branch-names.outputs.current_branch }}"
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FROM alpine:3.16.2
FROM alpine:3.20.0

RUN apk update && \
apk upgrade
RUN apk add openjdk8
RUN apk add openjdk21

VOLUME /tmp
ARG DEPENDENCY=target/dependency
Expand Down
52 changes: 27 additions & 25 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@ buildscript {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.7.4")
classpath("org.springframework.boot:spring-boot-gradle-plugin:3.2.5")
}
}

plugins {
id 'com.palantir.docker' version '0.22.1'
id 'java'
id 'com.palantir.docker' version '0.35.0'
id 'org.springframework.boot' version '3.2.5'
}

group = 'kingstonduo'
version = '1.4'

apply plugin: 'java'
apply plugin: 'eclipse'
Expand All @@ -20,31 +23,26 @@ apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'com.palantir.docker'

jar {
baseName = 'delphinus-data'
version = '1.5'
}

repositories {
mavenCentral()
}

sourceCompatibility = 1.8
targetCompatibility = 1.8
sourceCompatibility = '21'
targetCompatibility = '21'

processResources {
filesMatching('application.properties') {
expand(project.properties)
}

jar {
archivesBaseName='delphinus-data'
}

dependencies {
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-data-mongodb")
testImplementation("org.mockito:mockito-core:4.8.0")
testImplementation("org.springframework.boot:spring-boot-starter-test")
implementation("org.springframework.boot:spring-boot-starter-data-mongodb")
implementation("org.json:json:20220924")
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.mockito:mockito-core'
testImplementation('org.mockito:mockito-junit-jupiter:3.12.4')
testImplementation 'org.springframework:spring-test:5.2.25.RELEASE'
}

springBoot {
Expand All @@ -57,12 +55,12 @@ task unpack(type: Copy) {
into("build/dependency")
}

def getTagInfo() {
if (project.hasProperty('tag')) {
def tagValue = project.property('tag')
return tagValue
} else {
def gitBranch = "Unknown branch"
def getCurrentGitBranch() {
if (project.hasProperty('tag')) {
def tagValue = project.property('tag')
return tagValue
} else {
def gitBranch = "Unknown branch"
try {
def workingDir = new File("${project.projectDir}")
def result = 'git rev-parse --abbrev-ref HEAD'.execute(null, workingDir)
Expand All @@ -72,12 +70,16 @@ def getTagInfo() {
}
} catch (e) {
}
return gitBranch
if (gitBranch == "develop" || gitBranch == "master"){
return project.version
}else{
return gitBranch
}
}
}

docker {
name "${project.group}/${jar.baseName}:" + getTagInfo()
name "kingstonduo/delphinus-data:" + getCurrentGitBranch()
copySpec.from(tasks.unpack.outputs).into("dependency")
buildArgs(['DEPENDENCY': "dependency"])
}
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
zipStorePath=wrapper/dists
2 changes: 1 addition & 1 deletion gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi

# For Cygwin, switch paths to Windows format before running java
# For Cygwin, switch paths to Windows format BeforeEach running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/org/kpmp/GenerateLinkScript.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@
import org.springframework.context.annotation.ComponentScan;
import org.kpmp.logging.LoggingService;

import javax.servlet.http.Part;
import java.io.File;
import java.io.FileOutputStream;
import java.text.MessageFormat;
import java.util.List;
import java.util.Map;

@ComponentScan(basePackages = { "org.kpmp" })
public class GenerateLinkScript implements CommandLineRunner {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/kpmp/errors/ErrorController.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.kpmp.errors;

import javax.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletRequest;

import org.kpmp.logging.LoggingService;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down
20 changes: 10 additions & 10 deletions src/main/java/org/kpmp/filters/AuthorizationFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
import java.io.IOException;
import java.util.List;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import jakarta.servlet.Filter;
import jakarta.servlet.FilterChain;
import jakarta.servlet.FilterConfig;
import jakarta.servlet.ServletException;
import jakarta.servlet.ServletRequest;
import jakarta.servlet.ServletResponse;
import jakarta.servlet.http.Cookie;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;

import org.json.JSONArray;
import org.json.JSONException;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/kpmp/logging/LoggingService.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.kpmp.logging;

import javax.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletRequest;

import org.kpmp.shibboleth.ShibbolethUser;
import org.kpmp.shibboleth.ShibbolethUserService;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.kpmp.shibboleth;

import javax.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/kpmp/slides/SlideController.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletRequest;

@Controller
public class SlideController {
Expand Down
1 change: 0 additions & 1 deletion src/main/java/org/kpmp/slides/SlideService.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.util.Collections;
import java.util.List;
import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
Expand Down
15 changes: 7 additions & 8 deletions src/test/java/org/kpmp/GenerateLinkScriptTest.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package org.kpmp;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.kpmp.slides.ParticipantRepository;
import org.kpmp.slides.Slide;
import org.kpmp.slides.SlideService;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.kpmp.logging.LoggingService;

import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class GenerateLinkScriptTest {

Expand All @@ -20,13 +19,13 @@ public class GenerateLinkScriptTest {
private LoggingService loggingService;
private GenerateLinkScript generateLinkScript;

@Before
@BeforeEach
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
MockitoAnnotations.openMocks(this);
generateLinkScript = new GenerateLinkScript(participantRepository, loggingService);
}

@After
@AfterEach
public void tearDown() throws Exception {
generateLinkScript = null;
}
Expand Down
10 changes: 5 additions & 5 deletions src/test/java/org/kpmp/WebConfigTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.web.servlet.config.annotation.CorsRegistration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;

public class WebConfigTest {

private WebConfig config;

@Before
@BeforeEach
public void setUp() throws Exception {
config = new WebConfig();
}

@After
@AfterEach
public void tearDown() throws Exception {
config = null;
}
Expand Down
15 changes: 8 additions & 7 deletions src/test/java/org/kpmp/errors/ErrorControllerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;

import javax.servlet.http.HttpServletRequest;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import jakarta.servlet.http.HttpServletRequest;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.kpmp.logging.LoggingService;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
Expand All @@ -18,13 +19,13 @@ public class ErrorControllerTest {
private LoggingService logger;
private ErrorController controller;

@Before
@BeforeEach
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
MockitoAnnotations.openMocks(this);
controller = new ErrorController(logger);
}

@After
@AfterEach
public void tearDown() throws Exception {
}

Expand Down
13 changes: 7 additions & 6 deletions src/test/java/org/kpmp/errors/FrontEndErrorTest.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
package org.kpmp.errors;

import static org.junit.Assert.assertEquals;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

public class FrontEndErrorTest {

private FrontEndError error;

@Before
@BeforeEach
public void setup() {
error = new FrontEndError();
}

@After
@AfterEach
public void tearDown() {
error = null;
}
Expand Down
Loading

0 comments on commit 2d3ee31

Please sign in to comment.