11import io.github.gradlenexus.publishplugin.NexusRepository
22import 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
65plugins {
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
1614group = " 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
2018repositories {
21- mavenCentral()
19+ mavenCentral()
2220}
2321
2422dependencies {
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
4840java {
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
5951val ossrhUsername: String? by project
@@ -62,119 +54,116 @@ val githubRepository: String? by project
6254val githubOwner = githubRepository?.split(" /" )?.get(0 )
6355val 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
8981artifacts {
90- archives(sourcesJar)
91- archives(dokkaJar)
82+ archives(sourcesJar)
83+ archives(dokkaJar)
9284}
9385
9486lateinit var publication: MavenPublication
9587lateinit var githubPackages: ArtifactRepository
9688lateinit var mavenCentral: NexusRepository
9789
9890publishing {
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- 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+ 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
150142nexusPublishing {
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
159151signing {
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
166158val closeAndReleaseStagingRepository by project.tasks
167159closeAndReleaseStagingRepository.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
176167fun 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
179168val ArtifactRepository .publishTask get() = tasks[" publishAllPublicationsTo${this .name} Repository" ]
180169val NexusRepository .publishTask get() = " publishTo${this .name.replaceFirstChar { it.titlecase() }} "
0 commit comments