-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle.kts
140 lines (117 loc) · 3.43 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
import org.ajoberstar.grgit.Grgit
plugins {
java
`maven-publish`
alias(libs.plugins.lavalink)
alias(libs.plugins.grgit)
}
val (gitVersion, release) = versionFromGit()
logger.lifecycle("Version: $gitVersion (release: $release)")
group = "me.duncte123"
version = gitVersion
lavalinkPlugin {
name = "java-lyrics-plugin"
path = "$group.lyrics.lavalink"
configurePublishing = false
apiVersion = libs.versions.lavalink.api
serverVersion = libs.versions.lavalink.server
}
val isLavalinkMavenDefined = System.getenv("LAVALINK_MAVEN_USERNAME") != null && System.getenv("LAVALINK_MAVEN_PASSWORD") != null
val lavalinkMavenUrl: String
get() {
if (release) {
return "https://maven.lavalink.dev/releases"
}
return "https://maven.lavalink.dev/snapshots"
}
subprojects {
apply(plugin = "java")
apply(plugin = "maven-publish")
apply(plugin = "org.ajoberstar.grgit")
tasks.compileJava {
options.encoding = "UTF-8"
}
publishing {
repositories {
if (isLavalinkMavenDefined && name == "lavalyrics") {
maven {
name = "lavalink"
url = uri(lavalinkMavenUrl)
credentials {
username = System.getenv("LAVALINK_MAVEN_USERNAME")
password = System.getenv("LAVALINK_MAVEN_PASSWORD")
}
}
}
}
}
}
allprojects {
repositories {
mavenCentral()
maven("https://maven.lavalink.dev/releases")
maven("https://maven.lavalink.dev/snapshots")
maven("https://maven.topi.wtf/releases")
maven("https://maven.topi.wtf/snapshots")
}
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}
tasks {
compileJava {
options.encoding = "UTF-8"
}
}
dependencies {
compileOnly(libs.jackson.databind)
compileOnly(libs.jackson.annotations)
compileOnly(libs.lavalink.server)
compileOnly(libs.lavaplayer)
compileOnly(libs.lavaplayer.rotator)
implementation(projects.protocol)
implementation(projects.application)
}
tasks.jar {
archiveBaseName.set("lyrics")
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
tasks.wrapper {
gradleVersion = "8.5"
distributionType = Wrapper.DistributionType.BIN
}
publishing {
repositories {
if (isLavalinkMavenDefined) {
maven {
name = "lavalink"
url = uri(lavalinkMavenUrl)
credentials {
username = System.getenv("LAVALINK_MAVEN_USERNAME")
password = System.getenv("LAVALINK_MAVEN_PASSWORD")
}
}
}
}
publications {
create<MavenPublication>("maven") {
groupId = "me.duncte123"
artifactId = "java-lyrics-plugin"
from(components["java"])
}
}
}
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
}
}