This repository has been archived by the owner on Jan 18, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathbuild.gradle
325 lines (276 loc) · 9.72 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
buildscript {
repositories {
mavenCentral()
jcenter()
maven {
name = "Valkyrien Skies Internal"
url = "http://maven.valkyrienskies.org/repository/internal/"
}
}
dependencies {
classpath "com.github.GregTechCE:ForgeGradle:7e8e0b4c9d"
classpath "org.spongepowered:mixingradle:0.6-SNAPSHOT"
}
}
plugins {
id "com.github.johnrengelman.shadow" version "4.0.4"
id "maven-publish"
}
apply plugin: "net.minecraftforge.gradle.forge"
apply plugin: "org.spongepowered.mixin"
apply plugin: "java"
ext {
//general things
javaVersion = "1.8"
//determine the version
if (project.hasProperty('CustomReleaseVersion')) {
vsVersion = project.property('CustomReleaseVersion')
} else {
// Get the revision. Use `.execute([], file("."))`
// to always execute in the directory of build.gradle
def revision = "git rev-parse HEAD".execute([], file(".")).text
vsVersion = "1.0.0+" + revision.substring(0, 10)
}
//minecraft things
mcpmappingsVersion = "stable_39"
minecraftforgeVersion = "14.23.5.2838"
minecraftVersion = "1.12.2"
//dependency things
cqengineVersion = "3.4.0"
jacksonVersion = "2.10.0"
javaxInjectVersion = "1"
lombokVersion = "1.18.10"
mixinVersion = "0.8.2"
spongeVersion = "1.12.2-2838-7.3.0"
vsApiVersion = "1.0.0.9"
}
version = "$vsVersion"
group = "org.valkyrienskies"
archivesBaseName = "valkyrien-skies"
compileJava {
sourceCompatibility = targetCompatibility = "$javaVersion"
}
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}
minecraft {
version = "$minecraftVersion-$minecraftforgeVersion"
runDir = "run"
mappings = "$mcpmappingsVersion"
makeObfSourceJar = false
coreMod = "org.valkyrienskies.mixin.MixinLoaderForge"
def args = [
"-Dmixin.checks.interfaces=true",
"-Dmixin.debug.export=true",
"-Dmixin.debug.verbose=true",
"-Dmixin.hotSwap=true",
"-Xmx2G",
"-XX:+UseG1GC",
"-ea",
"-da:io.netty..."
]
clientJvmArgs += args
serverJvmArgs += args
}
configurations {
shade
compile.extendsFrom shade
all { //hacky workaround
resolutionStrategy {
force("com.google.guava:guava:21.0")
}
}
}
repositories {
mavenCentral()
jcenter()
maven {
name = "Valkyrien Skies Internal"
url = "http://maven.valkyrienskies.org/repository/internal/"
}
}
// This is included here because of this garbage https://github.com/SpongePowered/SpongeForge/blob/stable-7/build.gradle#L40-L52
// Basically I can't add compatibility for the newest SpongeForge without this
// Thanks Sponge team!!! >:(
configurations.all {
resolutionStrategy {
force 'com.typesafe:config:1.3.1'
}
}
dependencies {
// mixin needs to be distributed with the mod, very important
shade("org.spongepowered:mixin:$mixinVersion") {
exclude module: "commons-io"
exclude module: "guava"
exclude module: "gson"
exclude module: "launchwrapper"
}
// Mixin annotation processor creates the mixin obfuscation refmap
annotationProcessor("org.spongepowered:mixin:$mixinVersion:processor")
annotationProcessor("org.apache.logging.log4j:log4j-core:2.11.2")
// Needs to be present at compile-time because we mix in to spongeforge, however marking it as
// compile makes forge load it as a mod in a dev environment, which is very annoying
compileOnly("org.spongepowered:spongeforge:$spongeVersion:dev") {
transitive = true
}
// The VS API, just shade it into core no need to make it a standalone mod
shade "org.valkyrienskies:api:$vsApiVersion"
// VS World and Control, for local testing only, not shaded in
deobfCompile("org.valkyrienskies:Valkyrien-Skies-World:1d9df462f15c9125255ea086d7aeb75fe12e5877:all") {
transitive = false
}
deobfCompile("org.valkyrienskies:Valkyrien-Skies-Control:bc55aa179d643fd30d4c49a48a2491633033c5f3:all") {
transitive = false
}
// ODE4j physics engine (https://mvnrepository.com/artifact/org.ode4j/core)
// shade group: 'org.ode4j', name: 'core', version: '0.4.0' // 800KB
// shade group: 'org.ode4j', name: 'demo', version: '0.4.0'
// javax inject annotation
shade "javax.inject:javax.inject:$javaxInjectVersion" // 2KB
// CQEngine for in-memory nonpersistent database
// Provides Kryo
shade("com.googlecode.cqengine:cqengine:$cqengineVersion") {
exclude module: "sqlite-jdbc" //11.1 MB
exclude module: "antlr4-runtime" //648.0 KB
exclude module: "javassist" //1.5 MB
//exclude module: "typetools" //23.5 KB
}
// JOML
shade 'org.joml:joml:1.9.25' // 663 KB
// Jackson
shade "com.fasterxml.jackson.core:jackson-databind:$jacksonVersion"
shade "com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:$jacksonVersion"
shade "com.fasterxml.jackson.module:jackson-module-parameter-names:$jacksonVersion"
shade "com.fasterxml.jackson.datatype:jackson-datatype-jdk8:$jacksonVersion"
// Include all dependencies in the /dependencies folder
shade fileTree(include: ["*.jar"], dir: "dependencies")
// lombok
compileOnly "org.projectlombok:lombok:$lombokVersion"
annotationProcessor "org.projectlombok:lombok:$lombokVersion"
// junit tests
testImplementation 'org.junit.jupiter:junit-jupiter:5.6.2'
testImplementation 'org.hamcrest:hamcrest:2.2'
}
processResources {
// this will ensure that this task is redone when the versions change.
inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version
// replace stuff in mcmod.info, nothing else
from(sourceSets.main.resources.srcDirs) {
include "mcmod.info"
// replace version and mcversion
expand "version": project.version, "mcversion": project.minecraft.version
}
// copy everything else, thats not the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude "mcmod.info"
}
// move _at.cfg into META-INF
rename '(.+_at.cfg)', 'META-INF/$1'
}
mixin {
defaultObfuscationEnv searge
add sourceSets.main, "mixins.valkyrienskies.refmap.json"
}
jar {
classifier = 'unshaded' // this is probably not the one you want
manifest.attributes(
"MixinConfigs": "mixins.valkyrienskies.json,mixins.valkyrienskies-sponge-compat.json",
"tweakClass": "org.spongepowered.asm.launch.MixinTweaker",
"FMLCorePluginContainsFMLMod": "true",
"FMLCorePlugin": "org.valkyrienskies.mixin.MixinLoaderForge",
"ForceLoadAsMod": "true",
"FMLAT": "valkyrienskies_at.cfg"
)
}
shadowJar {
classifier = null // No -all classifier
configurations = [project.configurations.shade]
relocate 'com.fasterxml', 'org.valkyrienskies.deps.com.fasterxml'
mergeServiceFiles() // https://github.com/johnrengelman/shadow/issues/304
}
reobf {
jar {
mappingType = "SEARGE"
classpath = sourceSets.main.compileClasspath
}
shadowJar{
mappingType = "SEARGE"
classpath = sourceSets.main.compileClasspath
}
}
build.dependsOn(reobfJar)
build.dependsOn(reobfShadowJar)
publishing {
repositories {
def ghpUser = project.findProperty("gpr.user") ?: System.getenv("USERNAME")
def ghpPassword = project.findProperty("gpr.key") ?: System.getenv("TOKEN")
if (ghpUser != null && ghpPassword != null) {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/ValkyrienSkies/Valkyrien-Skies")
credentials {
username = ghpUser
password = ghpPassword
}
}
}
if (project.hasProperty("daporkchopMavenUsername") && project.hasProperty("daporkchopMavenPassword")) {
maven {
credentials {
username = "$daporkchopMavenUsername"
password = "$daporkchopMavenPassword"
}
name = "DaPorkchop_"
url = "https://maven.daporkchop.net/release/"
}
}
}
publications {
maven(MavenPublication) {
groupId = "org.valkyrienskies"
artifactId = "valkyrien-skies"
version = project.version
artifact jar {
classifier null
}
artifact shadowJar {
classifier "all"
}
artifact sourceJar {
classifier "sources"
}
}
}
}
//sets additional JVM args for genIntellijRuns
//task preIntellijRuns {
// doFirst {
// StreamSupport.stream(configurations.compile.spliterator(), false).filter({
// it.name.contains("mixin")
// }).findAny().ifPresent({
// minecraft.clientJvmArgs += "-javaagent:" + it.absolutePath
// minecraft.serverJvmArgs += "-javaagent:" + it.absolutePath
// })
// }
//}
//genIntellijRuns.dependsOn(preIntellijRuns)
// Junit testing
test {
useJUnitPlatform()
}
/*
// Based on this tutorial https://darkhax.net/2017/10/jar-signing
task signJar(type: SignJar, dependsOn: reobfShadowJar) {
onlyIf {
project.hasProperty('keyStore')
}
keyStore = project.findProperty('keyStore')
alias = project.findProperty('keyStoreAlias')
storePass = project.findProperty('keyStorePass')
keyPass = project.findProperty('keyStoreKeyPass')
inputFile = new File(shadowJar.getDestinationDir(), shadowJar.getArchiveName().replaceAll(".jar", "-all.jar"));
outputFile = inputFile
}
build.dependsOn signJar
*/