forked from arjunnain17/3arthh4ck_1.3.1-BUILDABLE-SRC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
296 lines (256 loc) · 10 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
import java.text.DateFormat
import java.text.SimpleDateFormat
buildscript {
repositories {
//noinspection JCenterRepository
jcenter()
maven {
name = 'forge'
url = 'https://files.minecraftforge.net/maven'
}
maven {
name = 'SpongePowered'
url = 'https://repo.spongepowered.org/maven'
}
maven {
name = "jitpack.io"
url = "https://jitpack.io"
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
classpath 'org.spongepowered:mixingradle:0.6-SNAPSHOT'
classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.4'
classpath 'com.formdev:flatlaf:1.5'
}
}
apply plugin: 'net.minecraftforge.gradle.forge'
// TODO: double check if there's forge methods we missed with vanilla source
// apply plugin: 'net.minecraftforge.gradle.tweaker-client'
apply plugin: 'org.spongepowered.mixin'
apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'application'
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'eclipse'
mainClassName = "me.earth.earthhack.installer.main.Main"
group project.modGroup //http://maven.apache.org/guides/mini/guide-naming-conventions.html
def getCheckedOutGitCommitHash() {
def gitFolder = "$projectDir/.git/"
def takeFromHash = 12
/*
* '.git/HEAD' contains either
* in case of detached head: the currently checked out commit hash
* otherwise: a reference to a file containing the current commit hash
*/
def head = new File(gitFolder + "HEAD").text.split(":") // .git/HEAD
def isCommit = head.length == 1 // e5a7c79edabbf7dd39888442df081b1c9d8e88fd
// def isRef = head.length > 1 // ref: refs/heads/master
if(isCommit) return head[0].trim().take(takeFromHash) // e5a7c79edabb
def refHead = new File(gitFolder + head[1].trim()) // .git/refs/heads/master
refHead.text.trim().take takeFromHash
}
// build constants
boolean INCREMENT = false // increments version
// NO APPEND THAT YOURSELF BITCH
boolean UNIQUE = false // adds a random 8-char string to the build number
// instead of incrementing the last number
// this is so that we don't get absurdly large numbers
// maybe only increment the number automatically if CI is ever added to the repo?
boolean HASH = true
boolean DATE = false // adds the date to the random string
boolean CLEAR = true // clears other jars in the build folder to stop it from being clogged up
boolean VANILLA = false
String title = getCheckedOutGitCommitHash()
//noinspection GroovyUnusedAssignment
sourceCompatibility = targetCompatibility = '1.8'
compileJava {
// idk this gets called when u do anything but whatever
File versionFile = file 'version'
String contents = versionFile.getText( 'UTF-8' )
String[] split = contents.split('\\.')
int lastVersion = Integer.parseInt(split[2].split('-')[0])
if (INCREMENT)
{
lastVersion++
}
if (!UNIQUE)
{
contents = split[0] + '.' + split[1] + '.' + (lastVersion)
}
else
{
String extra = ""
if (DATE)
{
Date date = Calendar.getInstance().getTime()
DateFormat dateFormat = new SimpleDateFormat('mm-dd-yy-hh-mm')
extra = dateFormat.format(date) + '-'
}
String generatedString = UUID.randomUUID().toString().split('-')[0]
String randomString = lastVersion + '-' + 'build-' + extra + generatedString
contents = split[0] + '.' + split[1] + '.' + randomString
}
if (HASH)
{
contents = split[0] + '.' + split[1] + '.' + lastVersion + '-' + title
}
versionFile.write( contents, 'UTF-8' )
version contents
sourceCompatibility = targetCompatibility = '1.8'
// Tbh it would be much easier if we could assign this differently
// instead of writing it, but StackOverflow didn't give a working
// solution for that. One looked promising but it caused duplicate classes.
File update = file 'src/main/java/me/earth/earthhack/impl/Earthhack.java'
contents = update.getText( 'UTF-8' )
contents = contents.replaceAll( 'VERSION = "(.*?)"', 'VERSION = "' + project.version + '"' )
update.write( contents, 'UTF-8' )
update = file 'src/main/resources/mcmod.info'
contents = update.getText( 'UTF-8' )
contents = contents.replaceAll( '"version": "(.*?)"', '"version": "' + project.version + '"' )
update.write( contents, 'UTF-8' )
if (CLEAR)
{
File libs = file buildDir.getAbsolutePath() + '/libs/'
if (libs.exists() && libs.isDirectory())
{
for (File file in libs.listFiles())
{
file.delete()
}
}
}
}
minecraft {
//noinspection GroovyAssignabilityCheck
version = project.forgeVersion
runDir = 'run'
mappings = project.mcpVersion
makeObfSourceJar = false
// tweakClass = 'me.earth.earthhack.tweaker.EarthhackTweaker'
}
repositories {
maven {
name = 'spongepowered-repo'
url = 'https://repo.spongepowered.org/maven'
}
maven {
name = "jitpack.io"
url = "https://jitpack.io"
}
mavenCentral()
google()
/*maven {
url = 'https://oss.sonatype.org/content/repositories/snapshots/'
}*/
/*maven {
url = 'https://oss.sonatype.org/content/repositories/releases/'
}*/
}
dependencies {
compile('org.spongepowered:mixin:0.7.11-SNAPSHOT') {
exclude module: 'launchwrapper'
exclude module: 'guava'
exclude module: 'gson'
exclude module: 'commons-io'
}
/*compile('org.languagetool:language-en:5.4') {
exclude module: 'guava'
}*/
// compile group: 'org.languagetool', name: 'language-en', version: '5.4'
/*compile('org.languagetool:languagetool-core:5.4') {
exclude module: 'guava'
}*/
compile group: 'club.minnced', name: 'java-discord-rpc', version: '2.0.1'
compile group: 'com.formdev', name: 'flatlaf', version: '1.5'
// compile group: 'org.l33tlabs.twl', name: 'pngdecoder', version: '1.0'
compile group: 'org.slick2d', name: 'slick2d-core', version: '1.0.2'
compile group: 'org.joml', name: 'joml', version: '1.10.2'
compile group: 'us.ihmc', name: 'jassimp', version: '4.0.0-ihmc6'
compile group: 'us.ihmc', name: 'ihmc-native-library-loader', version: '1.3.1'
compile group: 'com.github.stephengold', name: 'Libbulletjme', version: '12.5.0'
compile group: 'de.fabmax', name: 'physx-jni', version: '0.4.15'
compile group: 'de.fabmax', name: 'physx-jni', version: '0.4.15:native-win64'
compile group: 'net.java.dev.jna', name: 'jna', version: '5.8.0'
compile group: 'net.java.dev.jna', name: 'jna-platform', version: '5.8.0'
compile group: 'com.badlogicgames.gdx', name: 'gdx', version: '1.10.0'
compile group: 'com.badlogicgames.gdx', name: 'gdx-bullet', version: '1.10.0'
compile group: 'com.badlogicgames.gdx', name: 'gdx-backend-lwjgl', version: '1.10.0'
compile "com.badlogicgames.gdx:gdx-platform:1.10.0:natives-desktop"
compile "com.badlogicgames.gdx:gdx-bullet-platform:1.10.0:natives-desktop"
}
task getDeps(type: Copy) {
from sourceSets.main.runtimeClasspath
into 'runtime/'
}
processResources {
inputs.property 'version', project.version
inputs.property 'mcversion', project.minecraft.version
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'
expand 'version': project.version, 'mcversion': project.minecraft.version
}
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}
rename '(.+_at.cfg)', 'META-INF/$1'
}
shadowJar {
dependencies {
//noinspection GroovyAssignabilityCheck
// include(dependency('org.languagetool:languagetool-core'))
// include(dependency('org.languagetool:language-en'))
include(dependency('org.spongepowered:mixin'))
include(dependency('club.minnced:java-discord-rpc:2.0.1'))
include(dependency('club.minnced:discord-rpc-release:v3.3.0'))
include(dependency('com.formdev:flatlaf:1.5'))
// include(dependency('org.l33tlabs.twl:pngdecoder:1.0'))
include(dependency('org.slick2d:slick2d-core'))
// include(dependency('com.github.dabasan:jassimp'))
// include(dependency(files('libs/assimp4j.jar')))
include(dependency('org.joml:joml'))
include(dependency('us.ihmc:jassimp'))
include(dependency('us.ihmc:ihmc-native-library-loader'))
include(dependency('org.apache.commons:commons-lang3'))
/* Below this line is stuff necessary for unfinished stuff on my local branch. */
include(dependency('com.github.stephengold:Libbulletjme'))
include(dependency('de.fabmax:physx-jni'))
include(dependency('com.badlogicgames.gdx:gdx-backend-lwjgl'))
include(dependency('com.badlogicgames.gdx:gdx'))
include(dependency('com.badlogicgames.gdx:gdx-bullet'))
include(dependency('com.badlogicgames.gdx:gdx-platform'))
include(dependency('com.badlogicgames.gdx:gdx-bullet-platform'))
include(dependency('net.java.dev.jna:jna'))
include(dependency('net.java.dev.jna:jna-platform'))
// include(dependency(files('libs/patched-lwjgl.jar')))
// include(dependency('org.lwjgl:lwjgl-assimp'))
// include(dependency('org.lwjgl:lwjgl'))
}
exclude 'dummyThing'
exclude 'LICENSE.txt'
classifier = 'release'
}
mixin {
defaultObfuscationEnv searge
//noinspection GroovyAssignabilityCheck
add sourceSets.main, 'mixins.earth.refmap.json'
}
reobf {
shadowJar {
mappingType = VANILLA ? 'NOTCH' : 'SEARGE'
classpath = sourceSets.main.compileClasspath
}
}
jar {
manifest {
attributes(
'Manifest-Version': 1.0,
'TweakClass': 'me.earth.earthhack.tweaker.EarthhackTweaker',
'TweakOrder': -999,
'FMLCorePluginContainsFMLMod': 'true',
'ForceLoadAsMod': 'true',
'Main-Class': mainClassName
)
}
}
build.dependsOn(shadowJar)