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 "
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 "
109 `maven- publish`
1110 signing
12- id(" io.github.gradle-nexus.publish-plugin" ) version " 1.3.0"
13- idea
11+ id(" io.github.gradle-nexus.publish-plugin" ) version " 2.0.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.toString() .drop(" v" )
16+ status = if (version == " local " ) " snapshot" else " release"
1917
2018repositories {
2119 mavenCentral()
@@ -30,29 +28,23 @@ dependencies {
3028 testImplementation(kotlin(" reflect" , KotlinVersion .CURRENT .toString()))
3129 }
3230
31+ testRuntimeOnly(name = " junit-platform-launcher" , group = " org.junit.platform" , version = " 1.12.1" )
3332 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 > {
35+ tasks.withType<Test >().configureEach {
4436 useJUnitPlatform()
45- reports.junitXml.required.set( true )
37+ reports.junitXml.required = true
4638}
4739
4840java {
4941 sourceCompatibility = VERSION_1_8
5042 targetCompatibility = VERSION_1_8
5143}
5244
53- tasks.withType< KotlinCompile > {
54- kotlinOptions {
55- jvmTarget = " 1.8 "
45+ kotlin {
46+ compilerOptions {
47+ jvmTarget = JvmTarget . JVM_1_8
5648 }
5749}
5850
@@ -62,28 +54,28 @@ 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 ) {
57+ val sourcesJar by tasks.registering (Jar ::class ) {
6658 group = " build"
6759 description = " Assembles the source code into a jar"
68- archiveClassifier.set( " sources" )
69- from(sourceSets.main.get() .allSource)
60+ archiveClassifier = " sources"
61+ from(sourceSets.main.map { it .allSource } )
7062}
7163
72- tasks.withType< DokkaTask > {
73- dokkaSourceSets.named( " main" ) {
64+ dokka {
65+ dokkaSourceSets.main {
7466 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" )
67+ localDirectory = file(" src/main/kotlin" )
68+ remoteUrl = uri(" https://github.com/$githubRepository /blob/main/src/main/kotlin" )
69+ remoteLineSuffix = " #L"
7870 }
7971 }
8072}
8173
82- val dokkaJar by tasks.creating (Jar ::class ) {
74+ val dokkaJar by tasks.registering (Jar ::class ) {
8375 group = " build"
8476 description = " Assembles the Kotlin docs with Dokka"
8577 archiveClassifier.set(" javadoc" )
86- from(tasks.named(" dokkaJavadoc " ))
78+ from(tasks.named(" dokkaGeneratePublicationJavadoc " ))
8779}
8880
8981artifacts {
@@ -103,34 +95,34 @@ publishing {
10395 artifact(dokkaJar)
10496
10597 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 " )
98+ name = " $groupId :$artifactId "
99+ description = " Convert between different string notations commonly found in programming"
100+ inceptionYear = " 2020"
101+ url = " https://github.com/$githubRepository "
110102 ciManagement {
111- system.set( " GitHub Actions" )
112- url.set( " https://github.com/$githubRepository /actions" )
103+ system = " GitHub Actions"
104+ url = " https://github.com/$githubRepository /actions"
113105 }
114106 issueManagement {
115- system.set( " GitHub Issues" )
116- url.set( " https://github.com/$githubRepository /issues" )
107+ system = " GitHub Issues"
108+ url = " https://github.com/$githubRepository /issues"
117109 }
118110 developers {
119111 developer {
120- name.set( " Joshua Gleitze" )
121- email.set( " dev@joshuagleitze.de" )
112+ name = " Joshua Gleitze"
113+ email = " dev@joshuagleitze.de"
122114 }
123115 }
124116 scm {
125- connection.set( " scm:git:https://github.com/$githubRepository .git" )
126- developerConnection.set( " scm:git:git://git@github.com:$githubRepository .git" )
127- url.set( " https://github.com/$githubRepository " )
117+ connection = " scm:git:https://github.com/$githubRepository .git"
118+ developerConnection = " scm:git:git://git@github.com:$githubRepository .git"
119+ url = " https://github.com/$githubRepository "
128120 }
129121 licenses {
130122 license {
131- name.set( " MIT" )
132- url.set( " https://opensource.org/licenses/MIT" )
133- distribution.set( " repo" )
123+ name = " MIT"
124+ url = " https://opensource.org/licenses/MIT"
125+ distribution = " repo"
134126 }
135127 }
136128 }
@@ -150,8 +142,8 @@ publishing {
150142nexusPublishing {
151143 repositories {
152144 mavenCentral = sonatype {
153- username.set( ossrhUsername)
154- password.set( ossrhPassword)
145+ username = ossrhUsername
146+ password = ossrhPassword
155147 }
156148 }
157149}
@@ -163,18 +155,15 @@ signing {
163155 sign(publication)
164156}
165157
166- val closeAndReleaseStagingRepository by project.tasks
167- closeAndReleaseStagingRepository .mustRunAfter(mavenCentral.publishTask)
158+ val closeAndReleaseStagingRepositories by project.tasks
159+ closeAndReleaseStagingRepositories .mustRunAfter(mavenCentral.publishTask)
168160
169- task( " release" ) {
161+ val release by tasks.registering {
170162 group = " release"
171163 description = " Releases the project to Maven Central"
172- dependsOn(githubPackages.publishTask, mavenCentral.publishTask, closeAndReleaseStagingRepository )
164+ dependsOn(githubPackages.publishTask, mavenCentral.publishTask, closeAndReleaseStagingRepositories )
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