一键导入
ci-cd-sonar
Load when configuring build pipeline, CI workflows, SonarCloud, JaCoCo, or the Gradle version catalog. Covers fatJar, ktlint, and dependency management.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Load when configuring build pipeline, CI workflows, SonarCloud, JaCoCo, or the Gradle version catalog. Covers fatJar, ktlint, and dependency management.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Load when adding scheduled tasks, periodic jobs, or background coroutines. Covers the coroutine-based task pattern, error handling, and lifecycle management.
Load when adding new configuration properties, modifying HOCON files, or understanding how config is loaded. Covers app.conf, application.conf, and the loading pipeline.
IMPORTANT: Load when adding error handling in routes, services, or repositories. Covers AcknowledgeBO vs exceptions, standardized responses, and proper logging.
Load when implementing multipart file upload, download, or file storage. Covers multipart parsing, validation, disk persistence, and URL generation.
IMPORTANT: Load when adding monitoring, metrics, or logging. Covers Micrometer/Prometheus, SLF4J usage, CallLogging, and observability patterns.
IMPORTANT: Load when onboarding, planning a new feature, or understanding how the project is wired end-to-end. Covers the full stack: startup → DI → data → routing → config.
| name | ci-cd-sonar |
| description | Load when configuring build pipeline, CI workflows, SonarCloud, JaCoCo, or the Gradle version catalog. Covers fatJar, ktlint, and dependency management. |
.github/workflows/gradle/libs.versions.tomltesting-ktordata-access or api-routingFile: .github/workflows/ktlint.yaml
ScaCap/action-ktlint@masterfail_on_error: true)intellij_idea code style (configured in .editorconfig)File: .github/workflows/sonarcloud-analysis.yaml
master and on every PR./gradlew build sonar --infoSONAR_TOKEN, SONAR_PROJECT_KEY, SONAR_ORGANIZATION secrets/varsfetch-depth: 0 for full git history (required for Sonar analysis)gradle/libs.versions.toml)All dependencies are managed via version catalog. Structure:
[versions]
ktor = "3.1.3"
kotlin = "2.1.20"
# ...
[libraries]
ktor-server-core = { module = "io.ktor:ktor-server-core-jvm", version.ref = "ktor" }
# ...
[plugins]
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
# ...
ktor-server-core → libs.ktor.server.core)-jvm classifier (except client modules and rate-limit)ktor-server-tests uses pinned version 2.3.13 (different from main Ktor version)[versions] block, referenced by version.refsonar {
properties {
property("sonar.coverage.exclusions", listOf(
"**/*BO.kt",
"**/*DTO.kt",
"**/*Exception.kt",
"src/main/kotlin/es/wokis/Application.kt",
"*.kts",
"**/di/*.kt",
))
}
}
BO, DTO, Exception, Application.kt, build scripts, and DI modules are excluded from coverage analysis.
Configured in build.gradle.kts:
tasks.test {
useJUnitPlatform()
finalizedBy(tasks.jacocoTestReport)
}
jacoco {
toolVersion = libs.versions.jacoco.get()
}
tasks.jacocoTestReport {
dependsOn(tasks.test)
reports {
xml.required = true
xml.outputLocation.set(file("build/reports/jacoco/test-results/jacocoTestReport.xml"))
}
}
Uses Ktor Gradle plugin for fat JAR:
ktor {
fatJar {
archiveFileName.set("${rootProject.name}-${rootProject.version}.jar")
}
}
Run with:
./gradlew fatJar
# Output: build/libs/ecibot-server-1.0.jar
| Command | Purpose |
|---|---|
./gradlew build | Full build + tests |
./gradlew test | Run tests only |
./gradlew fatJar | Build executable fat JAR |
./gradlew sonar | Run SonarCloud analysis |
./gradlew build sonar --info | CI build + analysis |
build.gradle.kts — always add to version catalog firstgithub-pr-review (required for PR annotations)fetch-depth: 0 from SonarCloud workflow.github/workflows/ktlint.yaml — ktlint CI.github/workflows/sonarcloud-analysis.yaml — SonarCloud CIbuild.gradle.kts — build configuration, JaCoCo, Sonar, fat JARgradle/libs.versions.toml — version catalog