Vorbereitung Release 0.2.0 #83
@@ -1,12 +1,7 @@
|
||||
# ----------------------------------------------------------------------- #
|
||||
FROM gradle:9.2.1-jdk AS builder
|
||||
FROM gradle:9.2.1-jdk21 AS builder
|
||||
WORKDIR /
|
||||
COPY ./api/src/main/ ./api/src/main/
|
||||
COPY ./api/build.gradle ./api/
|
||||
COPY ./models/src/main/ ./models/src/main/
|
||||
COPY ./models/build.gradle ./models/
|
||||
COPY ./services/src/main/ ./services/src/main/
|
||||
COPY ./services/build.gradle ./services/
|
||||
COPY ./src/main/ ./src/main/
|
||||
COPY ./build.gradle ./
|
||||
COPY ./gradle.properties ./
|
||||
COPY ./settings.gradle ./
|
||||
@@ -19,7 +14,7 @@ FROM alpine/java:21-jdk AS run
|
||||
RUN adduser --system appuser
|
||||
USER appuser
|
||||
|
||||
COPY --from=builder --chown=appuser:appuser /api/build/libs/api-0.2.0-SNAPSHOT.jar app.jar
|
||||
COPY --from=builder --chown=appuser:appuser /build/libs/kontor-javalin-0.2.0-SNAPSHOT.jar app.jar
|
||||
|
||||
EXPOSE 8400
|
||||
USER appuser
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
plugins {
|
||||
id 'application'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation project(":models") // We need this dependency for serializing persons to JSON
|
||||
implementation project(":services") // We'll make use of the InMemoryPersonReader soon
|
||||
|
||||
implementation libs.javalin // Pulling in Javalin
|
||||
implementation libs.jackson // For JSON serialization of persons
|
||||
implementation libs.slf4j // To see some Javalin logging
|
||||
}
|
||||
|
||||
application {
|
||||
mainClass = "de.thpeetz.kontor.api.Main"
|
||||
mainModule = "de.thpeetz.kontor.api"
|
||||
}
|
||||
|
||||
task fatJar(type: Jar) {
|
||||
manifest {
|
||||
attributes 'Main-Class': 'de.thpeetz.kontor.api.Main'
|
||||
//attributes (
|
||||
// 'Main-Class': 'de.thpeetz.kontor.api.Main',
|
||||
// 'Main-Module': 'de.thpeetz.kontor.api'
|
||||
//)
|
||||
}
|
||||
//archiveBaseName = 'all-in-one-jar'
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
|
||||
with jar
|
||||
}
|
||||
|
||||
build.dependsOn fatJar
|
||||
distZip.dependsOn fatJar
|
||||
distTar.dependsOn fatJar
|
||||
startScripts.dependsOn fatJar
|
||||
@@ -1,10 +0,0 @@
|
||||
module de.thpeetz.kontor.api {
|
||||
requires io.javalin;
|
||||
requires com.fasterxml.jackson.databind;
|
||||
requires org.slf4j;
|
||||
requires kotlin.stdlib;
|
||||
|
||||
requires de.thpeetz.kontor.services;
|
||||
|
||||
uses de.thpeetz.kontor.services.api.PersonReader;
|
||||
}
|
||||
@@ -1,14 +1,28 @@
|
||||
plugins {
|
||||
id 'org.javamodularity.moduleplugin' version '2.0.0' apply false
|
||||
id 'java'
|
||||
}
|
||||
|
||||
subprojects {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
apply plugin: "org.javamodularity.moduleplugin"
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation libs.javalin // Pulling in Javalin
|
||||
implementation libs.jackson // For JSON serialization of persons
|
||||
implementation libs.slf4j // To see some Javalin logging
|
||||
}
|
||||
|
||||
task fatJar(type: Jar) {
|
||||
manifest {
|
||||
attributes 'Main-Class': 'de.thpeetz.kontor.api.Main'
|
||||
}
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
|
||||
with jar
|
||||
}
|
||||
|
||||
build.dependsOn fatJar
|
||||
|
||||
wrapper {
|
||||
gradleVersion = "9.2.1"
|
||||
}
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
plugins {
|
||||
id 'java-library'
|
||||
}
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
module de.thpeetz.kontor.models {
|
||||
// We're exporting the only package we have in this subproject
|
||||
exports de.thpeetz.kontor.models;
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
plugins {
|
||||
id 'java-library'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation project(":models") // <-- add dependency to models subproject
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
import de.thpeetz.kontor.services.api.PersonReader;
|
||||
import de.thpeetz.kontor.services.inmemory.InMemoryPersonReader;
|
||||
|
||||
module de.thpeetz.kontor.services {
|
||||
exports de.thpeetz.kontor.services.api;
|
||||
|
||||
requires de.thpeetz.kontor.models;
|
||||
|
||||
// We're telling the ServiceLoader that the InMemoryPersonReader provides the implementation for the PersonReader interface
|
||||
provides PersonReader with InMemoryPersonReader;
|
||||
}
|
||||
@@ -1,6 +1 @@
|
||||
rootProject.name = 'kontor-javalin'
|
||||
|
||||
include ':models'
|
||||
include ':services'
|
||||
include ':api'
|
||||
|
||||
|
||||
+6
-7
@@ -1,21 +1,17 @@
|
||||
package de.thpeetz.kontor.api;
|
||||
|
||||
import de.thpeetz.kontor.services.api.PersonReader;
|
||||
import de.thpeetz.kontor.services.inmemory.InMemoryPersonReader;
|
||||
import io.javalin.Javalin;
|
||||
import java.util.ServiceLoader;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
|
||||
public class Main {
|
||||
private static Logger logger = LoggerFactory.getLogger(Main.class);
|
||||
private static short port = 8400;
|
||||
|
||||
public static void main(String[] args) {
|
||||
var personReader = ServiceLoader.load(PersonReader.class).findFirst().get(); // <-- Getting an implementation
|
||||
// for the PersonReader interface
|
||||
// from the ServiceLoader
|
||||
var personReader = new InMemoryPersonReader();
|
||||
var objMapper = new ObjectMapper();
|
||||
var result = objMapper.valueToTree(personReader.getAll());
|
||||
|
||||
@@ -23,7 +19,10 @@ public class Main {
|
||||
|
||||
var app = Javalin.create().start(port);
|
||||
app.get("/ping", ctx -> ctx.result("pong"));
|
||||
app.get("/persons", ctx -> ctx.json(result));
|
||||
app.get("/persons", ctx -> {
|
||||
logger.info("persons called");
|
||||
ctx.json(result);
|
||||
});
|
||||
|
||||
logger.info("API's alive for real :-)))");
|
||||
}
|
||||
-1
@@ -1,7 +1,6 @@
|
||||
package de.thpeetz.kontor.services.api;
|
||||
|
||||
import de.thpeetz.kontor.models.Person;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface PersonReader {
|
||||
+1
@@ -6,6 +6,7 @@ import java.util.List;
|
||||
import de.thpeetz.kontor.services.api.PersonReader;
|
||||
|
||||
public class InMemoryPersonReader implements PersonReader {
|
||||
|
||||
@Override
|
||||
public List<Person> getAll() {
|
||||
return List.of(
|
||||
Reference in New Issue
Block a user