-
Notifications
You must be signed in to change notification settings - Fork 0
/
buildtools.gradle
49 lines (41 loc) · 1.53 KB
/
buildtools.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
import groovy.json.JsonSlurper
def buildToolsFolder = new File(project.buildDir, "buildtools")
def downloadFolder = new File(buildToolsFolder, "download")
def mcversion = '1.18.2'
private static def getVersions() {
List<String> versionList = new ArrayList<>()
Map versions = new JsonSlurper().parse(new URL('https://launchermeta.mojang.com/mc/game/version_manifest.json'))
for(def versionObj : versions.versions) {
if(versionObj.type == 'release') {
versionList.add(versionObj.id)
}
}
return versionList
}
task setMCVersion() {
}
task checkVersion() {
def versionList = getVersions()
if(!versionList.contains(mcversion)) {
mcversion = 'latest'
println "Version ${mcversion} is not available. Using latest version latest instead."
}
}
task downloadBuildTools(type: Download) {
dependsOn(checkVersion)
downloadFolder.mkdirs()
src 'https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar'
dest file(downloadFolder.absolutePath + '/BuildTools.jar')
onlyIfModified true
}
task cleanBuildTools(type: Delete) {
file(downloadFolder).delete()
}
task runBuildTools(type: Exec) {
dependsOn(downloadBuildTools)
finalizedBy(cleanBuildTools)
def workingDirectory = new File(buildToolsFolder, mcversion)
workingDirectory.mkdirs()
setWorkingDir(workingDirectory.absolutePath)
commandLine "java", '-jar', "${downloadFolder.absolutePath}/BuildTools.jar", '--remapped', '--compile-if-changed', "--rev", mcversion
}