-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.gradle.kts
123 lines (102 loc) · 4.42 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
import java.time.Duration
plugins {
`java-library`
`maven-publish`
signing
id("io.github.gradle-nexus.publish-plugin") version "1.1.0"
}
val ossrhUser: String? by project
val ossrhPassword: String? by project
val stagingProfile: String? by project
val enablePublishing = ossrhUser != null && ossrhPassword != null && stagingProfile != null
if (enablePublishing) {
apply(plugin = "io.github.gradle-nexus.publish-plugin")
nexusPublishing {
repositories.sonatype {
username.set(ossrhUser)
password.set(ossrhPassword)
stagingProfileId.set(stagingProfile)
}
// Sonatype is very slow :)
connectTimeout.set(Duration.ofMinutes(1))
clientTimeout.set(Duration.ofMinutes(10))
transitionCheckOptions {
maxRetries.set(100)
delayBetween.set(Duration.ofSeconds(5))
}
}
}
subprojects {
repositories {
mavenCentral()
}
apply(plugin="java")
configure<JavaPluginExtension> {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
group = "club.minnced"
version = "0.2.9"
// See https://github.com/sedmelluq/lavaplayer/blob/master/common/src/main/java/com/sedmelluq/lava/common/natives/architecture/DefaultArchitectureTypes.java
// identifier is the suffix used after the system name
fun getPlatform(triplet: String) = when {
triplet.startsWith("x86_64") && "linux" in triplet && "musl" in triplet -> "linux-musl-x86-64"
triplet.startsWith("i686") && "linux" in triplet && "musl" in triplet -> "linux-musl-x86"
triplet.startsWith("aarch64") && "linux" in triplet && "musl" in triplet -> "linux-musl-aarch64"
triplet.startsWith("arm") && "linux" in triplet && "musl" in triplet -> "linux-musl-arm"
triplet.startsWith("x86_64") && "linux" in triplet -> "linux-x86-64"
triplet.startsWith("i686") && "linux" in triplet -> "linux-x86"
triplet.startsWith("aarch64") && "linux" in triplet -> "linux-aarch64"
triplet.startsWith("arm") && "linux" in triplet -> "linux-arm"
triplet.startsWith("x86_64") && "windows" in triplet -> "win-x86-64"
triplet.startsWith("i686") && "windows" in triplet -> "win-x86"
triplet.startsWith("aarch64") && "windows" in triplet -> "win-aarch64"
triplet.startsWith("arm") && "windows" in triplet -> "win-arm"
"darwin" in triplet -> "darwin"
else -> throw IllegalArgumentException("Unknown platform: $triplet")
}
// Testing: "x86_64-unknown-linux-gnu"
ext["target"] = findProperty("target") as? String ?: throw AssertionError("Invalid target")
ext["platform"] = getPlatform(ext["target"].toString())
val generatePom: MavenPom.() -> Unit = {
packaging = "jar"
description.set("Rust implementation of the JDA-NAS interface")
url.set("https://github.com/MinnDevelopment/udpqueue.rs")
scm {
url.set("https://github.com/MinnDevelopment/udpqueue.rs")
connection.set("scm:git:git://github.com/MinnDevelopment/udpqueue.rs")
developerConnection.set("scm:git:ssh:[email protected]:MinnDevelopment/udpqueue.rs")
}
licenses {
license {
name.set("The Apache Software License, Version 2.0")
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
distribution.set("repo")
}
}
developers {
developer {
id.set("Minn")
name.set("Florian Spieß")
email.set("[email protected]")
}
}
}
ext["generatePom"] = generatePom
val rebuild = tasks.create("rebuild") {
group = "build"
afterEvaluate {
dependsOn(tasks["build"], tasks["clean"])
tasks["build"].dependsOn(tasks.withType<Jar>())
tasks.forEach {
if (it.name != "clean")
mustRunAfter(tasks["clean"])
}
}
}
tasks.withType<PublishToMavenRepository> {
enabled = enablePublishing
mustRunAfter(rebuild)
dependsOn(rebuild)
}
}