Skip to content

Commit 8efc87d

Browse files
committed
2 parents 350027d + 2b972ab commit 8efc87d

33 files changed

+1163
-80
lines changed

README.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,13 @@ repositories {
6969
7070
dependencies {
7171
implementation("net.dv8tion:JDA:$version") { // replace $version with the latest version
72-
// Optionally disable audio natives to reduce jar size by excluding `opus-java`
72+
// Optionally disable audio natives to reduce jar size by excluding `opus-java` and `tink`
7373
// Gradle DSL:
74-
// exclude module: 'opus-java'
74+
// exclude module: 'opus-java' // required for encoding audio into opus, not needed if audio is already provided in opus encoding
75+
// exclude module: 'tink' // required for encrypting and decrypting audio
7576
// Kotlin DSL:
76-
// exclude(module="opus-java")
77+
// exclude(module="opus-java") // required for encoding audio into opus, not needed if audio is already provided in opus encoding
78+
// exclude(module="tink") // required for encrypting and decrypting audio
7779
}
7880
}
7981
```
@@ -85,14 +87,19 @@ dependencies {
8587
<groupId>net.dv8tion</groupId>
8688
<artifactId>JDA</artifactId>
8789
<version>$version</version> <!-- replace $version with the latest version -->
88-
<!-- Optionally disable audio natives to reduce jar size by excluding `opus-java`
90+
<!-- Optionally disable audio natives to reduce jar size by excluding `opus-java` and `tink` -->
8991
<exclusions>
92+
<!-- required for encoding audio into opus, not needed if audio is already provided in opus encoding
9093
<exclusion>
9194
<groupId>club.minnced</groupId>
9295
<artifactId>opus-java</artifactId>
93-
</exclusion>
96+
</exclusion> -->
97+
<!-- required for encrypting and decrypting audio
98+
<exclusion>
99+
<groupId>com.google.crypto.tink</groupId>
100+
<artifactId>tink</artifactId>
101+
</exclusion> -->
94102
</exclusions>
95-
-->
96103
</dependency>
97104
```
98105

build.gradle.kts

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
//to build everything: "gradlew build"
1818
//to build and upload everything: "gradlew release"
1919

20+
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
2021
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
2122
import io.github.gradlenexus.publishplugin.AbstractNexusStagingRepositoryTask
2223
import 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

4244
val 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)
4446
val isGithubAction = System.getProperty("GITHUB_ACTION") != null || System.getenv("GITHUB_ACTION") != null
4547
val 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-
177193
val 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

327343
val compileJava by tasks.getting(JavaCompile::class) {
328344
dependsOn(generateJavaSources)
329-
source = generateJavaSources.source
345+
source = generateJavaSources.get().source
330346
}
331347

332348
val 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) {
467483
afterEvaluate {
468484
val closeAndReleaseStagingRepositories by tasks.getting
469485
closeAndReleaseStagingRepositories.apply {
470-
release.dependsOn(this)
486+
release.get().dependsOn(this)
471487
mustRunAfter(publishingTasks)
472488
}
473489
}

gradle/libs.versions.toml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
[versions]
2+
jackson = "2.18.3"
3+
4+
5+
[libraries]
6+
jackson-core = { module = "com.fasterxml.jackson.core:jackson-core", version.ref = "jackson" }
7+
jackson-databind = { module = "com.fasterxml.jackson.core:jackson-databind", version.ref = "jackson" }
8+
websocket-client = { module = "com.neovisionaries:nv-websocket-client", version = "2.14" }
9+
okhttp = { module = "com.squareup.okhttp3:okhttp", version = "4.12.0" }
10+
trove4j = { module = "net.sf.trove4j:core", version = "3.1.0" }
11+
commons-collections = { module = "org.apache.commons:commons-collections4", version = "4.4" }
12+
commons-lang3 = { module = "org.apache.commons:commons-lang3", version = "3.17.0" }
13+
slf4j = { module = "org.slf4j:slf4j-api", version = "2.0.17" }
14+
findbugs = { module = "com.google.code.findbugs:jsr305", version = "3.0.2" }
15+
jetbrains-annotations = { module = "org.jetbrains:annotations", version = "26.0.2" }
16+
opus = { module = "club.minnced:opus-java", version = "1.1.1" }
17+
jna = { module = "net.java.dev.jna:jna", version = "5.17.0" }
18+
tink = { module = "com.google.crypto.tink:tink", version = "1.17.0" }
19+
20+
# Test dependencies
21+
22+
junit = { module = "org.junit.jupiter:junit-jupiter", version = "5.12.2" }
23+
junit-launcher = { module = "org.junit.platform:junit-platform-launcher", version = "1.12.2" }
24+
reflections = { module = "org.reflections:reflections", version = "0.10.2" }
25+
logback-classic = { module = "ch.qos.logback:logback-classic", version = "1.5.18" }
26+
assertj = { module = "org.assertj:assertj-core", version = "3.27.3" }
27+
archunit = { module = "com.tngtech.archunit:archunit", version = "1.4.0" }
28+
mockito = { module = "org.mockito:mockito-core", version = "5.17.0" }
29+
30+
31+
[bundles]
32+
jackson = ["jackson-core", "jackson-databind"]
33+
junit = ["junit", "junit-launcher"]
34+
35+
36+
[plugins]
37+
publish = { id = "io.github.gradle-nexus.publish-plugin", version = "2.0.0" }
38+
shadow = { id = "com.github.johnrengelman.shadow", version = "8.1.1" }
39+
versions = { id = "com.github.ben-manes.versions", version = "0.52.0" }
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
4-
networkTimeout=10000
5-
validateDistributionUrl=true
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
64
zipStoreBase=GRADLE_USER_HOME
75
zipStorePath=wrapper/dists

settings.gradle.kts

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,2 @@
11
rootProject.name = "JDA"
22

3-
dependencyResolutionManagement {
4-
versionCatalogs {
5-
create("libs") {
6-
version("jackson", "2.17.2")
7-
library("jackson-core", "com.fasterxml.jackson.core", "jackson-core").versionRef("jackson")
8-
library("jackson-databind", "com.fasterxml.jackson.core", "jackson-databind").versionRef("jackson")
9-
bundle("jackson", listOf("jackson-core", "jackson-databind"))
10-
11-
library("logback-classic", "ch.qos.logback", "logback-classic" ).version("1.5.6")
12-
library("opus", "club.minnced", "opus-java" ).version("1.1.1")
13-
library("findbugs", "com.google.code.findbugs", "jsr305" ).version("3.0.2")
14-
library("websocket-client", "com.neovisionaries", "nv-websocket-client" ).version("2.14")
15-
library("okhttp", "com.squareup.okhttp3", "okhttp" ).version("4.12.0")
16-
library("jna", "net.java.dev.jna", "jna" ).version("5.14.0")
17-
library("trove4j", "net.sf.trove4j", "core" ).version("3.1.0")
18-
library("commons-collections", "org.apache.commons", "commons-collections4").version("4.4")
19-
library("commons-lang3", "org.apache.commons", "commons-lang3" ).version("3.14.0")
20-
library("assertj", "org.assertj", "assertj-core" ).version("3.25.3")
21-
library("jetbrains-annotations", "org.jetbrains", "annotations" ).version("24.1.0")
22-
library("junit", "org.junit.jupiter", "junit-jupiter" ).version("5.10.2")
23-
library("mockito", "org.mockito", "mockito-core" ).version("5.11.0")
24-
library("reflections", "org.reflections", "reflections" ).version("0.10.2")
25-
library("slf4j", "org.slf4j", "slf4j-api" ).version("2.0.13")
26-
library("tink", "com.google.crypto.tink", "tink" ).version("1.14.1")
27-
library("archunit", "com.tngtech.archunit", "archunit" ).version("1.3.0")
28-
}
29-
}
30-
}

0 commit comments

Comments
 (0)