This repository has been archived by the owner on Nov 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathbuild.gradle
324 lines (267 loc) · 12.3 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
import org.codehaus.groovy.runtime.GStringImpl
buildscript {
repositories {
maven { url = 'https://maven.minecraftforge.net' }
mavenCentral()
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
plugins {
id 'com.github.johnrengelman.shadow' version '7.1.2'
id "maven-publish"
}
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'kotlin'
// apply plugin: 'eclipse'
apply plugin: 'idea'
apply from: '.scripts/properties-reader.gradle'
if (project.hasProperty("release")) project.ext.mod_version = "$mod_version_major.$mod_version_api.$mod_version_minor.$mod_version_patch" as GStringImpl
else project.ext.mod_version = "$mod_version_major.$mod_version_api.$mod_version_minor.${mod_version_patch.toInteger() + 1}-snapshot${new Date().format("yyyyMMdd'T'HHmmss")}" as GStringImpl // snapshots are always one patch higher than the current release
version = "$minecraft_version-$mod_version" as Object
group = 'at.martinthedragon'
archivesBaseName = "$modid"
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))
println("Mod version: ${project.version}")
sourceSets {
api {
resources.srcDirs = []
}
main {
resources {
include '**/**'
srcDirs += 'src/datagen/generated/resources'
exclude '.cache'
}
compileClasspath += api.output
runtimeClasspath += api.output
}
datagen {
java.srcDirs = ['src/datagen/main/java'] // so java doesn't create a new folder outside
kotlin.srcDirs = ['src/datagen/main/kotlin']
resources.srcDirs = ['src/datagen/main/resources']
compileClasspath += api.output + main.output
}
}
minecraft {
mappings channel: 'official', version: "$minecraft_version"
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
// "SCAN": For mods scan.
// "REGISTRIES": For firing of registry events.
// "REGISTRYDUMP": For getting the contents of all registries.
runs {
client {
workingDirectory file("run")
// for getting tokens, see https://gist.github.com/50ap5ud5/beebcf056cbdd3c922cc8993689428f4#approach-1---use-minecraft-instance
if (project.localProperties != null &&
project.localProperties.containsKey('dev.auth.uuid') &&
project.localProperties.containsKey('dev.auth.token') &&
project.localProperties.containsKey('dev.auth.username') &&
project.localProperties.containsKey('dev.auth.type')
) {
println("Setting Minecraft authentication for " + project.localProperties.get('dev.auth.username'))
args('--uuid', project.localProperties.get('dev.auth.uuid'), '--accessToken', project.localProperties.get('dev.auth.token'), '--username', project.localProperties.get('dev.auth.username'), '--userType', project.localProperties.get('dev.auth.type'))
}
property 'forge.logging.console.level', 'debug'
property 'mixin.env.remapRefMap', 'true'
property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg"
// you'll have to use JetBrains Runtime to get anything out of this
// see http://hotswapagent.org/mydoc_quickstart-jdk17.html
// for use with hotswap agent, use the following arguments: -XX:+AllowEnhancedClassRedefinition,-XX:HotswapAgent=fatjar,-Xlog:redefine+class*=info
// don't forget to regenerate run configs when changing arguments
if (project.localProperties != null && project.localProperties.containsKey('jvm.args')) {
jvmArgs(project.localProperties.get('jvm.args').split(','))
}
mods {
nucleartech {
sources((SourceSet[]) [sourceSets.main, sourceSets.api])
}
}
}
server {
workingDirectory file("run")
property 'forge.logging.console.level', 'debug'
property 'mixin.env.remapRefMap', 'true'
property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg"
// you'll have to use JetBrains Runtime to get anything out of this
// see http://hotswapagent.org/mydoc_quickstart-jdk17.html
// for use with hotswap agent, use the following arguments: -XX:+AllowEnhancedClassRedefinition,-XX:HotswapAgent=fatjar,-Xlog:redefine+class*=info
// don't forget to regenerate run configs when changing arguments
if (project.localProperties != null && project.localProperties.containsKey('jvm.args')) {
jvmArgs(project.localProperties.get('jvm.args').split(','))
}
mods {
nucleartech {
sources((SourceSet[]) [sourceSets.main, sourceSets.api])
}
}
}
data {
workingDirectory file("run")
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
property 'forge.logging.console.level', 'debug'
property 'mixin.env.remapRefMap', 'true'
property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg"
// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
args '--mod', "$modid", '--all', '--output', file('src/datagen/generated/resources/'), '--existing', file('src/main/resources/')
mods {
nucleartech {
sources((SourceSet[]) [sourceSets.main, sourceSets.api, sourceSets.datagen])
}
}
}
}
}
minecraft.runs.all {
lazyToken("minecraft_classpath") {
configurations.library.copyRecursive().resolve()
.collect { it.absolutePath }
//.findAll { !it.contains("org.jetbrains\\annotations\\13.0") && !it.contains("org.jetbrains/annotations/13.0") } // somewhat inelegantly remove duplicate
.join(File.pathSeparator)
}
}
repositories {
maven {
// location of the maven that hosts JEI files
name = "Progwml6 maven"
url = "https://dvs1.progwml6.com/files/maven/"
}
maven {
// location of a maven mirror for JEI files, as a fallback
name = "ModMaven"
url = "https://modmaven.k-4u.nl"
}
maven { url 'https://modmaven.dev/' }
maven { url "https://maven.shedaniel.me" }
mavenCentral()
}
configurations {
library // workaround for IDE runtime
implementation.extendsFrom library
apiImplementation.extendsFrom(implementation)
datagenImplementation.extendsFrom(implementation)
datagenCompileOnly.extendsFrom(compileOnly)
datagenRuntimeOnly.extendsFrom(runtimeOnly)
}
dependencies {
minecraft "net.minecraftforge:forge:$minecraft_version-$forge_version"
library ("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version") {
exclude group: 'org.jetbrains', module: 'annotations'
}
// reload gradle and run genIntellijRuns (or eclipse) after changing
def devModeREI = project.localProperties != null && project.localProperties.containsKey('dev.mode.rei') && Boolean.valueOf(project.localProperties.get("dev.mode.rei"))
println("Currently running integration for ${devModeREI ? "REI" : "JEI"}")
compileOnly fg.deobf("mezz.jei:jei-$minecraft_version:$jei_version:api")
compileOnly fg.deobf("me.shedaniel:RoughlyEnoughItems-api-forge:$rei_version")
compileOnly fg.deobf("me.shedaniel:RoughlyEnoughItems-default-plugin-forge:$rei_version")
if (devModeREI) {
implementation fg.deobf("me.shedaniel:RoughlyEnoughItems-forge:$rei_version")
implementation fg.deobf("me.shedaniel.cloth:cloth-config-forge:$cloth_config_version")
implementation fg.deobf("dev.architectury:architectury-forge:$architectury_version")
} else {
runtimeOnly fg.deobf("mezz.jei:jei-$minecraft_version:$jei_version")
}
// for testing compatibility
runtimeOnly fg.deobf("mekanism:Mekanism:${mekanism_version}")
runtimeOnly fg.deobf("mekanism:Mekanism:${mekanism_version}:additions")
runtimeOnly fg.deobf("mekanism:Mekanism:${mekanism_version}:generators")
runtimeOnly fg.deobf("mekanism:Mekanism:${mekanism_version}:tools")
datagenCompileOnly sourceSets.main.output
}
def manifestAttributes() {
return [
"Specification-Title": "Nuclear Tech Mod",
"Specification-Vendor": "MartinTheDragon",
"Specification-Version": project.mod_version,
"Implementation-Title": project.name,
"Implementation-Version": project.mod_version,
"Implementation-Vendor" :"MartinTheDragon",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
]
}
jar {
dependsOn(classes)
duplicatesStrategy(DuplicatesStrategy.INCLUDE) // is this bad? i dunno
from([sourceSets.api.output, sourceSets.main.output])
// configurations {shaded.extendsFrom library}
// from { configurations.shaded.collect() { it.isDirectory() ? it : zipTree(it) }}
archiveClassifier.set("slim")
manifest.attributes(manifestAttributes())
afterEvaluate { finalizedBy reobfJar }
}
shadowJar {
archiveClassifier.set("")
configurations = [project.configurations.library]
from([sourceSets.api.output, sourceSets.main.output])
def relocation = "${project.group}.relocated"
relocate "kotlin", "${relocation}.kotlin"
relocate "org.intellij", "${relocation}.intellij"
relocate "org.jetbrains", "${relocation}.jetbrains"
afterEvaluate { finalizedBy reobfShadowJar }
}
assemble.dependsOn shadowJar
// you have no idea how much pain and headaches getting this to work caused me
task sourcesJar(type: Jar, dependsOn: [classes, apiClasses]) {
duplicatesStrategy(DuplicatesStrategy.INCLUDE)
archiveClassifier.set("sources")
from([sourceSets.api.kotlin, sourceSets.main.kotlin])
manifest.attributes(manifestAttributes())
}
task apiJar(type: Jar) {
duplicatesStrategy(DuplicatesStrategy.INCLUDE)
archiveClassifier.set("api")
from sourceSets.api.output
manifest.attributes(manifestAttributes())
afterEvaluate { finalizedBy reobfApiJar }
}
artifacts {
archives apiJar
archives jar
}
reobf {
apiJar { classpath.from(sourceSets.api.compileClasspath) }
jar { classpath.from(sourceSets.main.compileClasspath) }
shadowJar {}
}
/*
opt-in=kotlin.RequiresOptIn - Enables usage of experimental APIs
jvm-default=all - Generates defaults in interfaces for Java users
lambdas=indy - Uses invokedynamic for lambdas instead of generating explicit classes
no-call-assertions - Disables not-null assertions on Platform types (when calling Java code)
no-param-assertions - Disables not-null assertions on method parameters given by Java code
use-fast-jar-file-system - Uses an experimental implementation for faster compilation
extended-compiler-checks - Gives some more information about things
*/
def kotlinCompilerArgs = ["-opt-in=kotlin.RequiresOptIn", "-Xjvm-default=all", "-Xlambdas=indy", "-Xno-call-assertions", "-Xno-param-assertions", "-Xuse-fast-jar-file-system"]
compileKotlin {
kotlinOptions {
jvmTarget = "17"
freeCompilerArgs += kotlinCompilerArgs
}
}
compileApiKotlin {
kotlinOptions {
jvmTarget = "17"
freeCompilerArgs += kotlinCompilerArgs + ["-Xexplicit-api=strict"]
}
}
compileDatagenKotlin {
kotlinOptions {
jvmTarget = "17"
freeCompilerArgs += kotlinCompilerArgs
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = "17"
freeCompilerArgs += kotlinCompilerArgs
}
}
idea {
module {
excludeDirs += file("run")
}
}