This repository has been archived by the owner on Aug 24, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathbuild.gradle.kts
215 lines (177 loc) · 5.59 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
@file:Suppress("UNUSED_VARIABLE")
import com.jfrog.bintray.gradle.BintrayExtension
import com.jfrog.bintray.gradle.BintrayPlugin
import kr.motd.gradle.sphinx.gradle.SphinxTask
import org.codehaus.plexus.util.Os
import java.util.Date
plugins {
`maven-publish`
id("org.jetbrains.kotlin.multiplatform") version "1.4.32"
id("com.github.ben-manes.versions") version "0.39.0"
id("io.gitlab.arturbosch.detekt") version "1.17.1"
id("com.jfrog.bintray") version "1.8.5" apply false
id("kr.motd.sphinx") version "2.10.1"
}
detekt {
input = files(
subprojects.flatMap { project ->
listOf(
"${project.projectDir}/src/commonMain/kotlin",
"${project.projectDir}/src/jvmMain/kotlin"
)
}
)
buildUponDefaultConfig = true
config = files("$rootDir/detekt-config.yml")
}
allprojects {
group = "com.github.jcornaz.kwik"
// version = currentVersion
repositories {
mavenCentral()
jcenter()
}
}
// Hack so that we can configure all subprojects from this file
kotlin { jvm() }
subprojects {
apply(plugin = "org.jetbrains.kotlin.multiplatform")
apply<BintrayPlugin>()
apply<MavenPublishPlugin>()
apply<JacocoPlugin>()
apply<JavaPlugin>()
kotlin {
jvm {
compilations.all {
kotlinOptions {
jvmTarget = "1.8"
}
}
}
linuxX64("linux")
mingwX64("windows")
@Suppress("SuspiciousCollectionReassignment")
targets.all {
compilations.all {
explicitApi()
kotlinOptions {
allWarningsAsErrors = findProperty("warningAsError") != null
freeCompilerArgs += "-Xopt-in=kotlin.RequiresOptIn"
}
}
}
sourceSets {
commonTest {
dependencies {
api(kotlin("test-common"))
api(kotlin("test-annotations-common"))
}
}
val jvmTest by existing {
dependencies {
implementation(kotlin("test"))
implementation(kotlin("test-junit"))
}
}
}
}
configure<JacocoPluginExtension> {
toolVersion = "0.8.6"
}
publishing {
publications.withType<MavenPublication>().apply {
val metadata by getting {
artifactId = "kwik-${project.name}-common"
}
val jvm by getting {
artifactId = "kwik-${project.name}-jvm"
}
if (Os.isFamily(Os.FAMILY_UNIX)) {
val linux by getting {
artifactId = "kwik-${project.name}-linux"
}
}
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
val windows by getting {
artifactId = "kwik-${project.name}-windows"
}
}
}
}
configure<BintrayExtension> {
user = System.getenv("BINTRAY_USER")
key = System.getenv("BINTRAY_KEY")
publish = true
with(pkg) {
userOrg = "kwik"
name = "kwik"
repo = when {
'-' in project.version.toString() -> "preview"
else -> "stable"
}
setLicenses("Apache-2.0")
vcsUrl = "https://github.com/jcornaz/kwik"
githubRepo = "jcornaz/kwik"
with(version) {
name = project.version.toString()
released = Date().toString()
if ('+' !in project.version.toString()) {
vcsTag = project.version.toString()
}
}
}
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
setPublications("windows")
} else {
setPublications("metadata", "jvm", "linux")
}
}
tasks {
val jvmTest by existing {
finalizedBy("jacocoTestReport")
}
val check by existing {
dependsOn("publishToMavenLocal")
}
val jacocoTestReport by existing(JacocoReport::class) {
dependsOn(jvmTest)
classDirectories.setFrom(File("$buildDir/classes/kotlin/jvm/main").walkBottomUp().toSet())
sourceDirectories.setFrom(files("src/commonMain/kotlin", "src/jvmMain/kotlin"))
executionData.setFrom(files("${buildDir}/jacoco/jvmTest.exec"))
reports {
xml.isEnabled = true
html.isEnabled = true
}
}
}
}
tasks {
val version by registering {
group = "Help"
description = "Prints version of kwik"
doLast {
println(project.version)
}
}
val detekt by existing {
description = "Performs static code analysis and report detected code smells"
}
val sphinx by existing(SphinxTask::class) {
setWarningsAsErrors(true)
setSourceDirectory("$rootDir/docs")
inputs.file("$rootDir/README.rst")
inputs.dir("$rootDir/example")
outputs.cacheIf { true }
}
val testReport by registering(TestReport::class) {
group = "Verification"
description = "Create an aggregated report of all test tasks"
destinationDir = file("$buildDir/reports/allTests")
reportOn(subprojects.flatMap { it.tasks.withType(Test::class) })
dependsOn.clear()
mustRunAfter(subprojects.flatMap { it.tasks.withType(Test::class) })
}
val check by existing {
dependsOn(sphinx)
}
}