Skip to content

Commit de34094

Browse files
Big-Iron-CheemsMineGame159
authored andcommitted
Refactor launcher into source set, eliminate launch subproject
1 parent fe4a568 commit de34094

4 files changed

Lines changed: 47 additions & 42 deletions

File tree

build.gradle.kts

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ configurations {
6969
}
7070
}
7171

72+
sourceSets.create("launcher")
73+
7274
dependencies {
7375
// Fabric
7476
minecraft(libs.minecraft)
@@ -100,6 +102,16 @@ dependencies {
100102
jij(libs.waybackauthlib)
101103
}
102104

105+
sourceSets {
106+
val launcher = getByName("launcher")
107+
108+
launcher.apply {
109+
java {
110+
srcDir("src/launcher/java")
111+
}
112+
}
113+
}
114+
103115
// Handle transitive dependencies for jar-in-jar
104116
// Based on implementation from BaseProject by FlorianMichael/EnZaXD
105117
// Source: https://github.com/FlorianMichael/BaseProject/blob/main/src/main/kotlin/de/florianmichael/baseproject/Fabric.kt
@@ -113,7 +125,6 @@ afterEvaluate {
113125
"jsr305" // Compile time annotations only
114126
)
115127

116-
117128
jijConfig.incoming.resolutionResult.allDependencies.forEach { dep ->
118129
val requested = dep.requested.displayName
119130

@@ -135,12 +146,6 @@ loom {
135146
accessWidenerPath = file("src/main/resources/meteor-client.accesswidener")
136147
}
137148

138-
afterEvaluate {
139-
tasks.migrateMappings.configure {
140-
outputDir.set(project.file("src/main/java"))
141-
}
142-
}
143-
144149
tasks {
145150
processResources {
146151
val buildNumber = project.findProperty("build_number")?.toString() ?: ""
@@ -160,16 +165,24 @@ tasks {
160165
}
161166
}
162167

168+
// Compile launcher with Java 8 for backwards compatibility
169+
getByName<JavaCompile>("compileLauncherJava") {
170+
sourceCompatibility = JavaVersion.VERSION_1_8.toString()
171+
targetCompatibility = JavaVersion.VERSION_1_8.toString()
172+
options.compilerArgs.add("-Xlint:-options")
173+
}
174+
163175
jar {
164176
inputs.property("archivesName", project.base.archivesName.get())
165177

166178
from("LICENSE") {
167179
rename { "${it}_${inputs.properties["archivesName"]}" }
168180
}
169181

170-
// Launch sub project
171-
dependsOn(":launch:compileJava")
172-
from(project(":launch").layout.buildDirectory.dir("classes/java/main"))
182+
// Include launcher classes
183+
val launcher = sourceSets.getByName("launcher")
184+
from(launcher.output.classesDirs)
185+
from(launcher.output.resourcesDir)
173186

174187
manifest {
175188
attributes["Main-Class"] = "meteordevelopment.meteorclient.Main"
@@ -187,7 +200,6 @@ tasks {
187200
}
188201

189202
withType<JavaCompile> {
190-
options.release = 21
191203
options.compilerArgs.add("-Xlint:deprecation")
192204
options.compilerArgs.add("-Xlint:unchecked")
193205
}

launch/build.gradle.kts

Lines changed: 0 additions & 13 deletions
This file was deleted.

settings.gradle.kts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,3 @@ pluginManagement {
1010
}
1111

1212
rootProject.name = "meteor-client"
13-
14-
include("launch")

launch/src/main/java/meteordevelopment/meteorclient/Main.java renamed to src/launcher/java/meteordevelopment/meteorclient/Main.java

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,33 @@ public static void main(String[] args) throws UnsupportedLookAndFeelException, C
1919
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
2020

2121
int option = JOptionPane.showOptionDialog(
22-
null,
23-
"To install Meteor Client you need to put it in your mods folder and run Fabric for latest Minecraft version.",
24-
"Meteor Client",
25-
JOptionPane.YES_NO_OPTION,
26-
JOptionPane.ERROR_MESSAGE,
27-
null,
28-
new String[] { "Open Wiki", "Open Mods Folder" },
29-
null
22+
null,
23+
"To install Meteor Client you need to put it in your mods folder and run Fabric for latest Minecraft version.",
24+
"Meteor Client",
25+
JOptionPane.YES_NO_OPTION,
26+
JOptionPane.ERROR_MESSAGE,
27+
null,
28+
new String[]{"Open Wiki", "Open Mods Folder"},
29+
null
3030
);
3131

3232
switch (option) {
33-
case 0: getOS().open("https://meteorclient.com/faq/installation"); break;
33+
case 0:
34+
getOS().open("https://meteorclient.com/faq/installation");
35+
break;
3436
case 1: {
3537
String path;
3638

3739
switch (getOS()) {
38-
case WINDOWS: path = System.getenv("AppData") + "/.minecraft/mods"; break;
39-
case OSX: path = System.getProperty("user.home") + "/Library/Application Support/minecraft/mods"; break;
40-
default: path = System.getProperty("user.home") + "/.minecraft"; break;
40+
case WINDOWS:
41+
path = System.getenv("AppData") + "/.minecraft/mods";
42+
break;
43+
case OSX:
44+
path = System.getProperty("user.home") + "/Library/Application Support/minecraft/mods";
45+
break;
46+
default:
47+
path = System.getProperty("user.home") + "/.minecraft";
48+
break;
4149
}
4250

4351
File mods = new File(path);
@@ -52,7 +60,7 @@ public static void main(String[] args) throws UnsupportedLookAndFeelException, C
5260
private static OperatingSystem getOS() {
5361
String os = System.getProperty("os.name").toLowerCase(Locale.ROOT);
5462

55-
if (os.contains("linux") || os.contains("unix")) return OperatingSystem.LINUX;
63+
if (os.contains("linux") || os.contains("unix")) return OperatingSystem.LINUX;
5664
if (os.contains("mac")) return OperatingSystem.OSX;
5765
if (os.contains("win")) return OperatingSystem.WINDOWS;
5866

@@ -64,13 +72,13 @@ private enum OperatingSystem {
6472
WINDOWS {
6573
@Override
6674
protected String[] getURLOpenCommand(URL url) {
67-
return new String[] { "rundll32", "url.dll,FileProtocolHandler", url.toString() };
75+
return new String[]{"rundll32", "url.dll,FileProtocolHandler", url.toString()};
6876
}
6977
},
7078
OSX {
7179
@Override
7280
protected String[] getURLOpenCommand(URL url) {
73-
return new String[] { "open", url.toString() };
81+
return new String[]{"open", url.toString()};
7482
}
7583
},
7684
UNKNOWN;
@@ -106,7 +114,7 @@ protected String[] getURLOpenCommand(URL url) {
106114
string = string.replace("file:", "file://");
107115
}
108116

109-
return new String[] { "xdg-open", string };
117+
return new String[]{"xdg-open", string};
110118
}
111119
}
112120
}

0 commit comments

Comments
 (0)