-
Notifications
You must be signed in to change notification settings - Fork 6
Add Kotlin app with Spring Boot 3 and coroutines #264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from 17 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
50c1f12
add build files for kotlin module
marijarin 7219da9
Merge branch 'master' into issue-231
marijarin 9de045b
add kotlin classes and fix adding detekt to java build
marijarin 91a9b0c
классы переписаны нужен рефакторинг
marijarin 33d0368
дописаны тесты, отдельный плагин для общих настроек
65fdb1d
kafka initializer
519fdd1
fix kafka container import
1f59029
info level for testcontainers
370d869
exclude detect-formatting as it causes initialization error in tests
2b3b86b
fix logs in kotlin app
be912c3
Merge branch 'master' into issue-231
ebb5d6a
add application kt exclusion from test report
fd18214
exclude loggers from test coverage verification
26d5664
fix build files
c5861d0
Moved dependencies to the version catalog
mfvanek af11522
Added detekt
mfvanek 0fb8929
Fix
mfvanek 9d4d538
добавлены правила для детекта
037ac0e
пустая строка
219c051
Increase code coverage
mfvanek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| rootProject.name = "sb-ot-demo-conventions" | ||
|
|
||
| dependencyResolutionManagement { | ||
| versionCatalogs { | ||
| create("libs") { | ||
| from(files("../gradle/libs.versions.toml")) | ||
| } | ||
| } | ||
| } |
46 changes: 46 additions & 0 deletions
46
buildSrc/src/main/kotlin/sb-ot-demo.jacoco-rules.gradle.kts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| plugins { | ||
| id("java") | ||
| id("jacoco") | ||
| } | ||
| tasks { | ||
| jacocoTestCoverageVerification { | ||
| dependsOn(jacocoTestReport) | ||
| violationRules { | ||
| rule { | ||
| limit { | ||
| counter = "CLASS" | ||
| value = "MISSEDCOUNT" | ||
| maximum = "0.0".toBigDecimal() | ||
| } | ||
| } | ||
| rule { | ||
| limit { | ||
| counter = "METHOD" | ||
| value = "MISSEDCOUNT" | ||
| maximum = "2.0".toBigDecimal() | ||
| } | ||
| } | ||
| rule { | ||
| limit { | ||
| counter = "LINE" | ||
| value = "MISSEDCOUNT" | ||
| maximum = "7.0".toBigDecimal() | ||
| } | ||
| } | ||
| rule { | ||
| limit { | ||
| counter = "INSTRUCTION" | ||
| value = "COVEREDRATIO" | ||
| minimum = "0.93".toBigDecimal() | ||
| } | ||
| } | ||
| rule { | ||
| limit { | ||
| counter = "BRANCH" | ||
| value = "COVEREDRATIO" | ||
| minimum = "0.66".toBigDecimal() | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
62 changes: 62 additions & 0 deletions
62
buildSrc/src/main/kotlin/sb-ot-demo.java-compile.gradle.kts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| /* | ||
| * Copyright (c) 2020-2025. Ivan Vakhrushev and others. | ||
| * https://github.com/mfvanek/spring-boot-open-telemetry-demo | ||
| * | ||
| * Licensed under the Apache License 2.0 | ||
| */ | ||
| val javaVersion = JavaVersion.VERSION_17 | ||
| plugins { | ||
| id("java") | ||
| id("jacoco") | ||
| id("com.google.osdetector") | ||
| id("org.gradle.test-retry") | ||
| } | ||
| dependencies { | ||
| testImplementation("org.assertj:assertj-core") | ||
| testImplementation("org.junit.jupiter:junit-jupiter-api") | ||
| testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine") | ||
| testRuntimeOnly("org.junit.platform:junit-platform-launcher") | ||
| // https://github.com/netty/netty/issues/11020 | ||
| if (osdetector.arch == "aarch_64") { | ||
| testImplementation("io.netty:netty-all:4.1.104.Final") | ||
| } | ||
| } | ||
|
|
||
| java { | ||
| sourceCompatibility = javaVersion | ||
| targetCompatibility = javaVersion | ||
| withJavadocJar() | ||
| withSourcesJar() | ||
| } | ||
|
|
||
| tasks { | ||
| withType<JavaCompile>().configureEach { | ||
| options.compilerArgs.add("-parameters") | ||
| options.compilerArgs.add("--should-stop=ifError=FLOW") | ||
| } | ||
|
|
||
| test { | ||
| useJUnitPlatform() | ||
|
|
||
| finalizedBy(jacocoTestReport, jacocoTestCoverageVerification) | ||
| maxParallelForks = 1 | ||
|
|
||
| retry { | ||
| maxRetries.set(2) | ||
| maxFailures.set(5) | ||
| failOnPassedAfterRetry.set(false) | ||
| } | ||
| } | ||
|
|
||
| jacocoTestReport { | ||
| dependsOn(test) | ||
| reports { | ||
| xml.required.set(true) | ||
| html.required.set(true) | ||
| } | ||
| } | ||
|
|
||
| check { | ||
| dependsOn(jacocoTestCoverageVerification) | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
buildSrc/src/main/kotlin/sb-ot-demo.kotlin-conventions.gradle.kts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| /* | ||
| * Copyright (c) 2020-2025. Ivan Vakhrushev and others. | ||
| * https://github.com/mfvanek/spring-boot-open-telemetry-demo | ||
| * | ||
| * Licensed under the Apache License 2.0 | ||
| */ | ||
|
|
||
| import org.jetbrains.kotlin.gradle.dsl.JvmTarget | ||
| import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | ||
|
|
||
| plugins { | ||
| id("java") | ||
| id("jacoco") | ||
| id("org.jetbrains.kotlin.jvm") | ||
| id("org.jetbrains.kotlin.plugin.spring") | ||
| id("io.gitlab.arturbosch.detekt") | ||
| id("sb-ot-demo.forbidden-apis") | ||
| id("sb-ot-demo.java-compile") | ||
| } | ||
|
|
||
| private val versionCatalog = extensions.getByType<VersionCatalogsExtension>().named("libs") | ||
|
|
||
| dependencies { | ||
| implementation("org.jetbrains.kotlin:kotlin-reflect") | ||
| versionCatalog.findLibrary("detekt-formatting").ifPresent { | ||
| detektPlugins(it) | ||
| } | ||
| versionCatalog.findLibrary("detekt-libraries").ifPresent { | ||
| detektPlugins(it) | ||
| } | ||
| } | ||
|
|
||
| tasks.withType<KotlinCompile> { | ||
| compilerOptions { | ||
| freeCompilerArgs.add("-Xjsr305=strict") | ||
| jvmTarget = JvmTarget.JVM_17 | ||
mfvanek marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
|
|
||
| detekt { | ||
| toolVersion = versionCatalog.findVersion("detekt").get().requiredVersion | ||
| config.setFrom(file("${rootDir}/config/detekt/detekt.yml")) | ||
| buildUponDefaultConfig = true | ||
| } | ||
|
|
||
| tasks { | ||
| withType<JavaCompile>().configureEach { | ||
| options.compilerArgs.add("-parameters") | ||
| options.compilerArgs.add("--should-stop=ifError=FLOW") | ||
| } | ||
|
|
||
| test { | ||
| testLogging.showStandardStreams = false // set to true for debug purposes | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| performance: | ||
| SpreadOperator: | ||
| active: false | ||
|
|
||
| style: | ||
| MaxLineLength: | ||
| maxLineLength: 200 | ||
mfvanek marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| [versions] | ||
| detekt = "1.23.8" | ||
| spring-boot-v3 = "3.4.4" | ||
|
|
||
| [libraries] | ||
| detekt = { group = "io.gitlab.arturbosch.detekt", name = "detekt-gradle-plugin", version.ref = "detekt" } | ||
| detekt-formatting = { group = "io.gitlab.arturbosch.detekt", name = "detekt-formatting", version.ref = "detekt" } | ||
| detekt-libraries = { group = "io.gitlab.arturbosch.detekt", name = "detekt-rules-libraries", version.ref = "detekt" } | ||
| spring-boot-v3-dependencies = { group = "org.springframework.boot", name = "spring-boot-dependencies", version.ref = "spring-boot-v3" } | ||
| springdoc-openapi = "org.springdoc:springdoc-openapi:2.8.6" | ||
| spring-cloud = "org.springframework.cloud:spring-cloud-dependencies:2024.0.1" | ||
| datasource-micrometer = "net.ttddyy.observation:datasource-micrometer-spring-boot:1.1.0" | ||
| logstash = "net.logstash.logback:logstash-logback-encoder:8.0" | ||
|
|
||
| [plugins] | ||
| spring-boot-v3 = { id = "org.springframework.boot", version.ref = "spring-boot-v3" } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,7 @@ | ||
| rootProject.name = "spring-boot-open-telemetry-demo" | ||
|
|
||
| include("spring-boot-3-demo-app") | ||
| include("common-internal-bom") | ||
| include("spring-boot-2-demo-app") | ||
| include("db-migrations") | ||
|
|
||
| dependencyResolutionManagement { | ||
| versionCatalogs { | ||
| create("libs") { | ||
| val springBoot3Version = version("spring-boot-v3", "3.4.4") | ||
| plugin("spring-boot-v3", "org.springframework.boot") | ||
| .versionRef(springBoot3Version) | ||
| library("spring-boot-v3-dependencies", "org.springframework.boot", "spring-boot-dependencies") | ||
| .versionRef(springBoot3Version) | ||
| } | ||
| } | ||
| } | ||
| include("spring-boot-3-demo-app-kotlin") |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.