-
Notifications
You must be signed in to change notification settings - Fork 51
/
build.gradle.kts
117 lines (98 loc) · 3.99 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
@file:Suppress("UnstableApiUsage")
import com.vanniktech.maven.publish.MavenPublishBaseExtension
import com.vanniktech.maven.publish.SonatypeHost
import org.ajoberstar.grgit.Grgit
plugins {
id("org.ajoberstar.grgit") version "5.2.0"
id("de.undercouch.download") version "5.4.0"
alias(libs.plugins.maven.publish.base) apply false
}
val (gitVersion, release) = versionFromGit()
logger.lifecycle("Version: $gitVersion (release: $release)")
allprojects {
group = "dev.arbjerg"
version = gitVersion
repositories {
mavenLocal()
mavenCentral()
maven("https://jitpack.io")
}
}
subprojects {
if (project.name == "natives" || project.name == "extensions-project") {
return@subprojects
}
apply<JavaPlugin>()
apply<MavenPublishPlugin>()
configure<JavaPluginExtension> {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
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")
}
}
afterEvaluate {
plugins.withId(libs.plugins.maven.publish.base.get().pluginId) {
configure<MavenPublishBaseExtension> {
coordinates(group.toString(), project.the<BasePluginExtension>().archivesName.get(), version.toString())
if (findProperty("mavenCentralUsername") != null && findProperty("mavenCentralPassword") != null) {
publishToMavenCentral(SonatypeHost.S01, false)
if (release) {
signAllPublications()
}
} else {
logger.lifecycle("Not publishing to OSSRH due to missing credentials")
}
pom {
name = "lavaplayer"
description = "A Lavaplayer fork maintained by Lavalink"
url = "https://github.com/lavalink-devs/lavaplayer"
licenses {
license {
name = "The Apache License, Version 2.0"
url = "https://github.com/lavalink-devs/lavaplayer/blob/main/LICENSE"
}
}
developers {
developer {
id = "freyacodes"
name = "Freya Arbjerg"
url = "https://www.arbjerg.dev"
}
}
scm {
url = "https://github.com/lavalink-devs/lavaplayer/"
connection = "scm:git:git://github.com/lavalink-devs/lavaplayer.git"
developerConnection = "scm:git:ssh://[email protected]/lavalink-devs/lavaplayer.git"
}
}
}
}
}
}
@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
}
}