Skip to content

Commit 03e20cd

Browse files
committed
feat(build): add Shadow plugin and update jar task configuration; refactor file validation
1 parent 3200e30 commit 03e20cd

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

build.gradle.kts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
plugins {
22
java
33
application
4+
id("com.github.johnrengelman.shadow") version "8.1.1"
45
}
56

67
group = "me.adversing"
@@ -30,9 +31,29 @@ application {
3031
mainClass.set("me.adversing.Main")
3132
}
3233

34+
tasks.jar {
35+
manifest {
36+
attributes(
37+
"Main-Class" to "me.adversing.Main"
38+
)
39+
}
40+
}
41+
3342
tasks.withType<JavaExec> {
3443
jvmArgs(
3544
"--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED",
3645
"--add-opens=java.base/jdk.internal.misc=ALL-UNNAMED"
3746
)
3847
}
48+
49+
tasks.shadowJar {
50+
archiveClassifier.set("all")
51+
manifest {
52+
attributes(
53+
"Main-Class" to "me.adversing.Main",
54+
"Add-Exports" to "java.base/jdk.internal.misc",
55+
"Add-Opens" to "java.base/jdk.internal.misc"
56+
)
57+
}
58+
}
59+

src/main/java/me/adversing/Main.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public static void main(String[] args) {
2121

2222
DiagnosticService diagnosticService = new DiagnosticService();
2323
Parser parser = new Parser(diagnosticService);
24-
String file = validateFile(args[0]);
24+
String file = validateFile(args);
2525
File asmFile = new File(file);
2626

2727
try (ASMEvaluator evaluator = new ASMEvaluator(diagnosticService, debug)) {
@@ -55,10 +55,16 @@ private static boolean hasDebugFlag(String[] args) {
5555
return Arrays.stream(args).anyMatch(arg -> "--debug".equals(arg) || "-d".equals(arg));
5656
}
5757

58-
private static String validateFile(String file) {
59-
if (file == null) {
60-
throw new IllegalArgumentException("No file provided.");
58+
private static String validateFile(String[] args) {
59+
if (args == null || args.length == 0) {
60+
throw new IllegalArgumentException("No arguments provided.");
6161
}
62+
63+
String file = args[0];
64+
if (file == null || file.trim().isEmpty()) {
65+
throw new IllegalArgumentException("File path cannot be null or empty.");
66+
}
67+
6268
return file;
6369
}
6470
}

0 commit comments

Comments
 (0)