-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.gradle.kts
125 lines (105 loc) · 3.65 KB
/
build.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.StandardCopyOption
buildscript {
// needs to be defined in here because otherwise tutteli-publish plugin does not have this information when applied
// and we want that it to apply the ch.tutteli conventions
rootProject.version = "2.2.0-SNAPSHOT"
rootProject.group = "ch.tutteli.kbox"
rootProject.description = "A utility library for Kotlin"
extra.set("generationFolder", project.files("src/commonMain/generated/kotlin"))
extra.set("generationTestFolder", project.files("src/commonTest/generated/kotlin"))
}
val generationFolder: ConfigurableFileCollection by extra
val generationTestFolder: ConfigurableFileCollection by extra
plugins {
id("build-logic.published-kotlin-multiplatform")
id("code-generation.generate")
alias(libs.plugins.detekt)
alias(libs.plugins.nexus.publish)
}
kotlin {
sourceSets {
commonMain {
kotlin.srcDir(generationFolder)
}
commonTest {
kotlin.srcDir(generationTestFolder)
dependencies {
implementation(libs.atrium.fluent.get().let { "${it.module}:${it.version}" }) {
exclude(group = "ch.tutteli.kbox")
}
}
}
}
}
detekt {
allRules = true
config.from(files("${rootProject.projectDir}/gradle/detekt.yml"))
}
val detektTasks = tasks.withType<io.gitlab.arturbosch.detekt.Detekt>()
fun Task.reportXml(): Path {
val fileName = if (name == "detekt") "detekt" else name.substring("detekt".length)
return project.layout.buildDirectory.file("reports/detekt/$fileName.xml").get().asFile.toPath()
}
// not provided by detekt itself so far, might change in the future
val allDetekt = tasks.register("allDetekt") {
detektTasks.forEach {
it.reports {
xml.required.set(true)
html.required.set(false)
txt.required.set(false)
sarif.required.set(false)
md.required.set(false)
}
dependsOn(it)
}
}
tasks.named("check").configure {
dependsOn(allDetekt)
}
detektTasks.forEach {
val reportXml = it.reportXml()
it.doLast {
// necessary as currently detekt writes main.xml for each platform and overrides when doing so
Files.move(
project.project.layout.buildDirectory.file("reports/detekt/main.xml").get().asFile.toPath(),
reportXml,
StandardCopyOption.REPLACE_EXISTING
)
}
// as we change name of the output file, we need to let gradle know about it
it.outputs.file(reportXml)
}
nexusPublishing {
repositories {
sonatype()
}
}
/*
Release & deploy a commit
--------------------------------
1. search for X.Y.Z-SNAPSHOT and replace with X.Y.Z
2. update main:
a) point to the tag, search for `tree/main` and replace it with `tree/vX.Y.Z` (README.md)
b) update badges
c) gr dokkaHtml
d) commit (modified docs/index.md, docs/kdoc/*, build.gradle.kts, README.md)
e) git tag vX.Y.Z
f) git push origin vX.Y.Z
4. deploy to maven-central:
a) echo "enter the sonatype user token"
read SONATYPE_PW
java -version 2>&1 | grep "version \"11" && ORG_GRADLE_PROJECT_sonatypePassword="$SONATYPE_PW" PUB=true CI=true gr clean publishToSonatype
b) Log into https://oss.sonatype.org/#stagingRepositories
c) check if staging repo is ok
d) close repo
e) release repo
5. create release on github
Prepare next dev cycle
-----------------------
1. point to main, search for `tree/vX.Y.Z` and replace it with `tree/main`
2. Replace badges
3. search for X.Y.Z and replace with X.Y.Z-SNAPSHOT
4. commit & push changes
*/