forked from MC-U-Team/Music-Player
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
330 lines (275 loc) · 7.23 KB
/
build.gradle
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
buildscript {
apply from: "https://raw.githubusercontent.com/HyCraftHD/Blank-Forge-Project/master/build.methods"
setup()
repositories {
maven {
url = "https://maven.minecraftforge.net"
}
maven {
url = "https://repo.u-team.info"
}
maven {
url = "https://plugins.gradle.org/m2/"
}
mavenCentral()
}
dependencies {
classpath "net.minecraftforge.gradle:ForgeGradle:${config.forge.gradle}"
classpath "gradle.plugin.com.matthewprenger:CurseGradle:1.4.0"
classpath "com.github.jengelman.gradle.plugins:shadow:4.0.4"
}
}
apply from: "https://raw.githubusercontent.com/HyCraftHD/Blank-Forge-Project/master/build.methods"
apply from: "https://raw.githubusercontent.com/HyCraftHD/Blank-Forge-Project/master/git.methods"
setup()
info()
apply plugin: "net.minecraftforge.gradle.forge"
apply plugin: "com.matthewprenger.cursegradle"
apply plugin: "maven"
apply plugin: "com.github.johnrengelman.shadow"
repositories {
maven { url = "https://repo.u-team.info" }
mavenCentral()
}
getBuildNumber()
group = "info.u-team"
archivesBaseName = "${config.mod.filename}-${config.forge.mcversion}"
version = "${config.mod.version}.${config.buildnumber}" + getAppendix();
def getAppendix() {
if("${config.mod.snapshot}".toBoolean()) {
return "-SNAPSHOT"
} else {
return ""
}
}
sourceCompatibility = targetCompatibility = "1.8"
compileJava {
sourceCompatibility = targetCompatibility = "1.8"
}
minecraft {
version = config.forge.version
runDir = "run"
mappings = "${config.forge.mapping}"
makeObfSourceJar = false
clientJvmArgs += "\"-Dmusicplayer.dev=${devPath()}\""
replace '${version}', project.version
replace '${mcversion}', project.minecraft.version
replaceIn "info/u_team/music_player/MusicPlayerMod.java"
}
def devPath() {
def buildDir = project(":musicplayer-lavaplayer").buildDir
def libs = new File(buildDir, "libs").absolutePath
def dependencies = new File(buildDir, "dependencies").absolutePath
return "${libs};${dependencies}"
}
def normalManifest = {
attributes(
"Specification-Title": config.mod.name,
"Specification-Vendor": "Team UTeam",
"Specification-Version": "11.14",
"Built-On": config.forge.mcversion,
"Implementation-Title": config.mod.name,
"Implementation-Version": project.version,
"Implementation-Vendor": "Team UTeam",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
)
}
configurations {
shade
tinyfd
library
library.extendsFrom(shade)
library.extendsFrom(tinyfd)
implementation.extendsFrom(library)
}
tasks.register("deleteTinyfd", Delete) {
delete fileTree("build/tinyfd")
}
tasks.register("extractTinyfd", Copy) {
dependsOn "deleteTinyfd"
destinationDir = file("${project.buildDir}/tinyfd")
from configurations.tinyfd
rename { String fileName ->
fileName += ".packed"
}
}
shadowJar {
classifier = ""
configurations = [project.configurations.shade]
dependsOn "jar"
dependsOn "extractTinyfd"
dependsOn ":musicplayer-lavaplayer-api:build"
dependsOn ":musicplayer-lavaplayer:build"
from sourceSets.main.output
from "musicplayer-lavaplayer/src/main/resources/LICENSE-DEPENDENCIES"
doFirst {
from project(":musicplayer-lavaplayer-api").sourceSets.main.output
}
into ("dependencies") {
from "musicplayer-lavaplayer/build/libs/musicplayer-lavaplayer.jar.packed"
from "musicplayer-lavaplayer/build/dependencies"
}
into ("tinyfd") {
from "build/tinyfd"
}
relocate "org.slf4j", "info.u_team.music_player.shade.org.slf4j"
relocate "net.harawata.appdirs", "info.u_team.music_player.shade.net.harawata.appdirs"
exclude "META-INF/maven/**"
manifest normalManifest
}
tasks.matching { task ->
task.name == "setupDecompWorkspace"
}.configureEach { task ->
task.dependsOn(":musicplayer-lavaplayer:assemble")
}
tasks.matching { task ->
task.name == "reobfJar"
}.configureEach { task ->
task.dependsOn("shadowJar")
}
uploadArchives.dependsOn "reobfJar"
task sourcesJar(type: Jar) {
classifier = "sources"
from sourceSets.main.allJava
from "LICENSE"
}
task docJar(type: Jar) {
classifier = "javadoc"
from javadoc
from "LICENSE"
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
options.addStringOption('encoding', 'UTF-8')
options.addStringOption('charSet', 'UTF-8')
}
}
artifacts {
archives sourcesJar
archives docJar
archives shadowJar
}
sourceSets {
main {
java
resources
}
}
dependencies {
library project(":musicplayer-lavaplayer-api")
shade "org.slf4j:slf4j-simple:1.7.36"
shade ("net.harawata:appdirs:1.0.0") {
transitive=false
}
tinyfd ("org.lwjgl:lwjgl-tinyfd:3.2.2:natives-linux") {
transitive=false
}
tinyfd ("org.lwjgl:lwjgl-tinyfd:3.2.2:natives-macos") {
transitive=false
}
tinyfd ("org.lwjgl:lwjgl-tinyfd:3.2.2:natives-windows") {
transitive=false
}
}
processResources {
inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version
from(sourceSets.main.resources.srcDirs) {
include "mcmod.info"
expand "version":project.version, "mcversion":project.minecraft.version
}
from(sourceSets.main.resources.srcDirs) {
exclude "mcmod.info"
}
}
compileJava {
options.encoding = "UTF-8"
}
def getValue(name) {
def envVariable = System.getenv(name)
if(envVariable != null) {
return envVariable
} else {
if (project.hasProperty(name)) {
return project.getProperty(name)
}
}
return null;
}
def getValueDefault(name) {
def value = getValue(name)
if(value == null) {
return "noValue"
}
return value
}
tasks.curseforge.dependsOn "reobfJar"
curseforge {
apiKey = getValueDefault("curseforge.token")
project {
id = config.curse.id
releaseType = config.curse.type
addGameVersion minecraft.version
addGameVersion "Forge"
addGameVersion "Java 8"
options {
forgeGradleIntegration = false
}
mainArtifact(tasks.getByName("jar")) {
displayName = "${config.curse.display}-${minecraft.version}-${project.version}"
changelogType = "html"
changelog = "<a href=\"${config.curse.changelog}\">Changelog of ${project.version}</a>"
}
}
}
uploadArchives {
repositories {
mavenDeployer {
if (project.hasProperty("mavenpass")) {
repository(url: "https://repo.u-team.info") {
authentication(userName: "maven", password: getValueDefault("maven.password"))
}
}
pom {
groupId = project.group
artifactId = project.archivesBaseName
version = project.version
project {
name project.archivesBaseName
packaging "jar"
description "Music-Player"
url "https://github.com/MC-U-Team/Music-Player"
scm {
url "https://github.com/MC-U-Team/Music-Player"
connection "scm:git:git://github.com/MC-U-Team/Music-Player.git"
developerConnection "scm:git:[email protected]:MC-U-Team/Music-Player.git"
}
issueManagement {
system "github"
url "https://github.com/MC-U-Team/Music-Player/issues"
}
licenses {
license {
name "Apache License 2.0"
url "https://github.com/MC-U-Team/Music-Player/blob/1.8.9-backport/LICENSE"
distribution "repo"
}
}
developers {
developer {
name "HyCraftHD"
}
}
}
}
}
}
}
task uploadBoth {
dependsOn assemble
dependsOn uploadArchives
dependsOn "curseforge${config.curse.id}"
dependsOn setBuildNumber
doLast {
println "Published both"
}
}