forked from Darkhax-Minecraft/BotanyPots
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
392 lines (289 loc) · 13.4 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
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
buildscript {
repositories {
maven { url = 'https://maven.minecraftforge.net/' }
maven { url 'https://plugins.gradle.org/m2/' }
jcenter()
mavenCentral()
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true
classpath 'gradle.plugin.com.matthewprenger:CurseGradle:1.4.0'
classpath group: 'gradle.plugin.com.diluv.diluvgradle', name: 'DiluvGradle', version: '1.3.0'
classpath group: 'com.diluv.schoomp', name: 'Schoomp', version: '1.1.0'
}
}
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'com.matthewprenger.cursegradle'
apply plugin: 'maven-publish'
apply plugin: 'eclipse'
apply from: 'https://raw.githubusercontent.com/MinecraftModDevelopment/Gradle-Collection/master/generic/secrets.gradle'
apply from: 'https://raw.githubusercontent.com/MinecraftModDevelopment/Gradle-Collection/master/generic/markdown-git-changelog.gradle'
apply from: 'https://raw.githubusercontent.com/MinecraftModDevelopment/Gradle-Collection/master/minecraft/artifacts.gradle'
apply from: 'https://raw.githubusercontent.com/MinecraftModDevelopment/Gradle-Collection/master/minecraft/maven_local_nomcp.gradle'
apply from: 'https://raw.githubusercontent.com/MinecraftModDevelopment/Gradle-Collection/master/generic/patreon.gradle'
apply from: 'https://raw.githubusercontent.com/MinecraftModDevelopment/Gradle-Collection/master/generic/format_json.gradle'
import groovy.json.JsonSlurper
import groovy.json.JsonOutput
import com.diluv.schoomp.Webhook
import com.diluv.schoomp.message.Message
import com.diluv.schoomp.message.embed.Embed
import com.diluv.schoomp.message.embed.Footer
if (project.hasProperty('secretFile')) {
loadSecrets(new File((String) findProperty('secretFile')))
}
version = "${mod_version}" + getBuildNumber()
archivesBaseName = "${mod_name}-${minecraft_version}"
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8'
minecraft {
mappings channel: 'snapshot', version: "${mcp_version}".toString()
if (project.hasProperty('mod_at')) {
accessTransformer = file(findProperty('mod_at'))
}
runs {
client {
workingDirectory project.file('run')
taskName "${mod_name}".replaceAll("\\s","") + 'Client'
jvmArg "-Dmixin.env.disableRefMap=true"
property 'forge.logging.console.level', 'debug'
mods {
botanypots {
source sourceSets.main
}
}
}
server {
workingDirectory project.file('run')
taskName "${mod_name}".replaceAll("\\s","") + 'Server'
jvmArg "-Dmixin.env.disableRefMap=true"
property 'forge.logging.console.level', 'debug'
mods {
botanypots {
source sourceSets.main
}
}
}
}
}
repositories {
maven {
name = "Progwml6 maven (JEI)"
url = "https://dvs1.progwml6.com/files/maven/"
}
maven {
name = "Jared's Maven (CRT)"
url "https://maven.blamejared.com"
}
maven {
name = "TehNut's Maven (HWYLA)"
url "https://maven.tehnut.info"
}
maven {
name 'tterrag maven'
url "https://maven.tterrag.com/"
}
}
dependencies {
minecraft "net.minecraftforge:forge:${forge_version}"
compile fg.deobf("net.darkhax.bookshelf:Bookshelf-Forge-1.16.5:${bookshelf_version}")
compile fg.deobf("mezz.jei:jei-1.16.5:${jei_version}")
compile fg.deobf("com.blamejared.crafttweaker:CraftTweaker-1.16.5:${crafttweaker_version}")
compile fg.deobf("mcp.mobius.waila:Hwyla:${hwyla_version}")
compile fg.deobf("mcjty.theoneprobe:TheOneProbe-1.16:${top_version}")
}
jar {
manifest {
attributes([
'Timestamp': System.currentTimeMillis(),
'Specification-Title': "${mod_name}",
'Specification-Vendor': "${mod_vendor}",
'Specification-Version': "${version}",
'Implementation-Title': project.archivesBaseName,
'Implementation-Version': project.version,
'Implementation-Vendor' :"${mod_vendor}",
'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
'Built-On-Java': "${System.getProperty('java.vm.version')} (${System.getProperty('java.vm.vendor')})",
'Built-On': "${forge_version}"
])
}
}
String getBuildNumber() {
return System.getenv('BUILD_NUMBER') ? System.getenv('BUILD_NUMBER') : System.getenv('TRAVIS_BUILD_NUMBER') ? System.getenv('TRAVIS_BUILD_NUMBER') : '0';
}
processResources {
from(sourceSets.main.resources.srcDirs) {
include 'META-INF/mods.toml'
def credits = "Thanks to my supporters on Patreon. "
def patreonSupporters = new ArrayList<String>()
for (entry in getPledges()) {
def pledge = entry.getValue();
if (pledge.isValid()) {
patreonSupporters.add(pledge.getDisplayName())
}
}
credits += patreonSupporters.join(', ')
expand 'version': project.version, 'mod_name': mod_name, 'mod_download': mod_download, 'mod_credits': credits, 'mod_authors': mod_authors, 'mod_description': mod_description
}
from(sourceSets.main.resources.srcDirs) {
exclude 'META-INF/mods.toml'
}
doLast {
def jsonMinifyStart = System.currentTimeMillis()
def jsonMinified = 0
def jsonBytesSaved = 0
fileTree(dir: outputs.files.asPath, include: '**/*.json').each {
File file = it
jsonMinified++
def oldLength = file.length()
file.text = JsonOutput.toJson(new JsonSlurper().parse(file))
jsonBytesSaved += oldLength - file.length()
}
println('Minified ' + jsonMinified + ' json files. Saved ' + jsonBytesSaved + ' bytes. Took ' + (System.currentTimeMillis() - jsonMinifyStart) + 'ms.')
}
}
curseforge {
apiKey = findProperty('curse_auth') ?: 0
def versions = "${curse_versions}".split(', ')
project {
id = "${curse_project}"
releaseType = 'alpha'
changelog = getGitChangelog() + "\n\nLike the mod? Consider following me on [Twitter](https://twitter.com/darkhaxdev) and joining the [Discord](https://discord.darkhax.net)\n\nHuge thanks to my supporters on [Patreon](https://www.patreon.com/Darkhax?MCChangelog?${mod_name})\n\n" + getPledgeLog()
changelogType = 'markdown'
versions.each {
addGameVersion "${it}"
}
if (project.hasProperty('curse_requirements') || project.hasProperty('curse_optionals')) {
mainArtifact(jar) {
relations {
if (project.hasProperty('curse_requirements')) {
def requirements = "${curse_requirements}".split(', ')
requirements.each {
requiredLibrary "${it}"
}
}
if (project.hasProperty('curse_optionals')) {
def optionals = "${curse_optionals}".split(', ')
optionals.each {
optionalLibrary "${it}"
}
}
}
}
}
addArtifact(sourcesJar)
addArtifact(javadocJar)
addArtifact(deobfJar)
}
}
tasks.getByName("curseforge").doLast {
try {
// Reads the file ID given to us by CurseForge
def newFileId = tasks.getByName("curseforge${curse_project}").property('mainArtifact').fileID
def webhook = new Webhook(findProperty('discordCFWebhook'), "${project.findProperty('mod_name')} Gradle Upload");
def message = new Message();
message.setUsername(findProperty('mod_name'));
message.setContent("${project.findProperty('mod_name')} ${version} for Minecraft ${findProperty('minecraft_version')} has been released! The download will be public soon.");
def embed = new Embed();
embed.addField('Download', "${project.findProperty('curse_page')}/files/$newFileId", false);
embed.addField('Change Log', "${getGitChangelog() ?: 'Unavailable :('}", false);
embed.setColor(0xFF8000);
message.addEmbed(embed);
webhook.sendMessage(message);
}
catch (IOException e) {
println 'Failed to push to the Discord webhook.'
}
}
task updateVersionTracker {
onlyIf {
project.hasProperty('versionTrackerAPI')
}
doLast {
def body = [
'author': "${project.findProperty('mod_vendor')}",
'projectName': "${project.findProperty('mod_name').toLowerCase()}",
'gameVersion': "${project.findProperty('minecraft_version')}",
'projectVersion': "${version}",
'homepage': "${project.findProperty('mod_download')}",
'uid': "${project.findProperty('versionTrackerKey')}"
]
// Opens a connection to the version tracker API and writes the payload JSON.
def req = new URL(project.findProperty('versionTrackerAPI')).openConnection()
req.setRequestMethod('POST')
req.setRequestProperty('Content-Type', 'application/json; charset=UTF-8')
req.setRequestProperty('User-Agent', "${project.findProperty('mod_name')} Tracker Gradle")
req.setDoOutput(true)
req.getOutputStream().write(JsonOutput.toJson(body).getBytes("UTF-8"))
// We need to attempt a read in order to actually send the message.
println "VersionCheck Status code: ${req.getResponseCode()}"
println "VersionCheck Response: ${req.getInputStream().getText()}"
}
}
// Diluv Publishing
import com.diluv.diluvgradle.TaskDiluvUpload
task publishDiluv (type: TaskDiluvUpload) {
//failSilently = true;
apiURL = findProperty('diluv_api')
token = findProperty('diluv_token')
changelog = getGitChangelog() + "\n\nHuge thanks to my supporters on [Patreon](https://www.patreon.com/Darkhax?MCChangelog?${mod_name})\n\n" + getPledgeLog()
projectId = findProperty('diluv_project')
projectVersion = project.version
uploadFile = jar
addDependency(1); // bookshelf
doLast {
def webhook = new Webhook(findProperty('diluv_discord_webhook'), "${project.findProperty('mod_name')} Gradle Upload");
def message = new Message();
message.setUsername(findProperty('mod_name'));
if (wasUploadSuccessful()) {
message.setContent("${project.findProperty('mod_name')} ${version} for Minecraft ${findProperty('minecraft_version')} has been released! The download will be publicly usable soon.");
def embed = new Embed();
embed.addField('Download', "[**NodeCDN Download Link**](${uploadInfo.downloadURL})", false);
embed.addField('Change Log', "${getGitChangelog() ?: 'Unavailable :('}", false);
embed.setFooter(new Footer("Uploaded by ${uploadInfo.uploader.displayName}", uploadInfo.uploader.avatarURL));
embed.setColor(0x009944);
try {
def connection = new URL("${apiURL}/v1/projects/${projectId}").openConnection() as HttpURLConnection;
connection.setRequestProperty('User-Agent', 'Gradle Webhook');
connection.setRequestProperty('Accept', 'application/json');
def response = connection.inputStream.withCloseable {inStream -> new JsonSlurper().parse(inStream as InputStream)};
if (connection.responseCode == 200) {
message.setAvatarUrl(response.logo);
}
}
catch (IOException e) {}
message.addEmbed(embed);
}
else {
message.setContent("There was an error uploading to Diluv :(");
if (errorInfo != null) {
def embed = new Embed();
embed.addField("Project Version", version, true);
embed.addField("Project ID", findProperty('diluv_project'), true);
embed.addField("Type", errorInfo.type, false);
embed.addField("Message", errorInfo.message, false);
embed.setColor(0xcf000f);
message.addEmbed(embed);
}
}
webhook.sendMessage(message);
}
}
// Jar Signing
import net.minecraftforge.gradle.common.task.SignJar
task signJar(type: SignJar, dependsOn: jar) {
onlyIf {
project.hasProperty('keyStore')
}
if (project.hasProperty('keyStore')) {
project.logger.info('Signing jar ' + jar.archivePath.getName());
keyStore = project.findProperty('keyStore')
alias = project.findProperty('keyStoreAlias')
storePass = project.findProperty('keyStorePass')
keyPass = project.findProperty('keyStoreKeyPass')
inputFile = jar.archivePath
outputFile = jar.archivePath
}
else {
project.logger.warn('Could not sign ' + jar.archivePath.getName() + '. No keyStore property could be found')
}
}
build.dependsOn signJar