refactor sonar build config

This commit is contained in:
Adam 2023-06-02 08:49:55 +02:00
parent 228b3fb4e3
commit 78403becf2
6 changed files with 31 additions and 18 deletions

View file

@ -17,7 +17,13 @@
plugins { plugins {
buildsrc.conventions.base buildsrc.conventions.base
buildsrc.conventions.sonarqube
} }
group = "net.thauvin.erik" group = "net.thauvin.erik"
version = "1.4.0-SNAPSHOT" version = "1.4.0-SNAPSHOT"
dependencies {
kover(projects.app)
kover(projects.lib)
}

View file

@ -9,4 +9,4 @@ dependencies {
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.21") implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.21")
implementation("org.jetbrains.kotlinx:kover-gradle-plugin:0.7.0") implementation("org.jetbrains.kotlinx:kover-gradle-plugin:0.7.0")
implementation("org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:4.2.0.3129") implementation("org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:4.2.0.3129")
} }

View file

@ -1,15 +1,10 @@
package buildsrc.conventions.lang package buildsrc.conventions.lang
import buildsrc.utils.Rife2TestListener import buildsrc.utils.Rife2TestListener
import org.gradle.api.JavaVersion
import org.gradle.api.tasks.testing.Test
import org.gradle.api.tasks.testing.logging.TestExceptionFormat import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.gradle.kotlin.dsl.withType
import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.targets.jvm.KotlinJvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.sonarqube.gradle.SonarTask
/** /**
* Common configuration for Kotlin/JVM projects * Common configuration for Kotlin/JVM projects
@ -20,7 +15,8 @@ import org.sonarqube.gradle.SonarTask
plugins { plugins {
id("buildsrc.conventions.base") id("buildsrc.conventions.base")
kotlin("jvm") kotlin("jvm")
id("buildsrc.conventions.code-quality") id("io.gitlab.arturbosch.detekt")
id("org.jetbrains.kotlinx.kover")
} }
java { java {
@ -39,4 +35,11 @@ tasks.withType<KotlinCompile>().configureEach {
tasks.withType<Test>().configureEach { tasks.withType<Test>().configureEach {
useJUnitPlatform() useJUnitPlatform()
val testsBadgeApiKey = providers.gradleProperty("testsBadgeApiKey")
addTestListener(Rife2TestListener(testsBadgeApiKey))
testLogging {
exceptionFormat = TestExceptionFormat.FULL
events = setOf(TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.FAILED)
}
} }

View file

@ -1,5 +1,8 @@
package buildsrc.conventions.lang package buildsrc.conventions.lang
import buildsrc.utils.Rife2TestListener
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.jetbrains.kotlin.gradle.targets.jvm.KotlinJvmTarget import org.jetbrains.kotlin.gradle.targets.jvm.KotlinJvmTarget
@ -13,6 +16,8 @@ import org.jetbrains.kotlin.gradle.targets.jvm.KotlinJvmTarget
plugins { plugins {
id("buildsrc.conventions.base") id("buildsrc.conventions.base")
kotlin("multiplatform") kotlin("multiplatform")
id("io.gitlab.arturbosch.detekt")
id("org.jetbrains.kotlinx.kover")
} }
@ -43,3 +48,12 @@ kotlin {
} }
} }
} }
tasks.withType<Test>().configureEach {
val testsBadgeApiKey = providers.gradleProperty("testsBadgeApiKey")
addTestListener(Rife2TestListener(testsBadgeApiKey))
testLogging {
exceptionFormat = TestExceptionFormat.FULL
events = setOf(TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.FAILED)
}
}

View file

@ -36,7 +36,7 @@ publishing {
licenses { licenses {
license { license {
name.set("The Apache License, Version 2.0") name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt") url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
} }
} }
developers { developers {

View file

@ -24,7 +24,6 @@ import org.sonarqube.gradle.SonarTask
plugins { plugins {
id("org.sonarqube") id("org.sonarqube")
id("io.gitlab.arturbosch.detekt")
id("org.jetbrains.kotlinx.kover") id("org.jetbrains.kotlinx.kover")
} }
@ -42,12 +41,3 @@ sonarqube {
tasks.withType<SonarTask>().configureEach { tasks.withType<SonarTask>().configureEach {
dependsOn(tasks.matching { it.name == "koverXmlReport" }) dependsOn(tasks.matching { it.name == "koverXmlReport" })
} }
tasks.withType<Test>().configureEach {
val testsBadgeApiKey = providers.gradleProperty("testsBadgeApiKey")
addTestListener(Rife2TestListener(testsBadgeApiKey))
testLogging {
exceptionFormat = TestExceptionFormat.FULL
events = setOf(TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.FAILED)
}
}