1
1
import io.github.gradlenexus.publishplugin.NexusRepository
2
2
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
5
4
6
5
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 "
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 "
10
9
`maven- publish`
11
10
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"
14
12
}
15
13
16
14
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.toString() .drop(" v" )
16
+ status = if (version == " local " ) " snapshot" else " release"
19
17
20
18
repositories {
21
19
mavenCentral()
@@ -30,29 +28,23 @@ dependencies {
30
28
testImplementation(kotlin(" reflect" , KotlinVersion .CURRENT .toString()))
31
29
}
32
30
31
+ testRuntimeOnly(name = " junit-platform-launcher" , group = " org.junit.platform" , version = " 1.12.1" )
33
32
testRuntimeOnly(name = " junit-jupiter-engine" , group = " org.junit.jupiter" , version = " 5.7.2" )
34
33
}
35
34
36
- idea {
37
- module {
38
- isDownloadSources = true
39
- isDownloadJavadoc = true
40
- }
41
- }
42
-
43
- tasks.withType<Test > {
35
+ tasks.withType<Test >().configureEach {
44
36
useJUnitPlatform()
45
- reports.junitXml.required.set( true )
37
+ reports.junitXml.required = true
46
38
}
47
39
48
40
java {
49
41
sourceCompatibility = VERSION_1_8
50
42
targetCompatibility = VERSION_1_8
51
43
}
52
44
53
- tasks.withType< KotlinCompile > {
54
- kotlinOptions {
55
- jvmTarget = " 1.8 "
45
+ kotlin {
46
+ compilerOptions {
47
+ jvmTarget = JvmTarget . JVM_1_8
56
48
}
57
49
}
58
50
@@ -62,28 +54,28 @@ val githubRepository: String? by project
62
54
val githubOwner = githubRepository?.split(" /" )?.get(0 )
63
55
val githubToken: String? by project
64
56
65
- val sourcesJar by tasks.creating (Jar ::class ) {
57
+ val sourcesJar by tasks.registering (Jar ::class ) {
66
58
group = " build"
67
59
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 } )
70
62
}
71
63
72
- tasks.withType< DokkaTask > {
73
- dokkaSourceSets.named( " main" ) {
64
+ dokka {
65
+ dokkaSourceSets.main {
74
66
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"
78
70
}
79
71
}
80
72
}
81
73
82
- val dokkaJar by tasks.creating (Jar ::class ) {
74
+ val dokkaJar by tasks.registering (Jar ::class ) {
83
75
group = " build"
84
76
description = " Assembles the Kotlin docs with Dokka"
85
77
archiveClassifier.set(" javadoc" )
86
- from(tasks.named(" dokkaJavadoc " ))
78
+ from(tasks.named(" dokkaGeneratePublicationJavadoc " ))
87
79
}
88
80
89
81
artifacts {
@@ -103,34 +95,34 @@ publishing {
103
95
artifact(dokkaJar)
104
96
105
97
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 "
110
102
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"
113
105
}
114
106
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"
117
109
}
118
110
developers {
119
111
developer {
120
- name.set( " Joshua Gleitze" )
121
-
112
+ name = " Joshua Gleitze"
113
+
122
114
}
123
115
}
124
116
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 " )
117
+ connection = " scm:git:https://github.com/$githubRepository .git"
118
+ developerConnection
= " scm:git:git://[email protected] :$githubRepository .git"
119
+ url = " https://github.com/$githubRepository "
128
120
}
129
121
licenses {
130
122
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"
134
126
}
135
127
}
136
128
}
@@ -150,8 +142,8 @@ publishing {
150
142
nexusPublishing {
151
143
repositories {
152
144
mavenCentral = sonatype {
153
- username.set( ossrhUsername)
154
- password.set( ossrhPassword)
145
+ username = ossrhUsername
146
+ password = ossrhPassword
155
147
}
156
148
}
157
149
}
@@ -163,18 +155,15 @@ signing {
163
155
sign(publication)
164
156
}
165
157
166
- val closeAndReleaseStagingRepository by project.tasks
167
- closeAndReleaseStagingRepository .mustRunAfter(mavenCentral.publishTask)
158
+ val closeAndReleaseStagingRepositories by project.tasks
159
+ closeAndReleaseStagingRepositories .mustRunAfter(mavenCentral.publishTask)
168
160
169
- task( " release" ) {
161
+ val release by tasks.registering {
170
162
group = " release"
171
163
description = " Releases the project to Maven Central"
172
- dependsOn(githubPackages.publishTask, mavenCentral.publishTask, closeAndReleaseStagingRepository )
164
+ dependsOn(githubPackages.publishTask, mavenCentral.publishTask, closeAndReleaseStagingRepositories )
173
165
}
174
166
175
- val Project .isSnapshot get() = versionDetails.commitDistance != 0
176
167
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
179
168
val ArtifactRepository .publishTask get() = tasks[" publishAllPublicationsTo${this .name} Repository" ]
180
169
val NexusRepository .publishTask get() = " publishTo${this .name.replaceFirstChar { it.titlecase() }} "
0 commit comments