forked from RakambdaOrg/FallingTree
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
156 lines (134 loc) · 4.76 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
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("com.google.guava:guava:30.1.1-jre")
classpath("commons-io:commons-io:2.11.0")
}
}
import com.modrinth.minotaur.TaskModrinthUpload
import groovy.json.JsonOutput
import groovy.json.JsonSlurper
plugins {
id("com.matthewprenger.cursegradle") version("1.4.0")
id("com.modrinth.minotaur") version("1.2.1")
id("com.github.ben-manes.versions") version("0.39.0")
}
allprojects {
apply plugin: "java"
java.toolchain.languageVersion = JavaLanguageVersion.of(16)
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
options.compilerArgs = ["-Xlint:deprecation"]
}
dependencies {
compileOnly(libs.lombok)
annotationProcessor(libs.lombok)
}
repositories {
mavenCentral()
maven {
name = "Minecraft Libraries"
url = uri("https://libraries.minecraft.net")
}
maven {
name = 'CurseForge'
url = 'https://minecraft.curseforge.com/api/maven'
}
maven {
name = "ModMenu"
url = "https://maven.terraformersmc.com/releases/"
}
maven {
name = "Cloth Config"
url = "https://maven.shedaniel.me/"
}
}
}
group = "fr.raksrinana"
archivesBaseName = "${project.modName}-${project.minecraft_version}"
task buildJar(type: Jar, group: "modding") {
dependsOn assemble, ":common:build", ":fabric:build", ":forge:build"
finalizedBy ":forge:signJar"
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
from zipTree("common/build/libs/common-${project.version}.jar"),
zipTree("fabric/build/libs/fabric-${project.version}.jar"),
zipTree("forge/build/libs/forge-${project.version}.jar")
manifest {
attributes([
"Specification-Title" : project.modId,
"Specification-Vendor" : "RakSrinaNa",
"Specification-Version" : project.version,
"Implementation-Title" : project.modName,
"Implementation-Version" : "${project.version}",
"Implementation-Vendor" : "RakSrinaNa",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}
}
assemble.finalizedBy("buildJar")
curseforge {
apiKey = "${project.findProperty("curseforgeApiKey")}"
project {
id = "${project.curseforge_project_id}"
changelogType = "markdown"
addGameVersion project.minecraft_version
addGameVersion "Java 16"
changelog = project.findProperty("changelog") ?: "No changelog provided"
releaseType = "${project.releaseType}"
mainArtifact(jar) {
displayName = "${project.minecraft_version}-${project.version}"
}
relations {
//Fabric
optionalDependency("fabric-api") //It's actually required
optionalDependency("modmenu")
embeddedLibrary("cloth-config")
//Forge
optionalDependency("cloth-config-forge")
}
}
options {
javaVersionAutoDetect = false
javaIntegration = false
forgeGradleIntegration = false
}
}
task publishModrinth(type: TaskModrinthUpload, group: "upload") {
dependsOn build
token = project.findProperty("modrinthToken") as String
projectId = project.modrinth_project_id
versionNumber = "${project.version}"
versionName = "${project.minecraft_version}-${project.version}"
uploadFile = jar
addGameVersion(project.minecraft_version as String)
addLoader("fabric")
addLoader("forge")
versionType = project.releaseType.toLowerCase()
changelog = project.findProperty("changelog") ?: "No changelog provided"
}
def writeUpdateJson() {
def version = project.version
def mcVersion = project.minecraft_version
def slurper = new JsonSlurper()
def file = project.file("update.json")
def json = slurper.parse(file)
def changelogUrl = "https://github.com/${project.repoUser}/${project.repoName}/releases"
json["changelog"] = changelogUrl
// TODO: Maybe add something to create an abbreviated changelog? May not be useful...
json.putIfAbsent(mcVersion, new HashMap<>())
json[mcVersion].putIfAbsent(version, changelogUrl + "/" + version)
json[mcVersion] = json[mcVersion].sort([compare: { a, b -> a.compareTo(b) }] as Comparator)
json["promos"]["${mcVersion}-latest"] = version
json["promos"]["${mcVersion}-recommended"] = version
println(json)
file.write(JsonOutput.prettyPrint(JsonOutput.toJson(json)))
}
task createUpdateJson(group: "modding") {
doLast {
println("Updating update.json...")
writeUpdateJson()
}
}
build.finalizedBy createUpdateJson