-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathbuild.gradle.kts
163 lines (148 loc) · 4.6 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
import org.jetbrains.dokka.gradle.DokkaTask
plugins {
kotlin("jvm") version "1.9.24"
alias(libs.plugins.shadowjar)
`maven-publish`
signing
alias(libs.plugins.spotless)
alias(libs.plugins.dokka) apply false
}
repositories {
mavenCentral()
}
dependencies {
compileOnly(libs.detekt.api)
testImplementation(libs.detekt.test)
testImplementation(libs.bundles.koTest)
}
tasks.withType<Test> {
useJUnitPlatform()
systemProperty("compile-snippet-tests", true)
testLogging {
showExceptions = true
showStandardStreams = true
events = setOf(
org.gradle.api.tasks.testing.logging.TestLogEvent.FAILED,
org.gradle.api.tasks.testing.logging.TestLogEvent.PASSED,
)
exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
}
}
allprojects {
apply(plugin = "kotlin")
apply(plugin = "maven-publish")
apply(plugin = "org.jetbrains.dokka")
apply(plugin = "signing")
kotlin {
jvmToolchain(11)
}
// see https://github.com/johnrengelman/shadow/issues/651
if (!hasProperty("uberJar")) {
val javaComponent = components.findByName("java") as AdhocComponentWithVariants
javaComponent.withVariantsFromConfiguration(configurations["shadowRuntimeElements"]) {
skip()
}
}
val dokkaHtml by tasks.existing(DokkaTask::class)
val dokkaJar by tasks.creating(org.gradle.jvm.tasks.Jar::class) {
group = JavaBasePlugin.DOCUMENTATION_GROUP
archiveClassifier.set("javadoc")
from(dokkaHtml)
}
val sourcesJar by tasks.creating(org.gradle.jvm.tasks.Jar::class) {
archiveClassifier.set("sources")
from(sourceSets.main.get().allSource)
}
val pomArtifactId: String? by project
if (pomArtifactId != null) {
publishing {
publications {
create<MavenPublication>("maven") {
val versionName: String by project
val pomGroupId: String by project
groupId = pomGroupId
artifactId = pomArtifactId
version = versionName
from(components["java"])
artifact(dokkaJar)
artifact(sourcesJar)
pom {
val pomDescription: String by project
val pomUrl: String by project
val pomName: String by project
description.set(pomDescription)
url.set(pomUrl)
name.set(pomName)
scm {
val pomScmUrl: String by project
val pomScmConnection: String by project
val pomScmDevConnection: String by project
url.set(pomScmUrl)
connection.set(pomScmConnection)
developerConnection.set(pomScmDevConnection)
}
licenses {
license {
val pomLicenseName: String by project
val pomLicenseUrl: String by project
val pomLicenseDist: String by project
name.set(pomLicenseName)
url.set(pomLicenseUrl)
distribution.set(pomLicenseDist)
}
}
developers {
developer {
val pomDeveloperId: String by project
val pomDeveloperName: String by project
id.set(pomDeveloperId)
name.set(pomDeveloperName)
}
}
}
}
}
signing {
sign(publishing.publications["maven"])
}
repositories {
maven {
val releasesRepoUrl = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
val snapshotsRepoUrl = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
val versionName: String by project
url = if (versionName.endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl
credentials {
username = project.findProperty("NEXUS_USERTOKEN_NAME")?.toString()
password = project.findProperty("NEXUS_USERTOKEN_PASSWORD")?.toString()
}
}
}
}
}
}
spotless {
kotlin {
target("**/*.kt")
targetExclude("!**/build/**/*.*")
ktlint(libs.versions.ktlint.get())
.editorConfigOverride(
mapOf(
"indent_size" to "2",
"max_line_length" to "120",
"ktlint_standard_function-expression-body" to "disabled",
"ktlint_standard_class-signature" to "disabled",
),
)
trimTrailingWhitespace()
endWithNewline()
}
kotlinGradle {
target("**/*.gradle.kts")
ktlint(libs.versions.ktlint.get())
.editorConfigOverride(
mapOf("indent_size" to "2", "max_line_length" to "120"),
)
trimTrailingWhitespace()
endWithNewline()
}
}