From f0c472b1792779e63fdeb97a470b46300de00050 Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Tue, 26 Oct 2021 16:19:55 +0200 Subject: feat(web/api): Initial API implementation in Kotlin This change adds the initial implementation of the new API server in Kotlin, replacing the old API written in Python. The implementation uses Quarkus, RESTEasy, and Hibernate to implement the new API endpoints. The reason for replacing the old API server is unifying the build and deployment toolchains, reducing the number of technologies necessary to work with OpenDC. Furthermore, we envision bundling the entire OpenDC project into a single distributions, allowing users to launch their own deployment trivially. --- opendc-web/opendc-web-api/build.gradle.kts | 74 +++++++++++++++++++++++++++++- 1 file changed, 73 insertions(+), 1 deletion(-) (limited to 'opendc-web/opendc-web-api/build.gradle.kts') diff --git a/opendc-web/opendc-web-api/build.gradle.kts b/opendc-web/opendc-web-api/build.gradle.kts index 7edfd134..9889b832 100644 --- a/opendc-web/opendc-web-api/build.gradle.kts +++ b/opendc-web/opendc-web-api/build.gradle.kts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 AtLarge Research + * Copyright (c) 2020 AtLarge Research * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -19,3 +19,75 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ + +description = "REST API for the OpenDC website" + +/* Build configuration */ +plugins { + `kotlin-conventions` + kotlin("plugin.allopen") + kotlin("plugin.jpa") + `testing-conventions` + `jacoco-conventions` + id("io.quarkus") +} + +dependencies { + implementation(enforcedPlatform(libs.quarkus.bom)) + + implementation(projects.opendcWeb.opendcWebProto) + + implementation(libs.quarkus.kotlin) + implementation(libs.quarkus.resteasy.core) + implementation(libs.quarkus.resteasy.jackson) + implementation(libs.jackson.module.kotlin) + implementation(libs.quarkus.smallrye.openapi) + + implementation(libs.quarkus.security) + implementation(libs.quarkus.oidc) + + implementation(libs.quarkus.hibernate.orm) + implementation(libs.quarkus.hibernate.validator) + implementation(libs.quarkus.hibernate.types) + implementation(libs.quarkus.jdbc.postgresql) + quarkusDev(libs.quarkus.jdbc.h2) + + testImplementation(libs.quarkus.junit5.core) + testImplementation(libs.quarkus.junit5.mockk) + testImplementation(libs.restassured.core) + testImplementation(libs.restassured.kotlin) + testImplementation(libs.quarkus.test.security) + testImplementation(libs.quarkus.jdbc.h2) +} + +allOpen { + annotation("javax.ws.rs.Path") + annotation("javax.enterprise.context.ApplicationScoped") + annotation("io.quarkus.test.junit.QuarkusTest") + annotation("javax.persistence.Entity") +} + +tasks.withType { + kotlinOptions.javaParameters = true +} + +tasks.quarkusDev { + workingDir = rootProject.projectDir.toString() +} + +tasks.test { + extensions.configure(JacocoTaskExtension::class) { + excludeClassLoaders = listOf("*QuarkusClassLoader") + destinationFile = layout.buildDirectory.file("jacoco-quarkus.exec").get().asFile + } +} + +/* Fix for Quarkus/ktlint-gradle incompatibilities */ +tasks.named("runKtlintCheckOverMainSourceSet").configure { + mustRunAfter(tasks.quarkusGenerateCode) + mustRunAfter(tasks.quarkusGenerateCodeDev) +} + +tasks.named("runKtlintCheckOverTestSourceSet").configure { + mustRunAfter(tasks.quarkusGenerateCodeTests) +} -- cgit v1.2.3 From 98273d483e68e333f9bf5c39510f9a46f3f3a74f Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Tue, 22 Mar 2022 10:57:02 +0100 Subject: fix(web/api): Support dynamic JSON type selection for DB This change adds support for dynamically selecting the appropriate JSON type for the current database. For Postgres, this will be the JSONB type, while for H2 this is either the BLOB or JSON type. --- opendc-web/opendc-web-api/build.gradle.kts | 1 - 1 file changed, 1 deletion(-) (limited to 'opendc-web/opendc-web-api/build.gradle.kts') diff --git a/opendc-web/opendc-web-api/build.gradle.kts b/opendc-web/opendc-web-api/build.gradle.kts index 9889b832..488ce8af 100644 --- a/opendc-web/opendc-web-api/build.gradle.kts +++ b/opendc-web/opendc-web-api/build.gradle.kts @@ -48,7 +48,6 @@ dependencies { implementation(libs.quarkus.hibernate.orm) implementation(libs.quarkus.hibernate.validator) - implementation(libs.quarkus.hibernate.types) implementation(libs.quarkus.jdbc.postgresql) quarkusDev(libs.quarkus.jdbc.h2) -- cgit v1.2.3 From 527ae2230f5c2dd22f496f45d5d8e3bd4acdb854 Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Mon, 4 Apr 2022 16:10:32 +0200 Subject: ci: Fix JaCoCo report aggregation This change updates the build script to fix the aggregation step for the JaCoCo coverage reports that are submitted to Codecov. Previously, not all modules were properly included in the report. --- opendc-web/opendc-web-api/build.gradle.kts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'opendc-web/opendc-web-api/build.gradle.kts') diff --git a/opendc-web/opendc-web-api/build.gradle.kts b/opendc-web/opendc-web-api/build.gradle.kts index 488ce8af..853632a7 100644 --- a/opendc-web/opendc-web-api/build.gradle.kts +++ b/opendc-web/opendc-web-api/build.gradle.kts @@ -53,6 +53,7 @@ dependencies { testImplementation(libs.quarkus.junit5.core) testImplementation(libs.quarkus.junit5.mockk) + testImplementation(libs.quarkus.jacoco) testImplementation(libs.restassured.core) testImplementation(libs.restassured.kotlin) testImplementation(libs.quarkus.test.security) @@ -77,7 +78,7 @@ tasks.quarkusDev { tasks.test { extensions.configure(JacocoTaskExtension::class) { excludeClassLoaders = listOf("*QuarkusClassLoader") - destinationFile = layout.buildDirectory.file("jacoco-quarkus.exec").get().asFile + // destinationFile = layout.buildDirectory.file("jacoco-quarkus.exec").get().asFile } } -- cgit v1.2.3