Skip to content

Commit

Permalink
CI env
Browse files Browse the repository at this point in the history
  • Loading branch information
gmuth committed Sep 13, 2023
1 parent 6abb19a commit b83dcc5
Showing 1 changed file with 29 additions and 32 deletions.
61 changes: 29 additions & 32 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import org.jetbrains.dokka.gradle.DokkaTask
import java.lang.System

// how to build? run ./gradlew
// where is the jar? build/lib/ipp-client-kotlin...jar
Expand Down Expand Up @@ -167,44 +166,42 @@ repo?.run { // tasks for publishing on maven repo

// ====== analyse code with SonarQube ======

val isRunningOnGithub = System.getProperty("CI")?.toBoolean() ?: false
val isRunningOnGithub = System.getenv("CI")?.toBoolean() ?: false
println("isRunningOnGithub=$isRunningOnGithub")
if(isRunningOnGithub) {

// required for sonarqube code coverage
// https://docs.sonarqube.org/latest/analysis/test-coverage/java-test-coverage
tasks.jacocoTestReport {
dependsOn(tasks.test)
// https://stackoverflow.com/questions/67725347/jacoco-fails-on-gradle-7-0-2-and-kotlin-1-5-10
//version = "0.8.7"
reports {
xml.required.set(true)
csv.required.set(false)
html.required.set(false)
}
}

// gradle test jacocoTestReport sonar
// https://docs.sonarqube.org/latest/analysis/scan/sonarscanner-for-gradle/
// configure token with 'publish analysis' permission in file ~/.gradle/gradle.properties:
// systemProp.sonar.login=<token>
sonar {
properties {
property("sonar.host.url", "https://sonarcloud.io")
property("sonar.projectKey", "gmuth_ipp-client-kotlin")
property("sonar.organization", "gmuth")
//property("sonar.verbose", "true")
//property("sonar.junit.reportPaths", "build/test-results/test")
//property("sonar.jacoco.reportPaths", "build/jacoco/test.exec")
//property("sonar.coverage.jacoco.xmlReportPaths", "build/reports/jacoco/test/")
}
// required for sonarqube code coverage
// https://docs.sonarqube.org/latest/analysis/test-coverage/java-test-coverage
tasks.jacocoTestReport {
dependsOn(tasks.test)
// https://stackoverflow.com/questions/67725347/jacoco-fails-on-gradle-7-0-2-and-kotlin-1-5-10
//version = "0.8.7"
reports {
xml.required.set(true)
csv.required.set(false)
html.required.set(false)
}
}

tasks.sonar {
dependsOn(tasks.jacocoTestReport) // for coverage
// gradle test jacocoTestReport sonar
// https://docs.sonarqube.org/latest/analysis/scan/sonarscanner-for-gradle/
// configure token with 'publish analysis' permission in file ~/.gradle/gradle.properties:
// systemProp.sonar.login=<token>
sonar {
properties {
property("sonar.host.url", "https://sonarcloud.io")
property("sonar.projectKey", "gmuth_ipp-client-kotlin")
property("sonar.organization", "gmuth")
//property("sonar.verbose", "true")
//property("sonar.junit.reportPaths", "build/test-results/test")
//property("sonar.jacoco.reportPaths", "build/jacoco/test.exec")
//property("sonar.coverage.jacoco.xmlReportPaths", "build/reports/jacoco/test/")
}
}

tasks.sonar {
dependsOn(tasks.jacocoTestReport) // for coverage
}

// ====== fat jar ======

tasks.register("fatJar", Jar::class) {
Expand Down

0 comments on commit b83dcc5

Please sign in to comment.