Files
user-management/build.gradle.kts
hurui200320 bed3de76dd
Unit test coverage / gradle-test (pull_request) Successful in 7m21s
Unit test coverage / gradle-test (push) Successful in 7m26s
CI for publishing docker image / build-and-publish (push) Successful in 7m2s
Implement query user endpoint for RabbitMQ (#35)
This PR implemented ticket clevermicro/user-management#34 for the user-service-v1 endpoint, along with all the infrastructures required to support the endpoints.

The changes are:
+ switch build tool to gradle for easier access to the private artifacts of clevermicro (although later Brian change the artifacts to public)
+ set up clevermicro amqp client
+ switched to official keycloak admin client instead of implementing it with webflux
+ implement the message formats for the RPC protocol, for now they are exclusive to auth-service, but in the future we will reuse (might with some changes) them for all RPC calls inside clevermicro (need a server lib for handling the message parsing and convertion)
+ implement the user query endpoint
+ implement unit test so the overall coverage is above 85%
+ fixed all issues found during the testing phase with shared env

Currently the latest docker image has been deployed to the shared env, see https://docs.cleverthis.com/en/architecture/microservices/shared-env#multi-user-support

Reviewed-on: #35
2025-07-31 12:56:14 +08:00

129 lines
3.9 KiB
Kotlin

plugins {
java
id("org.springframework.boot") version "3.5.3"
id("io.spring.dependency-management") version "1.1.7"
jacoco
checkstyle
idea
}
group = "com.cleverthis.clevermicro"
version = "0.0.1-SNAPSHOT"
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}
configurations {
compileOnly {
extendsFrom(configurations.annotationProcessor.get())
}
}
configurations.all {
// disable the cache, so it will fetch the latest snapshot for client api
resolutionStrategy.cacheChangingModulesFor(30, TimeUnit.SECONDS)
resolutionStrategy.cacheDynamicVersionsFor(30, TimeUnit.SECONDS)
}
repositories {
mavenCentral()
maven {
name = "cleverthis-forgejo-maven"
url = uri("https://git.cleverthis.com/api/packages/clevermicro/maven")
// disable auth since artifacts are publicly available
// if (System.getenv("MAVEN_TOKEN").isNullOrBlank()) {
// credentials(HttpHeaderCredentials::class) {
// name = "Authorization"
// val token =
// findProperty("cleverThisForgejoToken") as String? ?: error("Token not found")
// value = "token $token"
// }
// } else {
// credentials(HttpHeaderCredentials::class) {
// name = "Authorization"
// val token = System.getenv("MAVEN_TOKEN")
// value = "token $token"
// }
// }
// authentication {
// create("header", HttpHeaderAuthentication::class)
// }
}
}
extra["springCloudVersion"] = "2025.0.0"
dependencyManagement {
imports {
mavenBom("org.springframework.cloud:spring-cloud-dependencies:${property("springCloudVersion")}")
}
}
// https://javadoc.io/doc/org.mockito/mockito-core/latest/org.mockito/org/mockito/Mockito.html#0.3
val mockitoAgent = configurations.create("mockitoAgent")
dependencies {
implementation("org.springframework.boot:spring-boot-starter-actuator")
implementation("org.springframework.boot:spring-boot-starter-validation")
implementation("org.springframework.boot:spring-boot-starter-webflux")
implementation("org.springframework.cloud:spring-cloud-starter-consul-config")
compileOnly("org.projectlombok:lombok")
annotationProcessor("org.projectlombok:lombok")
runtimeOnly("io.micrometer:micrometer-registry-prometheus")
// clevermicro
implementation("com.cleverthis.clevermicro:core:0.2.0-SNAPSHOT")
// keycloak admin client
implementation("org.keycloak:keycloak-admin-client:26.0.6")
// opentelemetry
implementation(platform("io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom:2.11.0"))
implementation("io.opentelemetry.instrumentation:opentelemetry-spring-boot-starter")
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("io.projectreactor:reactor-test")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
testImplementation("com.squareup.okhttp3:mockwebserver:4.12.0")
mockitoAgent("org.mockito:mockito-core") { isTransitive = false }
}
tasks.withType<Test> {
jvmArgs("-javaagent:${mockitoAgent.asPath}")
useJUnitPlatform()
// generate jacoco test report
finalizedBy("jacocoTestReport")
// show full output streams so we can debug for pipelines
testLogging {
showStandardStreams = true
}
}
tasks.jacocoTestReport {
dependsOn(tasks.test)
reports {
xml.required.set(true)
html.required.set(true)
}
}
checkstyle {
toolVersion = "10.23.1"
configFile = file("${project.rootDir}/checkstyle.xml")
isShowViolations = true
isIgnoreFailures = false
maxWarnings = 0
maxErrors = 0
sourceSets = setOf(project.sourceSets["main"])
}
idea { // tell IDEA to always download source code and javadoc
module {
isDownloadJavadoc = true
isDownloadSources = true
}
}