-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle.kts
102 lines (87 loc) · 3.18 KB
/
build.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
plugins {
`java-library`
`maven-publish`
idea
id("com.github.ben-manes.versions") version "0.50.0"
id("org.ajoberstar.grgit") version "5.2.1"
}
group = "space.npstr.prometheus_extensions"
version = versionTag()
println("Version: ${project.version}")
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
vendor.set(JvmVendorSpec.ADOPTIUM)
}
withSourcesJar()
consistentResolution {
useCompileClasspathVersions()
}
}
repositories {
mavenCentral()
maven {
url = uri("https://m2.dv8tion.net/releases")
content { includeModule("net.dv8tion", "JDA") }
content { includeGroup("club.minnced") }
}
// maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots") } // D4J snapshots
// maven { url = uri("https://repo.spring.io/milestone") } // D4J snapshots
}
val prometheusVersion = "0.16.0"
val dsProxyVersion = "1.9"
val jdaVersion = "5.0.0-beta.18"
val troveVersion = "3.0.3"
val fastutilVersion = "8.5.12"
// see https://oss.sonatype.org/content/repositories/snapshots/com/discord4j/discord4j-core/
val d4jCoreVersion = "3.2.6"
val jUnitPlatformVersion = "1.10.1"
val jUnitVersion = "5.10.1"
val mockitoVersion = "5.8.0"
val assertJVersion = "3.24.2"
dependencies {
api("io.prometheus:simpleclient:$prometheusVersion")
compileOnly("net.ttddyy:datasource-proxy:$dsProxyVersion")
compileOnly("net.dv8tion:JDA:$jdaVersion")
// required for user count hax
compileOnly("net.sf.trove4j:trove4j:$troveVersion")
compileOnly("it.unimi.dsi:fastutil:$fastutilVersion")
compileOnly("com.discord4j:discord4j-core:$d4jCoreVersion")
testRuntimeOnly("org.junit.platform:junit-platform-launcher:$jUnitPlatformVersion")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:$jUnitVersion")
testImplementation("org.junit.jupiter:junit-jupiter-api:$jUnitVersion")
testImplementation("net.dv8tion:JDA:$jdaVersion")
testImplementation("org.mockito:mockito-core:$mockitoVersion")
testImplementation("org.assertj:assertj-core:$assertJVersion")
}
tasks.named<Test>("test") {
useJUnitPlatform()
testLogging {
exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
}
}
fun isNonStable(version: String): Boolean {
val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { version.uppercase().contains(it) }
val regex = "^[0-9,.v\\-_]+(-r)?$".toRegex()
val isStable = stableKeyword || regex.matches(version)
val isUnstable = listOf("ALPHA", "BETA").any { version.uppercase().contains(it) }
return isUnstable || isStable.not()
}
// https://github.com/ben-manes/gradle-versions-plugin
tasks.withType<com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask> {
rejectVersionIf {
isNonStable(candidate.version) && !isNonStable(currentVersion)
}
}
publishing {
publications {
create<MavenPublication>("prometheusExtensions") {
from(components["java"])
}
}
}
fun versionTag(): String {
val regex = Regex("^([0-9]+.[0-9]+.[0-9]+).*$")
val match = regex.find(grgit.describe(mapOf("tags" to true)))
return match?.value ?: "Unknown"
}