Skip to content

Commit 6e492bd

Browse files
committed
chore: update codebase
1 parent c6ccaf7 commit 6e492bd

File tree

8 files changed

+158
-162
lines changed

8 files changed

+158
-162
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ on:
55
branches: [ main ]
66
pull_request:
77

8+
env:
9+
ORG_GRADLE_PROJECT_version: ${{ github.sha }}
10+
811
jobs:
912

1013
build:

.github/workflows/release.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ on:
44
release:
55
types: [published]
66

7+
env:
8+
ORG_GRADLE_PROJECT_version: ${{ github.event.release.tag_name }}
9+
ORG_GRADLE_PROJECT_githubRepository: ${{ github.repository }}
10+
711
jobs:
812
release:
913
name: Release Artefacts
@@ -30,14 +34,11 @@ jobs:
3034
run: ./gradlew clean dependencies
3135
- name: Assemble Artefacts
3236
run: ./gradlew assemble
33-
env:
34-
ORG_GRADLE_PROJECT_githubRepository: ${{ github.repository }}
3537
- name: Release Artefacts
3638
run: ./gradlew release
3739
env:
3840
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.PACKAGE_SIGNING_KEY }}
3941
ORG_GRADLE_PROJECT_signingKeyPassword: ${{ secrets.PACKAGE_SIGNING_KEY_PASSWORD }}
40-
ORG_GRADLE_PROJECT_githubRepository: ${{ github.repository }}
4142
ORG_GRADLE_PROJECT_githubToken: ${{ secrets.RELEASE_GITHUB_TOKEN }}
4243
ORG_GRADLE_PROJECT_ossrhUsername: ${{ secrets.OSSRH_USERNAME }}
4344
ORG_GRADLE_PROJECT_ossrhPassword: ${{ secrets.OSSRH_PASSWORD }}
@@ -66,9 +67,7 @@ jobs:
6667
- name: Prepare
6768
run: ./gradlew clean dependencies
6869
- name: Generate Documentation
69-
run: ./gradlew dokkaHtml
70-
env:
71-
ORG_GRADLE_PROJECT_githubRepository: ${{ github.repository }}
70+
run: ./gradlew dokkaGenerate
7271
- name: Publish Documentation
7372
uses: peaceiris/[email protected]
7473
with:

build.gradle.kts

Lines changed: 110 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,51 @@
11
import io.github.gradlenexus.publishplugin.NexusRepository
22
import org.gradle.api.JavaVersion.VERSION_1_8
3-
import org.jetbrains.dokka.gradle.DokkaTask
4-
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
3+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
54

65
plugins {
7-
kotlin("jvm") version "1.9.25"
8-
id("com.palantir.git-version") version "3.2.0"
9-
id("org.jetbrains.dokka") version "1.9.20"
10-
`maven-publish`
11-
signing
12-
id("io.github.gradle-nexus.publish-plugin") version "1.3.0"
13-
idea
6+
kotlin("jvm") version "2.1.10"
7+
id("org.jetbrains.dokka-javadoc") version "2.0.0"
8+
id("org.jetbrains.dokka") version "2.0.0"
9+
`maven-publish`
10+
signing
11+
id("io.github.gradle-nexus.publish-plugin") version "1.3.0"
1412
}
1513

1614
group = "de.joshuagleitze"
17-
version = if (isSnapshot) versionDetails.gitHash else versionDetails.lastTag.drop("v")
18-
status = if (isSnapshot) "snapshot" else "release"
15+
version = if (version == "unspecified") "local" else version
16+
status = if (version == "local") "snapshot" else "release"
1917

2018
repositories {
21-
mavenCentral()
19+
mavenCentral()
2220
}
2321

2422
dependencies {
25-
testImplementation(name = "atrium-cc-en_GB-robstoll", group = "ch.tutteli.atrium", version = "0.15.0")
26-
testImplementation(name = "junit-jupiter-api", group = "org.junit.jupiter", version = "5.7.2")
27-
testImplementation(name = "junit-jupiter-params", group = "org.junit.jupiter", version = "5.7.2")
23+
testImplementation(name = "atrium-cc-en_GB-robstoll", group = "ch.tutteli.atrium", version = "0.15.0")
24+
testImplementation(name = "junit-jupiter-api", group = "org.junit.jupiter", version = "5.7.2")
25+
testImplementation(name = "junit-jupiter-params", group = "org.junit.jupiter", version = "5.7.2")
2826

29-
constraints {
30-
testImplementation(kotlin("reflect", KotlinVersion.CURRENT.toString()))
31-
}
27+
constraints {
28+
testImplementation(kotlin("reflect", KotlinVersion.CURRENT.toString()))
29+
}
3230

33-
testRuntimeOnly(name = "junit-jupiter-engine", group = "org.junit.jupiter", version = "5.7.2")
31+
testRuntimeOnly(name = "junit-platform-launcher", group = "org.junit.platform", version = "1.12.1")
32+
testRuntimeOnly(name = "junit-jupiter-engine", group = "org.junit.jupiter", version = "5.7.2")
3433
}
3534

36-
idea {
37-
module {
38-
isDownloadSources = true
39-
isDownloadJavadoc = true
40-
}
41-
}
42-
43-
tasks.withType<Test> {
44-
useJUnitPlatform()
45-
reports.junitXml.required.set(true)
35+
tasks.withType<Test>().configureEach {
36+
useJUnitPlatform()
37+
reports.junitXml.required = true
4638
}
4739

4840
java {
49-
sourceCompatibility = VERSION_1_8
50-
targetCompatibility = VERSION_1_8
41+
sourceCompatibility = VERSION_1_8
42+
targetCompatibility = VERSION_1_8
5143
}
5244

53-
tasks.withType<KotlinCompile> {
54-
kotlinOptions {
55-
jvmTarget = "1.8"
56-
}
45+
kotlin {
46+
compilerOptions {
47+
jvmTarget = JvmTarget.JVM_1_8
48+
}
5749
}
5850

5951
val ossrhUsername: String? by project
@@ -62,119 +54,116 @@ val githubRepository: String? by project
6254
val githubOwner = githubRepository?.split("/")?.get(0)
6355
val githubToken: String? by project
6456

65-
val sourcesJar by tasks.creating(Jar::class) {
66-
group = "build"
67-
description = "Assembles the source code into a jar"
68-
archiveClassifier.set("sources")
69-
from(sourceSets.main.get().allSource)
57+
val sourcesJar by tasks.registering(Jar::class) {
58+
group = "build"
59+
description = "Assembles the source code into a jar"
60+
archiveClassifier.set("sources")
61+
from(sourceSets.main.get().allSource)
7062
}
7163

72-
tasks.withType<DokkaTask> {
73-
dokkaSourceSets.named("main") {
74-
sourceLink {
75-
localDirectory.set(file("src/main/kotlin"))
76-
remoteUrl.set(uri("https://github.com/$githubRepository/blob/main/src/main/kotlin").toURL())
77-
remoteLineSuffix.set("#L")
78-
}
79-
}
64+
dokka {
65+
dokkaSourceSets.main {
66+
sourceLink {
67+
localDirectory = file("src/main/kotlin")
68+
remoteUrl = uri("https://github.com/$githubRepository/blob/main/src/main/kotlin")
69+
remoteLineSuffix = "#L"
70+
}
71+
}
8072
}
8173

82-
val dokkaJar by tasks.creating(Jar::class) {
83-
group = "build"
84-
description = "Assembles the Kotlin docs with Dokka"
85-
archiveClassifier.set("javadoc")
86-
from(tasks.named("dokkaJavadoc"))
74+
val dokkaJar by tasks.registering(Jar::class) {
75+
group = "build"
76+
description = "Assembles the Kotlin docs with Dokka"
77+
archiveClassifier.set("javadoc")
78+
from(tasks.named("dokkaGeneratePublicationJavadoc"))
8779
}
8880

8981
artifacts {
90-
archives(sourcesJar)
91-
archives(dokkaJar)
82+
archives(sourcesJar)
83+
archives(dokkaJar)
9284
}
9385

9486
lateinit var publication: MavenPublication
9587
lateinit var githubPackages: ArtifactRepository
9688
lateinit var mavenCentral: NexusRepository
9789

9890
publishing {
99-
publications {
100-
publication = create<MavenPublication>("maven") {
101-
from(components["java"])
102-
artifact(sourcesJar)
103-
artifact(dokkaJar)
104-
105-
pom {
106-
name.set(provider { "$groupId:$artifactId" })
107-
description.set("Convert between different string notations commonly found in programming")
108-
inceptionYear.set("2020")
109-
url.set("https://github.com/$githubRepository")
110-
ciManagement {
111-
system.set("GitHub Actions")
112-
url.set("https://github.com/$githubRepository/actions")
113-
}
114-
issueManagement {
115-
system.set("GitHub Issues")
116-
url.set("https://github.com/$githubRepository/issues")
117-
}
118-
developers {
119-
developer {
120-
name.set("Joshua Gleitze")
121-
email.set("[email protected]")
122-
}
123-
}
124-
scm {
125-
connection.set("scm:git:https://github.com/$githubRepository.git")
126-
developerConnection.set("scm:git:git://[email protected]:$githubRepository.git")
127-
url.set("https://github.com/$githubRepository")
128-
}
129-
licenses {
130-
license {
131-
name.set("MIT")
132-
url.set("https://opensource.org/licenses/MIT")
133-
distribution.set("repo")
134-
}
135-
}
136-
}
137-
}
138-
}
139-
repositories {
140-
githubPackages = maven("https://maven.pkg.github.com/$githubRepository") {
141-
name = "GitHubPackages"
142-
credentials {
143-
username = githubOwner
144-
password = githubToken
145-
}
146-
}
147-
}
91+
publications {
92+
publication = create<MavenPublication>("maven") {
93+
from(components["java"])
94+
artifact(sourcesJar)
95+
artifact(dokkaJar)
96+
97+
pom {
98+
name.set(provider { "$groupId:$artifactId" })
99+
description.set("Convert between different string notations commonly found in programming")
100+
inceptionYear.set("2020")
101+
url.set("https://github.com/$githubRepository")
102+
ciManagement {
103+
system.set("GitHub Actions")
104+
url.set("https://github.com/$githubRepository/actions")
105+
}
106+
issueManagement {
107+
system.set("GitHub Issues")
108+
url.set("https://github.com/$githubRepository/issues")
109+
}
110+
developers {
111+
developer {
112+
name.set("Joshua Gleitze")
113+
email.set("[email protected]")
114+
}
115+
}
116+
scm {
117+
connection.set("scm:git:https://github.com/$githubRepository.git")
118+
developerConnection.set("scm:git:git://[email protected]:$githubRepository.git")
119+
url.set("https://github.com/$githubRepository")
120+
}
121+
licenses {
122+
license {
123+
name.set("MIT")
124+
url.set("https://opensource.org/licenses/MIT")
125+
distribution.set("repo")
126+
}
127+
}
128+
}
129+
}
130+
}
131+
repositories {
132+
githubPackages = maven("https://maven.pkg.github.com/$githubRepository") {
133+
name = "GitHubPackages"
134+
credentials {
135+
username = githubOwner
136+
password = githubToken
137+
}
138+
}
139+
}
148140
}
149141

150142
nexusPublishing {
151-
repositories {
152-
mavenCentral = sonatype {
153-
username.set(ossrhUsername)
154-
password.set(ossrhPassword)
155-
}
156-
}
143+
repositories {
144+
mavenCentral = sonatype {
145+
username.set(ossrhUsername)
146+
password.set(ossrhPassword)
147+
}
148+
}
157149
}
158150

159151
signing {
160-
val signingKey: String? by project
161-
val signingKeyPassword: String? by project
162-
useInMemoryPgpKeys(signingKey, signingKeyPassword)
163-
sign(publication)
152+
val signingKey: String? by project
153+
val signingKeyPassword: String? by project
154+
useInMemoryPgpKeys(signingKey, signingKeyPassword)
155+
sign(publication)
164156
}
165157

166158
val closeAndReleaseStagingRepository by project.tasks
167159
closeAndReleaseStagingRepository.mustRunAfter(mavenCentral.publishTask)
168160

169-
task("release") {
170-
group = "release"
171-
description = "Releases the project to Maven Central"
172-
dependsOn(githubPackages.publishTask, mavenCentral.publishTask, closeAndReleaseStagingRepository)
161+
val release by tasks.registering {
162+
group = "release"
163+
description = "Releases the project to Maven Central"
164+
dependsOn(githubPackages.publishTask, mavenCentral.publishTask, closeAndReleaseStagingRepository)
173165
}
174166

175-
val Project.isSnapshot get() = versionDetails.commitDistance != 0
176167
fun String.drop(prefix: String) = if (this.startsWith(prefix)) this.drop(prefix.length) else this
177-
178-
val Project.versionDetails get() = (this.extra["versionDetails"] as groovy.lang.Closure<*>)() as com.palantir.gradle.gitversion.VersionDetails
179168
val ArtifactRepository.publishTask get() = tasks["publishAllPublicationsTo${this.name}Repository"]
180169
val NexusRepository.publishTask get() = "publishTo${this.name.replaceFirstChar { it.titlecase() }}"

gradle.properties

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
org.gradle.parallel=true
2+
org.gradle.configuration-cache=true
3+
org.gradle.configuration-cache.parallel=true
4+
5+
org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled
6+
org.jetbrains.dokka.experimental.gradle.pluginMode.noWarn=true

src/main/kotlin/BaseStringNotation.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@ abstract class BaseStringNotation(private val splitAt: Regex): StringNotation {
3535
.foldIndexed(StringBuffer()) { index, existing, part -> existing.append(printBeforePart(index, part)).append(part) }
3636
.toString()
3737

38-
override fun toString() = this::class.java.simpleName!!
38+
override fun toString(): String = this::class.java.simpleName
3939
}

0 commit comments

Comments
 (0)