Skip to content

Commit

Permalink
Update to Java 11
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuelBucheliZ committed Jun 30, 2023
1 parent 10d98ce commit bc53cd4
Show file tree
Hide file tree
Showing 14 changed files with 183 additions and 52 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Build Java Jar with Maven, build Docker Image and publish

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
cache: maven
- name: Build jar with Maven
run: mvn -B package -Pjar --file pom.xml
# Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive
- name: Update dependency graph
uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6
- name: Create jar release
uses: ncipollo/release-action@v1
with:
allowUpdates: true
artifacts: "target/pcws.jar"
commit: "${{ github.sha }}"
tag: "latest-jar"
prerelease: true
- name: Build war with Maven
run: mvn -B package -Pwar --file pom.xml
- name: Create war release
uses: ncipollo/release-action@v1
with:
allowUpdates: true
artifacts: "target/pcws.war,src/main/db/setup_db.sql,src/main/sh/transfer_logs.sh"
commit: "${{ github.sha }}"
tag: "latest-war"
prerelease: true
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
43 changes: 35 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,27 @@

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
replay_pid*

target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
# https://github.com/takari/maven-wrapper#usage-without-binary-jar
.mvn/wrapper/maven-wrapper.jar

# Eclipse m2e generated files
# Eclipse Core
.project
# JDT-specific (Eclipse Java Development Tools)
.classpath

# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
Expand All @@ -32,6 +51,9 @@ hs_err_pid*
.idea/**/dictionaries
.idea/**/shelf

# AWS User-specific
.idea/**/aws.xml

# Generated files
.idea/**/contentModel.xml

Expand All @@ -52,11 +74,14 @@ hs_err_pid*
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
.idea/modules.xml
.idea/*.iml
.idea/modules
*.iml
*.ipr
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr

# CMake
cmake-build-*/
Expand All @@ -79,6 +104,9 @@ atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml

# SonarLint plugin
.idea/sonarlint/

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
Expand All @@ -91,4 +119,3 @@ fabric.properties
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

.idea/artifacts/*
3 changes: 0 additions & 3 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions .idea/sonarlint/issuestore/index.pb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 0 additions & 8 deletions .travis.yml

This file was deleted.

4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM eclipse-temurin:11-jdk-alpine
VOLUME /tmp
COPY target/pcws.jar app.jar
ENTRYPOINT ["java","-jar","/app.jar"]
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

Main service for the BFH AppTrans exercise.

Live demo (with mock external systems) at https://bfh-pcws-mock.herokuapp.com/swagger-ui.html
Live demo (with mock external systems) at https://bfh-pcws-mock.herokuapp.com/swagger-ui/index.html

See also https://github.com/SamuelBucheliZ/bfh-apptrans-exercise/blob/master/README.md

## Versions

PC-WS is known to work with the following versions

- Java: 8
- Java: 11
- Tomcat: 9
- PostgreSQL: 10

Expand Down
35 changes: 21 additions & 14 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.1.RELEASE</version>
<version>2.7.12</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>ch.bfh</groupId>
Expand All @@ -16,7 +16,7 @@
<packaging>${packaging.type}</packaging>

<properties>
<java.version>1.8</java.version>
<java.version>11</java.version>
<springfox.swagger.version>2.9.2</springfox.swagger.version>
<feign.version>10.2.3</feign.version>
</properties>
Expand All @@ -32,16 +32,21 @@
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>2.1.5.RELEASE</version>
<version>2.7.12</version>
</dependency>

<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.5</version>
<version>42.2.27</version>
</dependency>

<dependency>
Expand All @@ -51,15 +56,9 @@
</dependency>

<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${springfox.swagger.version}</version>
</dependency>

<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${springfox.swagger.version}</version>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.7.0</version>
</dependency>

<dependency>
Expand All @@ -71,7 +70,7 @@
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>2.9.7</version>
<version>2.9.8</version>
</dependency>

<dependency>
Expand All @@ -91,6 +90,14 @@
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<release>${java.version}</release>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
Expand Down
22 changes: 8 additions & 14 deletions src/main/java/ch/bfh/pcws/Application.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
package ch.bfh.pcws;

import ch.bfh.pcws.account.AccountService;
import ch.bfh.pcws.code.CodeService;
import ch.bfh.pcws.image.CreateImageService;
import ch.bfh.pcws.log.DataLogService;
import ch.bfh.pcws.account.AccountService;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@SpringBootApplication
@EnableSwagger2
public class Application extends SpringBootServletInitializer {

public static void main(String... args) {
Expand All @@ -32,12 +28,10 @@ public CreateImageService createPrintCodeHandler(
}

@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build();
public OpenAPI openApi() {
return new OpenAPI() // see http://localhost:8080/swagger-ui/index.html
.info(new Info().title("PrintCode WebService")
.description("Sample Project used in BFH AppTrans exercise, see https://github.com/SamuelBucheliZ/bfh-apptrans-exercise")
.version("v0.0.1"));
}

}
6 changes: 3 additions & 3 deletions src/main/java/ch/bfh/pcws/api/CreateCodeEndpoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


import ch.bfh.pcws.image.CreateImageService;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.CrossOrigin;
Expand All @@ -23,8 +23,8 @@ public CreateCodeEndpoint(
}

@CrossOrigin(origins = "*")
@PostMapping(value = "/createCode", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ApiOperation("createCode")
@PostMapping(value = "/createCode", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "createCode")
public CodeResponse createCode(@RequestBody CodeRequest codeRequest) {
return createImageService.handle(codeRequest);
}
Expand Down
1 change: 1 addition & 0 deletions system.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
java.runtime.version=11

0 comments on commit bc53cd4

Please sign in to comment.