1717// to build everything: "gradlew build"
1818// to build and upload everything: "gradlew release"
1919
20+ import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
2021import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
2122import io.github.gradlenexus.publishplugin.AbstractNexusStagingRepositoryTask
2223import org.apache.tools.ant.filters.ReplaceTokens
@@ -27,8 +28,9 @@ plugins {
2728 `java- library`
2829 `maven- publish`
2930
30- id(" io.github.gradle-nexus.publish-plugin" ) version " 2.0.0"
31- id(" com.github.johnrengelman.shadow" ) version " 8.1.1"
31+ alias(libs.plugins.publish)
32+ alias(libs.plugins.shadow)
33+ alias(libs.plugins.versions)
3234}
3335
3436
@@ -40,7 +42,7 @@ plugins {
4042
4143
4244val javaVersion = JavaVersion .current()
43- val versionObj = Version (major = " 5" , minor = " 3 " , revision = " 2 " , classifier = null )
45+ val versionObj = Version (major = " 5" , minor = " 4 " , revision = " 0 " , classifier = null )
4446val isGithubAction = System .getProperty(" GITHUB_ACTION" ) != null || System .getenv(" GITHUB_ACTION" ) != null
4547val isCI = System .getProperty(" BUILD_NUMBER" ) != null // jenkins
4648 || System .getenv(" BUILD_NUMBER" ) != null
@@ -157,7 +159,7 @@ dependencies {
157159 addAll(configurations[" compileOnly" ].allDependencies)
158160 }
159161
160- testImplementation(libs.junit)
162+ testImplementation(libs.bundles. junit)
161163 testImplementation(libs.reflections)
162164 testImplementation(libs.mockito)
163165 testImplementation(libs.assertj)
@@ -166,14 +168,28 @@ dependencies {
166168 testImplementation(libs.archunit)
167169}
168170
171+ fun isNonStable (version : String ): Boolean {
172+ val stableKeyword = listOf (" RELEASE" , " FINAL" , " GA" ).any { version.uppercase().contains(it) }
173+ val regex = " ^[0-9,.v-]+(-r)?$" .toRegex()
174+ val isStable = stableKeyword || regex.matches(version)
175+ return isStable.not ()
176+ }
177+
178+ tasks.withType<DependencyUpdatesTask > {
179+ rejectVersionIf {
180+ isNonStable(candidate.version)
181+ }
182+
183+ gradleReleaseChannel = " current"
184+ }
185+
169186
170187// //////////////////////////////////
171188// //
172189// Build Task Configuration //
173190// //
174191// //////////////////////////////////
175192
176-
177193val jar by tasks.getting(Jar ::class ) {
178194 archiveBaseName.set(project.name)
179195 manifest.attributes(
@@ -186,7 +202,7 @@ val shadowJar by tasks.getting(ShadowJar::class) {
186202 exclude(" *.pom" )
187203}
188204
189- val sourcesForRelease by tasks.creating (Copy ::class ) {
205+ val sourcesForRelease by tasks.registering (Copy ::class ) {
190206 from(" src/main/java" ) {
191207 include(" **/JDAInfo.java" )
192208 val tokens = mapOf (
@@ -207,16 +223,16 @@ val sourcesForRelease by tasks.creating(Copy::class) {
207223 includeEmptyDirs = false
208224}
209225
210- val generateJavaSources by tasks.creating (SourceTask ::class ) {
226+ val generateJavaSources by tasks.registering (SourceTask ::class ) {
211227 val javaSources = sourceSets[" main" ].allJava.filter {
212228 it.name != " JDAInfo.java"
213229 }.asFileTree
214230
215- source = javaSources + fileTree(sourcesForRelease.destinationDir)
231+ source = javaSources + fileTree(sourcesForRelease.get(). destinationDir)
216232 dependsOn(sourcesForRelease)
217233}
218234
219- val noOpusJar by tasks.creating (ShadowJar ::class ) {
235+ val noOpusJar by tasks.registering (ShadowJar ::class ) {
220236 dependsOn(shadowJar)
221237 archiveClassifier.set(shadowJar.archiveClassifier.get() + " -no-opus" )
222238
@@ -230,7 +246,7 @@ val noOpusJar by tasks.creating(ShadowJar::class) {
230246 manifest.inheritFrom(jar.manifest)
231247}
232248
233- val minimalJar by tasks.creating (ShadowJar ::class ) {
249+ val minimalJar by tasks.registering (ShadowJar ::class ) {
234250 dependsOn(shadowJar)
235251 minimize()
236252 archiveClassifier.set(shadowJar.archiveClassifier.get() + " -min" )
@@ -248,12 +264,12 @@ val minimalJar by tasks.creating(ShadowJar::class) {
248264 manifest.inheritFrom(jar.manifest)
249265}
250266
251- val sourcesJar by tasks.creating (Jar ::class ) {
267+ val sourcesJar by tasks.registering (Jar ::class ) {
252268 archiveClassifier.set(" sources" )
253269 from(" src/main/java" ) {
254270 exclude(" **/JDAInfo.java" )
255271 }
256- from(sourcesForRelease.destinationDir)
272+ from(sourcesForRelease.get(). destinationDir)
257273
258274 dependsOn(sourcesForRelease)
259275}
@@ -290,7 +306,7 @@ val javadoc by tasks.getting(Javadoc::class) {
290306 }
291307
292308 dependsOn(sourcesJar)
293- source = sourcesJar.source.asFileTree
309+ source = sourcesJar.get(). source.asFileTree
294310 exclude(" MANIFEST.MF" )
295311
296312 // ### excludes ###
@@ -302,7 +318,7 @@ val javadoc by tasks.getting(Javadoc::class) {
302318 exclude(" com/iwebpp/crypto" )
303319}
304320
305- val javadocJar by tasks.creating (Jar ::class ) {
321+ val javadocJar by tasks.registering (Jar ::class ) {
306322 dependsOn(javadoc)
307323 archiveClassifier.set(" javadoc" )
308324 from(javadoc.destinationDir)
@@ -326,7 +342,7 @@ tasks.withType<JavaCompile> {
326342
327343val compileJava by tasks.getting(JavaCompile ::class ) {
328344 dependsOn(generateJavaSources)
329- source = generateJavaSources.source
345+ source = generateJavaSources.get(). source
330346}
331347
332348val build by tasks.getting(Task ::class ) {
@@ -439,7 +455,7 @@ nexusPublishing {
439455// //////////////////////////////////
440456
441457
442- val rebuild by tasks.creating (Task ::class ) {
458+ val rebuild by tasks.registering (Task ::class ) {
443459 group = " build"
444460
445461 dependsOn(build)
@@ -457,7 +473,7 @@ tasks.withType<AbstractNexusStagingRepositoryTask> {
457473 enabled = shouldPublish
458474}
459475
460- val release by tasks.creating (Task ::class ) {
476+ val release by tasks.registering (Task ::class ) {
461477 group = " publishing"
462478 enabled = shouldPublish
463479
@@ -467,7 +483,7 @@ val release by tasks.creating(Task::class) {
467483afterEvaluate {
468484 val closeAndReleaseStagingRepositories by tasks.getting
469485 closeAndReleaseStagingRepositories.apply {
470- release.dependsOn(this )
486+ release.get(). dependsOn(this )
471487 mustRunAfter(publishingTasks)
472488 }
473489}
0 commit comments