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 {
buildsrc.conventions.base
buildsrc.conventions.sonarqube
}
group = "net.thauvin.erik"
version = "1.4.0-SNAPSHOT"
dependencies {
kover(projects.app)
kover(projects.lib)
}

View file

@ -1,15 +1,10 @@
package buildsrc.conventions.lang
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.TestLogEvent
import org.gradle.kotlin.dsl.withType
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.targets.jvm.KotlinJvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.sonarqube.gradle.SonarTask
/**
* Common configuration for Kotlin/JVM projects
@ -20,7 +15,8 @@ import org.sonarqube.gradle.SonarTask
plugins {
id("buildsrc.conventions.base")
kotlin("jvm")
id("buildsrc.conventions.code-quality")
id("io.gitlab.arturbosch.detekt")
id("org.jetbrains.kotlinx.kover")
}
java {
@ -39,4 +35,11 @@ tasks.withType<KotlinCompile>().configureEach {
tasks.withType<Test>().configureEach {
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
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
@ -13,6 +16,8 @@ import org.jetbrains.kotlin.gradle.targets.jvm.KotlinJvmTarget
plugins {
id("buildsrc.conventions.base")
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 {
license {
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 {

View file

@ -24,7 +24,6 @@ import org.sonarqube.gradle.SonarTask
plugins {
id("org.sonarqube")
id("io.gitlab.arturbosch.detekt")
id("org.jetbrains.kotlinx.kover")
}
@ -42,12 +41,3 @@ sonarqube {
tasks.withType<SonarTask>().configureEach {
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)
}
}