Skip to content

Commit 55008ea

Browse files
Luna5ama5HT2
andauthored
[refactor] Updated Gradle and bunch of dependencies (#1664)
Co-authored-by: Dominika <sokolov.dominika@gmail.com>
1 parent 3b32428 commit 55008ea

20 files changed

Lines changed: 257 additions & 158 deletions

.travis.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
language: java
22
jdk:
3-
- openjdk8
4-
before_install:
5-
- chmod +x gradlew
6-
- "./gradlew setupDecompWorkspace"
3+
- openjdk8
4+
install:
5+
- chmod +x gradlew
6+
- "./gradlew --no-daemon compileJava"

build.gradle

Lines changed: 112 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,49 @@
11
buildscript {
2+
23
repositories {
34
jcenter()
5+
46
maven {
57
name = 'forge'
68
url = 'http://files.minecraftforge.net/maven'
79
}
10+
811
maven {
912
name = 'SpongePowered'
1013
url = 'http://repo.spongepowered.org/maven'
1114
}
1215
}
16+
1317
dependencies {
14-
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
15-
classpath 'org.spongepowered:mixingradle:0.6-SNAPSHOT'
16-
classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.3'
17-
classpath group: 'org.jetbrains.kotlin', name: 'kotlin-gradle-plugin', version: "${kotlin_version}"
18+
classpath 'net.minecraftforge.gradle:ForgeGradle:3.+'
19+
classpath 'org.spongepowered:mixingradle:0.7-SNAPSHOT'
20+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1821
}
22+
1923
}
2024

25+
apply plugin: 'idea'
26+
apply plugin: 'eclipse'
27+
2128
apply plugin: 'kotlin'
22-
apply plugin: 'net.minecraftforge.gradle.forge'
29+
apply plugin: 'net.minecraftforge.gradle'
2330
apply plugin: 'org.spongepowered.mixin'
24-
apply plugin: 'com.github.johnrengelman.shadow'
2531

2632
version project.modVersion
2733
group project.modGroup
2834

29-
sourceSets {
30-
main.java.srcDirs += 'src/main/cape-api'
31-
main.java.srcDirs += 'src/main/commons'
35+
sourceSets.main.java {
36+
srcDirs += 'src/main/cape-api'
37+
srcDirs += 'src/main/commons'
3238
}
3339

3440
compileKotlin {
35-
kotlinOptions {
36-
jvmTarget = "1.8"
37-
}
38-
}
39-
compileTestKotlin {
40-
kotlinOptions {
41-
jvmTarget = "1.8"
42-
}
41+
kotlinOptions.jvmTarget = "1.8"
4342
}
4443

4544
compileJava {
4645
sourceCompatibility = targetCompatibility = '1.8'
47-
}
48-
49-
minecraft {
50-
version = project.forgeVersion
51-
runDir = 'run'
52-
mappings = project.mcpVersion
53-
coreMod = 'me.zeroeightsix.kami.mixin.MixinLoaderForge'
54-
makeObfSourceJar = false
46+
options.encoding = 'UTF-8'
5547
}
5648

5749
repositories {
@@ -75,105 +67,129 @@ repositories {
7567
jcenter()
7668
}
7769

70+
71+
minecraft {
72+
mappings channel: 'stable', version: '39-1.12'
73+
74+
runs {
75+
client {
76+
workingDirectory project.file('run')
77+
78+
property 'fml.coreMods.load', 'me.zeroeightsix.kami.mixin.MixinLoaderForge'
79+
property 'mixin.env.disableRefMap', 'true' // Disable refmap so we don't get trolled by Baritone
80+
81+
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
82+
property 'forge.logging.console.level', 'debug'
83+
}
84+
}
85+
}
86+
87+
configurations {
88+
jarLibs
89+
}
90+
7891
dependencies {
79-
compile("org.spongepowered:mixin:0.7.11-SNAPSHOT") { // do NOT update this to 8.0 or above, it breaks compatibility with future client
80-
exclude module: 'launchwrapper'
81-
exclude module: 'guava'
82-
exclude module: 'gson'
92+
// Forge
93+
minecraft 'net.minecraftforge:forge:1.12.2-14.23.5.2854'
94+
95+
jarLibs('org.spongepowered:mixin:0.7.11-SNAPSHOT') {
8396
exclude module: 'commons-io'
97+
exclude module: 'gson'
98+
exclude module: 'guava'
99+
exclude module: 'launchwrapper'
84100
exclude module: 'log4j-core' // we want to exclude this as well because 0.7.11 includes it too new for MC
85101
}
86102

87-
compile(group: 'org.reflections', name: 'reflections', version: '0.9.12') {
88-
exclude group: 'com.google.guava', module: 'guava'
103+
// Hacky way to get mixin work
104+
annotationProcessor('org.spongepowered:mixin:0.8.2:processor') {
105+
exclude module: 'gson'
89106
}
90107

91-
compile 'club.minnced:java-discord-rpc:2.0.2'
92-
compile 'com.github.kevinsawicki:http-request:http-request-6.0'
93-
compile 'com.github.MrPowerGamerBR:TemmieWebhook:-SNAPSHOT'
108+
jarLibs('org.reflections:reflections:0.9.12') {
109+
exclude module: 'gson'
110+
exclude module: 'guava'
111+
}
94112

95-
compile 'com.github.cabaletta:baritone:1.2.14'
96-
compile 'cabaletta:baritone-api:1.2'
113+
jarLibs('club.minnced:java-discord-rpc:2.0.2') {
114+
exclude module: 'jna'
115+
}
97116

98-
compile group: "org.jetbrains.kotlin", name: "kotlin-stdlib", version: kotlin_version
99-
compile group: "org.jetbrains.kotlin", name: "kotlin-stdlib-jdk7", version: kotlin_version
100-
compile group: "org.jetbrains.kotlin", name: "kotlin-stdlib-jdk8", version: kotlin_version
101-
compile group: "org.jetbrains.kotlin", name: "kotlin-reflect", version: kotlin_version
117+
jarLibs('com.github.MrPowerGamerBR:TemmieWebhook:-SNAPSHOT') {
118+
exclude module: 'gson'
119+
}
102120

103-
compile group: "org.jetbrains", name: "annotations", version: annotations_version
104-
}
121+
jarLibs 'com.github.kevinsawicki:http-request:6.0'
105122

106-
processResources {
107-
inputs.property 'version', project.version
108-
inputs.property 'mcversion', project.minecraft.version
109123

110-
exclude '**/rawimagefiles'
124+
// Kotlin libs
125+
// kotlin-stdlib-common and annotations aren't required at runtime
126+
jarLibs("org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version") {
127+
exclude module: 'kotlin-stdlib-common'
128+
exclude module: 'annotations'
129+
}
111130

112-
from(sourceSets.main.resources.srcDirs) {
113-
include 'mcmod.info'
131+
jarLibs("org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version") {
132+
exclude module: 'kotlin-stdlib-common'
133+
exclude module: 'annotations'
134+
}
114135

115-
expand 'version': project.version, 'mcversion': project.minecraft.version
136+
jarLibs("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version") {
137+
exclude module: 'kotlin-stdlib-common'
138+
exclude module: 'annotations'
116139
}
117140

118-
from(sourceSets.main.resources.srcDirs) {
119-
exclude 'mcmod.info'
141+
jarLibs("org.jetbrains.kotlin:kotlin-reflect:$kotlin_version") {
142+
exclude module: 'kotlin-stdlib-common'
143+
exclude module: 'annotations'
120144
}
121145

122-
rename '(.+_at.cfg)', 'META-INF/$1'
123-
}
146+
// Add them back to compileOnly (provided)
147+
compileOnly "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlin_version"
148+
compileOnly 'org.jetbrains:annotations:13.0'
124149

125-
shadowJar {
126-
dependencies {
127-
include(dependency('cabaletta:baritone-api'))
128-
include(dependency('club.minnced:java-discord-rpc'))
129-
include(dependency('com.github.kevinsawicki:http-request'))
130-
include(dependency('com.github.MrPowerGamerBR:TemmieWebhook'))
131-
include(dependency("org.jetbrains.kotlin:kotlin-reflect:${kotlin_version}"))
132-
include(dependency("org.jetbrains.kotlin:kotlin-stdlib:${kotlin_version}"))
133-
include(dependency("org.jetbrains.kotlin:kotlin-stdlib-jdk7:${kotlin_version}"))
134-
include(dependency("org.jetbrains.kotlin:kotlin-stdlib-jdk8:${kotlin_version}"))
135-
include(dependency('org.javassist:javassist'))
136-
include(dependency('org.reflections:reflections'))
137-
include(dependency('org.spongepowered:mixin'))
138-
}
139-
140-
exclude 'dummyThing' // can someone explain why this is here
141-
classifier = 'release'
150+
// This Baritone will NOT be included in the jar
151+
implementation 'com.github.cabaletta:baritone:1.2.14'
152+
153+
// This Baritone WILL be included in the jar
154+
jarLibs 'cabaletta:baritone-api:1.2'
155+
156+
// Add everything in jarLibs to implementation (compile)
157+
implementation configurations.jarLibs
142158
}
143159

144160
mixin {
145-
defaultObfuscationEnv searge
161+
defaultObfuscationEnv 'searge'
146162
add sourceSets.main, 'mixins.kami.refmap.json'
147163
}
148164

149-
reobf {
150-
shadowJar {
151-
mappingType = 'SEARGE'
152-
classpath = sourceSets.main.compileClasspath
153-
}
154-
}
165+
processResources {
166+
inputs.property 'version', project.version
155167

156-
// Don't put baritone mixin here please c:
157-
jar {
158-
manifest {
159-
attributes(
160-
'MixinConfigs': 'mixins.kami.json',
161-
'tweakClass': 'org.spongepowered.asm.launch.MixinTweaker',
162-
'TweakOrder': 0,
163-
'FMLCorePluginContainsFMLMod': 'true',
164-
'FMLCorePlugin': 'me.zeroeightsix.kami.mixin.MixinLoaderForge',
165-
'ForceLoadAsMod': 'true',
166-
'FMLAT': 'kami_at.cfg'
167-
)
168+
exclude '**/rawimagefiles'
169+
170+
from(sourceSets.main.resources.srcDirs) {
171+
include 'mcmod.info'
172+
expand 'version': project.version
168173
}
169174
}
170175

176+
// Don't put baritone mixin here please c:
171177
jar {
172-
manifest {
173-
attributes(
174-
'Main-Class': 'me.zeroeightsix.installer.Installer'
175-
)
178+
manifest.attributes(
179+
'Manifest-Version': 1.0,
180+
'MixinConfigs': 'mixins.kami.json',
181+
'TweakClass': 'org.spongepowered.asm.launch.MixinTweaker',
182+
'TweakOrder': 0,
183+
'FMLCorePluginContainsFMLMod': 'true',
184+
'FMLCorePlugin': 'me.zeroeightsix.kami.mixin.MixinLoaderForge',
185+
'ForceLoadAsMod': 'true',
186+
'Main-Class': 'me.zeroeightsix.installer.Installer'
187+
)
188+
189+
// Copy needed libs to jar
190+
from {
191+
configurations.jarLibs.collect {
192+
it.isDirectory() ? it : zipTree(it)
193+
}
176194
}
177-
}
178-
179-
build.dependsOn(shadowJar)
195+
}

gradle.properties

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
org.gradle.jvmargs=-Xmx3G
22
modGroup=me.zeroeightsix
33
modVersion=1.12.xx-dev
4-
modBaseName=kamiblue
5-
forgeVersion=1.12.2-14.23.5.2847
6-
mcpVersion=stable_39
7-
kotlin_version=1.3.72
8-
annotations_version=16.0.3
4+
kotlin_version=1.4.20

gradle/wrapper/gradle-wrapper.jar

-4 Bytes
Binary file not shown.
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
#Thu Mar 26 18:02:24 EDT 2020
2-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-all.zip
31
distributionBase=GRADLE_USER_HOME
42
distributionPath=wrapper/dists
5-
zipStorePath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-bin.zip
64
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists

scripts/buildJarSafe.sh

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/bin/bash
2+
3+
# Created by l1ving on 17/02/20
4+
#
5+
# ONLY USED IN AUTOMATED BUILDS
6+
#
7+
# Usage: "./buildJarSafe.sh"
8+
9+
__d="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
10+
source ~/.profile
11+
source "$__d/utils.sh"
12+
13+
check_var "JDK_11_HOME" "$JDK_11_HOME" || exit $?
14+
check_var "JDK_8_HOME" "$JDK_8_HOME" || exit $?
15+
16+
if [ -z "$KAMI_DIR" ]; then
17+
echo "[buildJarSafe] Environment variable KAMI_DIR is not set, exiting." >&2
18+
exit 1
19+
fi
20+
21+
cd "$KAMI_DIR" || exit $?
22+
23+
rm -rf build/libs/ || {
24+
echo "[buildJarSafe] Failed to remove 'build/libs/', exiting." >&2
25+
exit 1
26+
}
27+
28+
export JAVA_HOME="$JDK_8_HOME"
29+
sudo archlinux-java set java-8-openjdk || exit $?
30+
chmod +x gradlew
31+
./gradlew --no-daemon build &>/dev/null || {
32+
echo "[buildJarSafe] Gradle build failed, exiting." >&2
33+
exit 1
34+
}
35+
36+
cd build/libs/ || exit $?
37+
38+
__named="$(find . -maxdepth 1 -name "*.jar" | head -n 1 | sed "s/^\.\///g")"
39+
# shellcheck disable=SC2001
40+
__bad_named="$(echo "$__named" | sed "s/\.jar$/-release.jar/g")"
41+
42+
mv "$__named" "$__bad_named" # rename it to include release
43+
44+
# Build release jar with the name without -release
45+
export JAVA_HOME="$JDK_11_HOME"
46+
sudo archlinux-java set java-11-openjdk || exit $?
47+
java -jar "$__d/jar-shrink/jar-shrink.jar" "$__bad_named" -out "$__named" -n -keep "me.zeroeightsix" -keep "baritone" -keep "org.kamiblue" -keep "org.spongepowered"
48+
49+
rm "$__bad_named" # remove the un-shrunk jar with -release
50+
51+
echo "$__named" # echo the shrunk jar, without -release

0 commit comments

Comments
 (0)