Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ max_line_length = 199
tab_width = 4
ij_continuation_indent_size = 4

[*.java]
[*.{java,kt}]
ij_java_imports_layout = *,|,java.**,javax.**,|,$*
ij_java_align_multiline_parameters = true
ij_java_blank_lines_after_class_header = 1
Expand All @@ -30,8 +30,8 @@ ij_java_keep_simple_blocks_in_one_line = true
ij_java_keep_simple_classes_in_one_line = false
ij_java_keep_simple_lambdas_in_one_line = true
ij_java_keep_simple_methods_in_one_line = true
ij_java_names_count_to_use_import_on_demand = 101
ij_java_class_count_to_use_import_on_demand = 101
ij_java_names_count_to_use_import_on_demand = 201
ij_java_class_count_to_use_import_on_demand = 201
ij_java_packages_to_use_import_on_demand = java.awt.*, javax.swing.*
ij_java_prefer_longer_names = true
ij_java_space_after_closing_angle_bracket_in_type_argument = false
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ description = "Experiments with Java"

allprojects {
group = "io.github.mfvanek"
version = "0.3.3"
version = "0.4.0"

repositories {
mavenLocal()
Expand Down
4 changes: 4 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,8 @@ dependencies {
implementation("de.thetaphi:forbiddenapis:3.9")
implementation("com.github.spotbugs.snom:spotbugs-gradle-plugin:6.1.7")
implementation("org.gradle:test-retry-gradle-plugin:1.6.2")
val kotlinVersion = "2.0.21"
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
implementation("org.jetbrains.kotlin:kotlin-allopen:$kotlinVersion")
implementation(libs.detekt)
}
9 changes: 9 additions & 0 deletions buildSrc/settings.gradle.kts
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 buildSrc/src/main/kotlin/sb-ot-demo.jacoco-rules.gradle.kts
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()
}
}
}
}
}
63 changes: 63 additions & 0 deletions buildSrc/src/main/kotlin/sb-ot-demo.java-compile.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Copyright (c) 2020-2025. Ivan Vakhrushev and others.
* https://github.com/mfvanek/spring-boot-open-telemetry-demo
*
* Licensed under the Apache License 2.0
*/

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.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
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)
}
}
76 changes: 2 additions & 74 deletions buildSrc/src/main/kotlin/sb-ot-demo.java-conventions.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ plugins {
id("net.ltgt.errorprone")
id("com.google.osdetector")
id("org.gradle.test-retry")
id("sb-ot-demo.java-compile")
id("sb-ot-demo.jacoco-rules")
}

dependencies {
Expand All @@ -43,16 +45,6 @@ dependencies {
spotbugsPlugins("com.mebigfatguy.sb-contrib:sb-contrib:7.6.9")
}

java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}

jacoco {
toolVersion = "0.8.12"
}

checkstyle {
toolVersion = "10.21.1"
configFile = file("${rootDir}/config/checkstyle/checkstyle.xml")
Expand Down Expand Up @@ -84,77 +76,13 @@ tasks.withType<SpotBugsTask>().configureEach {

tasks {
withType<JavaCompile>().configureEach {
options.compilerArgs.add("-parameters")
options.compilerArgs.add("--should-stop=ifError=FLOW")
options.errorprone {
disableWarningsInGeneratedCode.set(true)
disable("Slf4jLoggerShouldBeNonStatic")
}
}

test {
useJUnitPlatform()
dependsOn(checkstyleMain, checkstyleTest, pmdMain, pmdTest, spotbugsMain, spotbugsTest)
finalizedBy(jacocoTestReport, jacocoTestCoverageVerification)
maxParallelForks = 1

retry {
maxRetries.set(2)
maxFailures.set(5)
failOnPassedAfterRetry.set(false)
}
}

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()
}
}
}
}

jacocoTestReport {
dependsOn(test)
reports {
xml.required.set(true)
html.required.set(true)
}
}

check {
dependsOn(jacocoTestCoverageVerification)
}
}
45 changes: 45 additions & 0 deletions buildSrc/src/main/kotlin/sb-ot-demo.kotlin-conventions.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* 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 libs = extensions.getByType<VersionCatalogsExtension>().named("libs")

dependencies {
implementation("org.jetbrains.kotlin:kotlin-reflect")
libs.findLibrary("detekt-formatting").ifPresent {
detektPlugins(it)
}
libs.findLibrary("detekt-libraries").ifPresent {
detektPlugins(it)
}
}

tasks.withType<KotlinCompile> {
compilerOptions {
freeCompilerArgs.add("-Xjsr305=strict")
jvmTarget = JvmTarget.JVM_21
}
}

detekt {
toolVersion = libs.findVersion("detekt").get().requiredVersion
config.setFrom(file("${rootDir}/config/detekt/detekt.yml"))
buildUponDefaultConfig = true
autoCorrect = true
}
Loading