Skip to content

Commit 158cb03

Browse files
committed
Revert "Relocate libraries in shadow jar"
Tho this would be the proper way to do things, and should prevent issues when launchers force the installer to be run every launch. This breaks the wrapper because they do things in a lazy way. As such reverting.
1 parent b44b9a4 commit 158cb03

2 files changed

Lines changed: 40 additions & 30 deletions

File tree

build.gradle

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,15 @@ dependencies {
4646
testRuntimeOnly(libs.bundles.junit.runtime)
4747
}
4848

49-
// This isn't great, but it alows us to drop a existing jar file into the root folder and do some debugging
50-
def testJars = fileTree(dir: projectDir).matching{ include '*-installer.jar' }
51-
if (testJars.files.size() == 1) {
52-
logger.lifecycle("Detected test installer: ${testJars.singleFile.name}")
53-
def testData = tasks.register('testData', Jar) {
54-
from(zipTree(testJars.singleFile)) {
55-
exclude('**/*.class')
56-
exclude('META-INF/**')
57-
exclude('joptsimple/**')
58-
}
59-
includeEmptyDirs = false
60-
archiveClassifier = 'test-data'
61-
}
62-
dependencies.implementation(files(testData))
63-
}
49+
Files.list(Paths.get(projectDir.absolutePath))
50+
.filter(Files::isRegularFile)
51+
.filter(path -> path.getFileName().toString().endsWith('-installer.jar'))
52+
.findFirst()
53+
.ifPresent(path -> {
54+
var firstFile = path.toFile()
55+
logger.lifecycle("Detected test installer: ${firstFile.name}")
56+
dependencies.implementation(files(firstFile))
57+
})
6458

6559
tasks.named('jar', Jar) {
6660
manifest {
@@ -99,21 +93,6 @@ tasks.named('shadowJar', ShadowJar) {
9993

10094
archiveClassifier = 'fatjar'
10195
minimize()
102-
103-
// Meta stuff we don't need
104-
exclude('com/google/errorprone/**')
105-
exclude('META-INF/maven/**')
106-
exclude('META-INF/proguard/**')
107-
108-
// We shouldn't ever need to care about conflicts as this is an executable jar, but just be safe
109-
relocate('joptsimple', 'net.minecraftforge.installer.shadow.joptsimple')
110-
relocate('com.google.gson', 'net.minecraftforge.installer.shadow.gson')
111-
112-
// Rewrite JOpt's message files, so that help text is displayed nicely.
113-
transform(com.github.jengelman.gradle.plugins.shadow.transformers.PropertiesFileTransformer) {
114-
paths = [ 'Messages.properties$' ]
115-
keyTransformer = { key -> 'net.minecraftforge.installer.shadow.' + key }
116-
}
11796
}
11897

11998
tasks.withType(JavaCompile).configureEach {

proguard.pro

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
-dontoptimize
2+
-dontobfuscate
3+
#-dontpreverify
4+
-dontwarn javax.annotation.**
5+
-dontwarn javax.inject.**
6+
-dontwarn com.google.gson.**
7+
8+
9+
# Keep - Applications. Keep all application classes, along with their 'main'
10+
# methods.
11+
-keepclasseswithmembers public class * {
12+
public static void main(java.lang.String[]);
13+
}
14+
15+
# Also keep - Enumerations. Keep the special static methods that are required in
16+
# enumeration classes.
17+
-keepclassmembers enum * {
18+
public static **[] values();
19+
public static ** valueOf(java.lang.String);
20+
}
21+
22+
# Also keep - Swing UI L&F. Keep all extensions of javax.swing.plaf.ComponentUI,
23+
# along with the special 'createUI' method.
24+
-keep class * extends javax.swing.plaf.ComponentUI {
25+
public static javax.swing.plaf.ComponentUI createUI(javax.swing.JComponent);
26+
}
27+
28+
# Keep names - Native method names. Keep all native class/method names.
29+
-keepclasseswithmembers,allowshrinking class * {
30+
native <methods>;
31+
}

0 commit comments

Comments
 (0)