-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
180 lines (156 loc) · 4.85 KB
/
build.gradle.kts
File metadata and controls
180 lines (156 loc) · 4.85 KB
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
import io.github.gradlenexus.publishplugin.NexusRepository
import org.gradle.api.JavaVersion.VERSION_1_8
import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
kotlin("jvm") version "1.9.25"
id("com.palantir.git-version") version "3.2.0"
id("org.jetbrains.dokka") version "1.9.20"
`maven-publish`
signing
id("io.github.gradle-nexus.publish-plugin") version "1.3.0"
idea
}
group = "de.joshuagleitze"
version = if (isSnapshot) versionDetails.gitHash else versionDetails.lastTag.drop("v")
status = if (isSnapshot) "snapshot" else "release"
repositories {
mavenCentral()
}
dependencies {
testImplementation(name = "atrium-cc-en_GB-robstoll", group = "ch.tutteli.atrium", version = "0.15.0")
testImplementation(name = "junit-jupiter-api", group = "org.junit.jupiter", version = "5.7.2")
testImplementation(name = "junit-jupiter-params", group = "org.junit.jupiter", version = "5.7.2")
constraints {
testImplementation(kotlin("reflect", KotlinVersion.CURRENT.toString()))
}
testRuntimeOnly(name = "junit-jupiter-engine", group = "org.junit.jupiter", version = "5.7.2")
}
idea {
module {
isDownloadSources = true
isDownloadJavadoc = true
}
}
tasks.withType<Test> {
useJUnitPlatform()
reports.junitXml.required.set(true)
}
java {
sourceCompatibility = VERSION_1_8
targetCompatibility = VERSION_1_8
}
tasks.withType<KotlinCompile> {
kotlinOptions {
jvmTarget = "1.8"
}
}
val ossrhUsername: String? by project
val ossrhPassword: String? by project
val githubRepository: String? by project
val githubOwner = githubRepository?.split("/")?.get(0)
val githubToken: String? by project
val sourcesJar by tasks.creating(Jar::class) {
group = "build"
description = "Assembles the source code into a jar"
archiveClassifier.set("sources")
from(sourceSets.main.get().allSource)
}
tasks.withType<DokkaTask> {
dokkaSourceSets.named("main") {
sourceLink {
localDirectory.set(file("src/main/kotlin"))
remoteUrl.set(uri("https://github.com/$githubRepository/blob/main/src/main/kotlin").toURL())
remoteLineSuffix.set("#L")
}
}
}
val dokkaJar by tasks.creating(Jar::class) {
group = "build"
description = "Assembles the Kotlin docs with Dokka"
archiveClassifier.set("javadoc")
from(tasks.named("dokkaJavadoc"))
}
artifacts {
archives(sourcesJar)
archives(dokkaJar)
}
lateinit var publication: MavenPublication
lateinit var githubPackages: ArtifactRepository
lateinit var mavenCentral: NexusRepository
publishing {
publications {
publication = create<MavenPublication>("maven") {
from(components["java"])
artifact(sourcesJar)
artifact(dokkaJar)
pom {
name.set(provider { "$groupId:$artifactId" })
description.set("Convert between different string notations commonly found in programming")
inceptionYear.set("2020")
url.set("https://github.com/$githubRepository")
ciManagement {
system.set("GitHub Actions")
url.set("https://github.com/$githubRepository/actions")
}
issueManagement {
system.set("GitHub Issues")
url.set("https://github.com/$githubRepository/issues")
}
developers {
developer {
name.set("Joshua Gleitze")
email.set("dev@joshuagleitze.de")
}
}
scm {
connection.set("scm:git:https://github.com/$githubRepository.git")
developerConnection.set("scm:git:git://git@github.com:$githubRepository.git")
url.set("https://github.com/$githubRepository")
}
licenses {
license {
name.set("MIT")
url.set("https://opensource.org/licenses/MIT")
distribution.set("repo")
}
}
}
}
}
repositories {
githubPackages = maven("https://maven.pkg.github.com/$githubRepository") {
name = "GitHubPackages"
credentials {
username = githubOwner
password = githubToken
}
}
}
}
nexusPublishing {
repositories {
mavenCentral = sonatype {
username.set(ossrhUsername)
password.set(ossrhPassword)
}
}
}
signing {
val signingKey: String? by project
val signingKeyPassword: String? by project
useInMemoryPgpKeys(signingKey, signingKeyPassword)
sign(publication)
}
val closeAndReleaseStagingRepository by project.tasks
closeAndReleaseStagingRepository.mustRunAfter(mavenCentral.publishTask)
task("release") {
group = "release"
description = "Releases the project to Maven Central"
dependsOn(githubPackages.publishTask, mavenCentral.publishTask, closeAndReleaseStagingRepository)
}
val Project.isSnapshot get() = versionDetails.commitDistance != 0
fun String.drop(prefix: String) = if (this.startsWith(prefix)) this.drop(prefix.length) else this
val Project.versionDetails get() = (this.extra["versionDetails"] as groovy.lang.Closure<*>)() as com.palantir.gradle.gitversion.VersionDetails
val ArtifactRepository.publishTask get() = tasks["publishAllPublicationsTo${this.name}Repository"]
val NexusRepository.publishTask get() = "publishTo${this.name.replaceFirstChar { it.titlecase() }}"