-
-
Notifications
You must be signed in to change notification settings - Fork 28
/
build.gradle.kts
110 lines (87 loc) · 3.76 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
plugins {
id("com.github.breadmoirai.github-release") version "2.4.1"
id("com.cjcrafter.polymart-release") version "1.0.1"
}
polymart {
val weaponMechanicsVersion = findProperty("weaponMechanicsVersion") as? String ?: throw IllegalArgumentException("weaponMechanicsVersion was null")
apiKey = findProperty("polymart_api_key").toString()
title = weaponMechanicsVersion
version = weaponMechanicsVersion
resourceId = 4709
message = "This is a *test update* which was **published automatically**. You may ignore this."
file.set(file("build").resolve("WeaponMechanics.zip"))
}
githubRelease {
// https://github.com/BreadMoirai/github-release-gradle-plugin
val weaponMechanicsVersion = findProperty("weaponMechanicsVersion") as? String ?: throw IllegalArgumentException("weaponMechanicsVersion was null")
owner.set("WeaponMechanics")
repo.set("MechanicsMain")
authorization.set("Token ${findProperty("pass").toString()}")
tagName.set("v${weaponMechanicsVersion}")
targetCommitish.set("master")
releaseName.set("v${weaponMechanicsVersion}")
draft.set(false)
prerelease.set(false)
generateReleaseNotes.set(true)
body.set("")
overwrite.set(false)
allowUploadToExisting.set(false)
apiEndpoint.set("https://api.github.com")
setReleaseAssets(file("build").listFiles())
// If set to true, you can debug that this would do
dryRun.set(false)
}
// This is a helper method to compile MechanicsCore, WeaponMechanics, and to
// put all the stuff in zip files and such for github release.
tasks.register("buildForSpigotRelease").configure {
println("Cleaning build directory")
val folder = file("build")
folder.deleteRecursively()
folder.mkdir()
dependsOn(":BuildMechanicsCore:shadowJar")
dependsOn(":BuildWeaponMechanics:shadowJar")
finalizedBy("resourcePackForSpigotRelease", "zipForSpigotRelease")
}
tasks.register<Copy>("resourcePackForSpigotRelease") {
dependsOn("buildForSpigotRelease")
// !!! Has to be updated when resource pack is updated !!!
val resourcePackVersion = findProperty("resourcePackVersion") as? String ?: throw IllegalArgumentException("resourcePackVersion was null")
from("${layout.projectDirectory}\\resourcepack\\WeaponMechanicsResourcePack-${resourcePackVersion}.zip")
into(layout.buildDirectory)
doFirst {
println("Copy resource pack")
}
}
tasks.register<Zip>("zipForSpigotRelease") {
dependsOn("buildForSpigotRelease", "resourcePackForSpigotRelease")
archiveFileName.set("WeaponMechanics.zip")
destinationDirectory.set(layout.buildDirectory)
from(layout.buildDirectory) {
include("*.jar")
}
from("install-instructions.txt")
doFirst {
println("Generate zip file")
}
}
tasks.register<Zip>("zipNewResourcePack") {
// root > resourcepack > current
// is a directory with the current resource pack files. This task will
// take all of those files and put them in a zip file with the correct
// version number.
val resourcePackVersion = findProperty("resourcePackVersion") as? String ?: throw IllegalArgumentException("resourcePackVersion was null")
// if there is already file with the same name, throw an exception
val file = file("resourcepack").resolve("WeaponMechanicsResourcePack-${resourcePackVersion}.zip")
if (file.exists()) {
throw IllegalArgumentException("Resource pack v$resourcePackVersion already exists: ${file.absolutePath}")
}
archiveFileName.set("WeaponMechanicsResourcePack-${resourcePackVersion}.zip")
destinationDirectory.set(file("resourcepack"))
from(file("resourcepack").resolve("current"))
// add to git
doLast {
exec {
commandLine = listOf("git", "add", file.absolutePath)
}
}
}