-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle.kts
91 lines (77 loc) · 2.92 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
import java.io.ByteArrayOutputStream
plugins {
alias(libs.plugins.kotlin.jvm) apply false
alias(libs.plugins.kotlin.serialization) apply false
}
val (gitVersion, release) = versionFromGit()
logger.lifecycle("Version: $gitVersion (release: $release)")
allprojects {
group = "com.github.topi314.lavaqueue"
version = gitVersion
repositories {
mavenLocal()
mavenCentral()
maven("https://maven.arbjerg.dev/releases")
maven("https://maven.arbjerg.dev/snapshots")
maven("https://jitpack.io")
jcenter()
}
}
val isMavenDefined = findProperty("MAVEN_USERNAME") != null && findProperty("MAVEN_PASSWORD") != null
val isLavalinkMavenDefined = findProperty("LAVALINK_MAVEN_USERNAME") != null && findProperty("LAVALINK_MAVEN_PASSWORD") != null
subprojects {
apply<MavenPublishPlugin>()
configure<PublishingExtension> {
if (isMavenDefined) {
repositories {
val snapshots = "https://maven.topi.wtf/snapshots"
val releases = "https://maven.topi.wtf/releases"
maven(if (release) releases else snapshots) {
credentials {
username = findProperty("MAVEN_USERNAME") as String?
password = findProperty("MAVEN_PASSWORD") as String?
}
}
}
} else {
logger.lifecycle("Not publishing to maven.topi.wtf because credentials are not set")
}
if (name == "main") {
if (isLavalinkMavenDefined) {
repositories {
val snapshots = "https://maven.lavalink.dev/snapshots"
val releases = "https://maven.lavalink.dev/releases"
maven(if (release) releases else snapshots) {
credentials {
username = findProperty("LAVALINK_MAVEN_USERNAME") as String?
password = findProperty("LAVALINK_MAVEN_PASSWORD") as String?
}
}
}
} else {
logger.lifecycle("Not publishing to maven.lavalink.dev because credentials are not set")
}
}
}
}
fun versionFromGit(): Pair<String, Boolean> {
var versionStr = ByteArrayOutputStream()
var result = exec {
standardOutput = versionStr
isIgnoreExitValue = true
commandLine = listOf("git", "describe", "--exact-match", "--tags")
}
if (result.exitValue == 0) {
return Pair(versionStr.toString().trim(), true)
}
versionStr = ByteArrayOutputStream()
result = exec {
standardOutput = versionStr
isIgnoreExitValue = true
commandLine = listOf("git", "rev-parse", "--short", "HEAD")
}
if (result.exitValue != 0) {
throw GradleException("Failed to get git version")
}
return Pair(versionStr.toString().trim(), false)
}