-
Notifications
You must be signed in to change notification settings - Fork 30
/
build.gradle.kts
72 lines (60 loc) · 2.22 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
import org.ajoberstar.grgit.Grgit
plugins {
java
id("org.ajoberstar.grgit") version "5.2.0"
alias(libs.plugins.maven.publish.base) apply false
}
val (gitVersion, release) = versionFromGit()
logger.lifecycle("Version: $gitVersion (release: $release)")
allprojects {
group = "dev.lavalink.youtube"
// The plugin project is the only one that should not have a snapshot version since lavalink expects the jar name to be specific
version = if (project.name == "plugin") {
gitVersion.removeSuffix("-SNAPSHOT")
} else {
gitVersion
}
repositories {
mavenLocal()
mavenCentral()
maven(url = "https://maven.lavalink.dev/releases")
maven(url = "https://jitpack.io")
}
}
subprojects {
apply<JavaPlugin>()
apply<MavenPublishPlugin>()
configure<JavaPluginExtension> {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
configure<PublishingExtension> {
if (findProperty("MAVEN_PASSWORD") != null && findProperty("MAVEN_USERNAME") != null) {
repositories {
val snapshots = "https://maven.lavalink.dev/snapshots"
val releases = "https://maven.lavalink.dev/releases"
maven(if (release) releases else snapshots) {
credentials {
password = findProperty("MAVEN_PASSWORD") as String?
username = findProperty("MAVEN_USERNAME") as String?
}
}
}
} else {
logger.lifecycle("Not publishing to maven.lavalink.dev because credentials are not set")
}
}
}
@SuppressWarnings("GrMethodMayBeStatic")
fun versionFromGit(): Pair<String, Boolean> {
Grgit.open(mapOf("currentDir" to project.rootDir)).use { git ->
val headTag = git.tag
.list()
.find { it.commit.id == git.head().id }
val clean = git.status().isClean || System.getenv("CI") != null
if (!clean) {
logger.lifecycle("Git state is dirty, version is a snapshot.")
}
return if (headTag != null && clean) headTag.name to true else "${git.head().id}-SNAPSHOT" to false
}
}