This repository has been archived by the owner on May 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
238 lines (215 loc) · 6.57 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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
import java.time.Duration
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
plugins {
jacoco
`java-gradle-plugin`
kotlin("jvm")
`maven-publish`
signing
id("com.gradle.plugin-publish")
id("io.gitlab.arturbosch.detekt")
id("org.jetbrains.dokka")
id("org.jlleitschuh.gradle.ktlint")
id("org.danilopianini.git-sensitive-semantic-versioning")
id("org.danilopianini.publish-on-central")
id("de.marcphilipp.nexus-publish")
}
/*
* Project information
*/
group = "io.github.gciatto"
description = "A Gradle plugin easing the configuration Kotlin Multiplaftorm projects"
inner class PluginInfo {
val longName = "Set up Kotlin MPP projects via Gradle"
val website = "https://github.com/gciatto/kt-mpp-pp"
val scm = "git@github.com:gciatto/kt-mpp-pp.git"
val pluginImplementationClass = "$group.kt.mpp.KtMppPlusPlusPlugin"
val tags = listOf("kotlin", "multi plaftorm", "mpp", "gradle")
val license = "Apache License, Version 2.0"
val licenseUrl = "https://www.apache.org/licenses/LICENSE-2.0"
}
val info = PluginInfo()
gitSemVer {
version = computeGitSemVer()
}
println("$group:$name v$version")
repositories {
mavenCentral()
jcenter()
maven("https://plugins.gradle.org/m2/")
mapOf(
"kotlin/dokka" to setOf("org.jetbrains.dokka"),
"kotlin/kotlinx.html" to setOf("org.jetbrains.kotlinx"),
"arturbosch/code-analysis" to setOf("io.gitlab.arturbosch.detekt")
).forEach { (uriPart, groups) ->
maven {
url = uri("https://dl.bintray.com/$uriPart")
content { groups.forEach { includeGroup(it) } }
}
}
}
dependencies {
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:_")
api(gradleApi())
api(gradleKotlinDsl())
api("org.jetbrains.kotlin:kotlin-gradle-plugin:_")
implementation(kotlin("stdlib-jdk8"))
implementation("org.jlleitschuh.gradle:ktlint-gradle:_")
implementation("com.jfrog.bintray.gradle:gradle-bintray-plugin:_")
implementation("com.github.breadmoirai:github-release:_")
implementation("io.github.gciatto:kt-npm-publish:_")
implementation("org.jetbrains.dokka:dokka-gradle-plugin:_")
testImplementation(gradleTestKit())
testImplementation("com.uchuhimo:konf-yaml:_")
testImplementation("io.github.classgraph:classgraph:_")
testImplementation("io.kotest:kotest-runner-junit5:_")
testImplementation("io.kotest:kotest-assertions-core-jvm:_")
testImplementation("com.nhaarman.mockitokotlin2:mockito-kotlin:_")
testImplementation("org.mockito:mockito-core:_")
// testRuntimeOnly(files(createClasspathManifest))
}
kotlin {
target {
compilations.all {
kotlinOptions {
allWarningsAsErrors = true
// freeCompilerArgs = listOf("-XXLanguage:+InlineClasses", "-Xopt-in=kotlin.RequiresOptIn")
jvmTarget = JavaVersion.VERSION_1_8.toString()
}
}
}
}
java {
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_1_8
}
tasks.test {
useJUnitPlatform()
testLogging {
showStandardStreams = true
showCauses = true
showStackTraces = true
events(*TestLogEvent.values())
exceptionFormat = TestExceptionFormat.FULL
}
}
tasks.jacocoTestReport {
reports {
// Used by Codecov.io
xml.isEnabled = true
}
}
detekt {
failFast = true
buildUponDefaultConfig = true
config = files("$projectDir/config/detekt.yml")
reports {
html.enabled = true
xml.enabled = true
txt.enabled = true
}
}
pluginBundle {
website = info.website
vcsUrl = info.website
tags = info.tags
}
gradlePlugin {
plugins {
create("KtMppPlusPlus") {
id = "${rootProject.group}.${rootProject.name}"
displayName = info.longName
description = project.description
implementationClass = info.pluginImplementationClass
}
}
}
val signingKey: String? by project
val signingPassword: String? by project
println(
"""
Signing Key: ${mask(signingKey)}
Signing Passowrd: ${mask(signingPassword)}
""".trimIndent()
)
signing {
useInMemoryPgpKeys(signingKey, signingPassword)
}
val mavenRepo: String by project
val mavenUsername: String by project
val mavenPassword: String by project
println(
"""
Maven Repository: ${show(mavenRepo)}
Maven Username: ${show(mavenUsername)}
Maven Password: ${mask(mavenPassword)}
""".trimIndent()
)
publishing {
repositories {
maven(mavenRepo) {
credentials {
username = mavenUsername
password = mavenPassword
}
}
}
publications {
withType<MavenPublication> {
val pubName = name
pom {
name.set(info.longName)
description.set(project.description)
packaging = "jar"
url.set(info.website)
if (pubName.contains("plugin", ignoreCase = true)) {
licenses {
license {
name.set(info.license)
url.set(info.licenseUrl)
}
}
}
scm {
url.set(info.website)
connection.set(info.scm)
developerConnection.set(info.scm)
}
developers {
developer {
name.set("Giovanni Ciatto")
email.set("giovanni.ciatto@gmail.com")
url.set("https://about.me/gciatto")
}
}
}
}
}
}
publishOnCentral {
projectLongName = info.longName
projectDescription = project.description ?: "No description provided"
projectUrl = info.website
scmConnection = info.scm
licenseName = info.license
licenseUrl = info.licenseUrl
repository(mavenRepo) {
user = mavenUsername
password = mavenPassword
}
}
nexusPublishing {
repositories {
sonatype {
nexusUrl.set(uri(mavenRepo))
username.set(mavenUsername)
password.set(mavenPassword)
}
}
clientTimeout.set(Duration.ofMinutes(10))
}
fun mask(string: String?): String =
if (string.isNullOrBlank()) "<missing>" else "<provided>"
fun show(string: String?): String =
if (string.isNullOrBlank()) "<missing>" else string