-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbuild.gradle
154 lines (127 loc) · 4.24 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
plugins {
id "io.github.pacifistmc.forgix" version "1.+"
id 'com.gradleup.shadow' version '8.3.4' apply false
}
forgix {
group = "com.lx862.jcm"
mergedJarName = "${project.archives_base_name}-${project.mod_version}+${project.minecraft_version}.jar"
outputDir = "build/"
fabric {
projectName = "fabric"
jarLocation = "build/libs/${project.archives_base_name}-fabric-${project.mod_version}+${project.minecraft_version}.jar"
}
forge {
projectName = "forge"
jarLocation = "build/libs/${project.archives_base_name}-forge-${project.mod_version}+${project.minecraft_version}.jar"
}
}
configure(subprojects.findAll {it.name != 'rhino'}) {
apply plugin: "java"
apply plugin: 'com.gradleup.shadow'
group project.maven_group
version "${rootProject.properties.mod_version}+${rootProject.properties.minecraft_version}"
configurations {
shadowImplementation
implementation.extendsFrom shadowImplementation
}
base {
archivesName = "${rootProject.archives_base_name}-${project.properties.loader_name}"
}
dependencies {
implementation 'com.google.code.findbugs:jsr305:+'
shadowImplementation project(":rhino")
}
repositories {
flatDir { dirs "../libs" }
maven { url "https://jitpack.io" }
}
shadowJar {
configurations = [project.configurations.shadowImplementation]
}
def mc_ver = rootProject.properties.minecraft_version
def mc_major = mc_ver.split("\\.")[0]
def mc_main = mc_ver.split("\\.")[1]
def mc_minor = mc_ver.split("\\.").size() > 2 ? (mc_ver.split("\\.")[2] as String).padLeft(2, '0') : 0
def merged_mc_version = "$mc_major$mc_main$mc_minor"
ext { // Expose to subproject
java_version =
(merged_mc_version as int) <= 11605 ? 8 :
(merged_mc_version as int) <= 11701 ? 16 :
(merged_mc_version as int) <= 12004 ? 17 :
21
lg_unicode = (mc_main as int) <= 19 ? rootProject.properties.legacy_unicode_font : rootProject.properties.modern_fallback_font
door_blockstate = (mc_main as int) <= 18 ? rootProject.properties.mc_door_118 : rootProject.properties.mc_door_119
full_mod_version = version + artifact_date
}
/* Manifold support */
tasks.withType(JavaCompile).forEach {
it.options.compilerArgs += [ // Dependencies declared in subproject
"-Xplugin:Manifold",
"-AMC_VERSION=$merged_mc_version",
"-ALOADER=$project.properties.loader_name"
]
}
// Some system don't compile with UTF-8 by default
compileJava {
options.encoding = 'UTF-8'
}
// Replace placeholder resources
processResources {
inputs.property "version", version + artifact_date
inputs.property "minecraft_version", rootProject.minecraft_version
inputs.property "legacy_unicode", project.lg_unicode
inputs.property "mc_door_blockstate", project.door_blockstate
filesMatching('META-INF/mods.toml') {
expand (
"minecraft_version": minecraft_version,
"mod_version": project.full_mod_version
)
}
filesMatching("fabric.mod.json") {
expand (
"version": project.full_mod_version,
"minecraft_version": rootProject.minecraft_version
)
}
filesMatching("**/font/*.json") {
expand (
"legacy_unicode": project.lg_unicode,
)
}
filesMatching("**/blockstates/auto_iron_door.json") {
expand (
"mc_door_blockstate": project.door_blockstate,
)
}
}
compileJava.dependsOn(":rhino:checkRhino")
build.finalizedBy(mergeJars)
assemble.finalizedBy(mergeJars)
}
tasks.register("setupFiles") {
var sourceModloader = "fabric"
doLast {
for(var targetModloader : ["forge"]) {
delete fileTree("${targetModloader}/src/main/java/com/lx862/jcm/mod")
delete fileTree("${targetModloader}/src/main/java/com/lx862/mtrscripting")
delete fileTree("${targetModloader}/src/main/resources/assets")
delete fileTree("${targetModloader}/src/main/resources/data")
copy {
from "${sourceModloader}/src/main/java/com/lx862/jcm/mod"
into "${targetModloader}/src/main/java/com/lx862/jcm/mod"
}
copy {
from "${sourceModloader}/src/main/java/com/lx862/mtrscripting"
into "${targetModloader}/src/main/java/com/lx862/mtrscripting"
}
copy {
from "${sourceModloader}/src/main/resources/assets"
into "${targetModloader}/src/main/resources/assets"
}
copy {
from "${sourceModloader}/src/main/resources/data"
into "${targetModloader}/src/main/resources/data"
}
}
}
}