-
Notifications
You must be signed in to change notification settings - Fork 19
/
build.gradle
344 lines (282 loc) · 11.7 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
import org.apache.http.HttpEntity
import org.apache.http.client.methods.CloseableHttpResponse
import org.apache.http.client.methods.HttpPost
import org.apache.http.entity.ContentType
import org.apache.http.entity.mime.MultipartEntityBuilder
import org.apache.http.impl.client.CloseableHttpClient
import org.apache.http.impl.client.HttpClients
buildscript {
repositories {
maven { url = "https://repo.spongepowered.org/maven" }
//maven { url = 'https://sizableshrimp.me/maven' }
maven { url = "https://plugins.gradle.org/m2/" }
maven { url = "https://maven.parchmentmc.org" }
mavenCentral()
}
dependencies {
classpath "org.spongepowered:mixingradle:0.7+"
classpath "org.apache.httpcomponents:httpmime:4.5.14"
classpath "org.parchmentmc:librarian:1.+"
}
}
plugins {
id "com.modrinth.minotaur" version "2.+"
id "com.matthewprenger.cursegradle" version "1.4.0"
id 'net.neoforged.gradle' version '[6.0.13, 6.2)'
}
apply plugin: "java"
apply plugin: 'eclipse'
apply plugin: 'org.parchmentmc.librarian.forgegradle'
apply plugin: 'maven-publish'
apply plugin: "org.spongepowered.mixin"
def branch = System.getenv("GITHUB_REF")
def snapshotName = null;
if(branch != null) {
branch = branch.replace('refs/heads/', '')
}
def isRelease = System.getenv("IS_RELEASE") == "true"
snapshotName = (branch == null || branch.startsWith("release-please")) ? "SNAPSHOT" : branch
def githubSha = System.getenv("GITHUB_SHA")
def shaRef = githubSha != null ? "-${githubSha.substring(0, 8)}" : ""
println "Branch ${branch}${shaRef} isRelease: '${isRelease}'"
// Get version from file managed by please-release
def versionString = (file('./version.txt').text + (isRelease ? "" : "-${snapshotName}${shaRef}")).replaceAll('\n', '')
setVersion(versionString)
println "Version: ${getVersion()}"
group = project.package // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = project.archive
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
repositories {
maven { url = "https://maven.sekwah.com" }
maven {
url "https://www.cursemaven.com"
content {
includeGroup "curse.maven"
}
}
}
println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))
minecraft {
// The mappings can be changed at any time, and must be in the following format.
// snapshot_YYYYMMDD Snapshot are built nightly.
// stable_# Stables are built at the discretion of the MCP team.
// Use non-default mappings at your own risk. they may not always work.
// Simply re-run your setup task after changing the mappings to update your workspace.
mappings channel: 'official', version: '1.20.1'
//mappings channel: 'parchment', version: '2021.12.19-1.18.1'
//mappings channel: 'parchment', version: '2021.07.21-1.17'
// This is for personal local tests i was doing ignore it ;)
//mappings channel: 'snapshot', version: '20200706-unofficialtest-1.16.1'
// Readd if access transformers needed
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
// Default run configurations.
// These can be tweaked, removed, or duplicated as needed.
runs {
client {
workingDirectory project.file('run')
// Recommended logging data for a userdev environment
//property 'forge.logging.markers', 'SCAN,REGISTR
//version=1.2.1ES,REGISTRYDUMP'
// Recommended logging level for the console
property 'forge.logging.console.level', 'debug'
property 'mixin.env.remapRefMap', 'true'
property 'mixin.env.refMapRemappingFile', "${buildDir}/createSrgToMcp/output.srg"
mods {
"${project.modid}" {
source sourceSets.main
}
}
}
server {
workingDirectory project.file('run')
// Recommended logging data for a userdev environment
property 'forge.logging.markers', ''
//property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
// Recommended logging level for the console
property 'forge.logging.console.level', 'debug'
mods {
"${project.modid}" {
source sourceSets.main
}
}
}
data {
workingDirectory project.file('run')
// Recommended logging data for a userdev environment
property 'forge.logging.markers', ''
//property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
// Recommended logging level for the console
property 'forge.logging.console.level', 'debug'
args '--mod', project.modid, '--all', '--output', file('src/generated/resources/')
mods {
"${project.modid}" {
source sourceSets.main
}
}
}
}
}
sourceSets.main.resources { srcDir 'src/generated/resources' }
dependencies {
// Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed
// that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied.
// The userdev artifact is a special name and will get all sorts of transformations applied to it.
minecraft 'net.neoforged:forge:1.20.1-47.1.62'
implementation 'org.spongepowered:mixin:0.8.5'
annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'
implementation fg.deobf("com.sekwah:sekclib-forge:[1.0.0,2)")
// Trick intellij to allow for better editing in here for the discord task
// compile "org.apache.httpcomponents:httpmime:4.5.13"
//implementation fg.deobf("curse.maven:torohealth-damage-indicators-245733:3556931")
// implementation fg.deobf("curse.maven:jei-238222:3592081")
// implementation fg.deobf("curse.maven:configured-457570:3559398")
// implementation fg.deobf("curse.maven:jade-324717:3614180")
//implementation fg.deobf("curse.maven:hwyla:${project.hwyla_fileid}")
//include('org.ow2.asm:asm-debug-all:5.2')
// You may put jars on which you depend on in ./libs or you may define them like so..
// compile "some.group:artifact:version:classifier"
// compile "some.group:artifact:version"
// Real examples
// compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env
// compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env
// For more info...
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
// http://www.gradle.org/docs/current/userguide/dependency_management.html
}
mixin {
add sourceSets.main, "mixins.${project.modid}.refmap.json"
debug.verbose = true
debug.export = true
}
// Example for how to get properties into the manifest for reading by the runtime..
jar {
finalizedBy 'reobfJar'
archiveClassifier = 'universal'
archiveBaseName = "${archivesBaseName}${project.mc_version}"
manifest {
attributes([
"Specification-Title": project.modid,
"Specification-Vendor": project.vendor,
"Specification-Version": "1", // We are version 1 of ourselves
"Implementation-Title": project.name,
"Implementation-Version": "${versionString}",
"Implementation-Vendor" :project.vendor,
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
"MixinConfigs": "mixins.${project.modid}.json"
])
}
}
// Example configuration to allow publishing using the maven-publish task
// we define a custom artifact that is sourced from the reobfJar output task
// and then declare that to be published
// Note you'll need to add a repository here
def reobfFile = file("$buildDir/reobfJar/output.jar")
def reobfArtifact = artifacts.add('default', reobfFile) {
type 'jar'
builtBy 'reobfJar'
}
task srcJar(type: Jar) {
build.dependsOn it
from sourceSets.main.allSource
archiveClassifier = 'sources'
archiveBaseName = "${archivesBaseName}${project.mc_version}"
from file("LICENSE")
}
task deobfJar(type: Jar) {
build.dependsOn it
from sourceSets.main.output
archiveClassifier = 'deobf'
archiveBaseName = "${archivesBaseName}${project.mc_version}"
from file("LICENSE")
}
publishing {
publications {
mavenJava(MavenPublication) {
artifact reobfArtifact
artifact srcJar
}
}
repositories {
maven {
url "s3://sekwah-maven/"
authentication {
awsIm(AwsImAuthentication)
}
}
}
}
def getReleaseChangelog() {
def changelogFile = file('CHANGELOG.md')
def changelog = "## [${changelogFile.text.split('\n## \\[')[1]}\n\n"// ${project.github}/blob/${branch}/CHANGELOG.md
return changelog;
}
/**
* For pre-releases and testers to be able to try the latest commits if they want.
* If the builds start exceeding 8MB then we may want to upload to s3 instead and periodically clear.
* TODO possibly add a task that announces when builds are made?
* Though add a note that it may take a while for Curse to approve the files.
*/
task discordupload {
dependsOn(jar)
doLast {
String discordWebhook = System.getenv("DISCORD_WEBHOOK")
if(discordWebhook != null) {
CloseableHttpClient httpClient = HttpClients.createDefault()
HttpPost uploadFile = new HttpPost(discordWebhook)
MultipartEntityBuilder builder = MultipartEntityBuilder.create()
if(!isRelease) {
builder.addTextBody("content", "New snapshot or testing build")
} else {
builder.addTextBody("content", "New release build\n" +
"```markdown\n" +
"${getReleaseChangelog()}\n" +
"```")
}
var name = jar.archiveBaseName.get() + "-" + jar.archiveVersion.get() + ".jar"
builder.addBinaryBody("file", file(jar.archiveFile).newInputStream(), ContentType.APPLICATION_OCTET_STREAM, name)
HttpEntity multipart = builder.build()
uploadFile.setEntity(multipart)
CloseableHttpResponse response = httpClient.execute(uploadFile)
response.getEntity()
println("Posted build")
} else {
println("Discord webhook unspecified")
}
}
}
tasks.curseforge.enabled = System.getenv("CURSE_API") != null
curseforge {
logger.info("Curse api: " + System.getenv("CURSE_API"))
if (System.getenv("CURSE_API") != null) {
apiKey = System.getenv("CURSE_API")
}
project {
id = project.curse_project_id
changelog = getReleaseChangelog()
changelogType = 'markdown'
releaseType = 'release'
addGameVersion '1.20'
addGameVersion '1.20.1'
relations {
requiredDependency 'sekclib'
}
mainArtifact(jar){
}
addArtifact srcJar
addArtifact deobfJar
}
}
// https://github.com/modrinth/minotaur
modrinth {
token = System.getenv("MODRINTH_TOKEN")
projectId = project.modrinth_slug
versionType = "release"
uploadFile = jar
additionalFiles = [srcJar, deobfJar]
gameVersions = ["1.20", "1.20.1"]
changelog = getReleaseChangelog()
dependencies {
required.project "sekclib" // Creates a new required dependency on Fabric API
}
}