Skip to content

Commit 4b7c7e8

Browse files
committed
Merge branch 'api-12' into api-13
2 parents b544a05 + 06ebd1d commit 4b7c7e8

File tree

3 files changed

+65
-51
lines changed

3 files changed

+65
-51
lines changed

vanilla/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ minecraft {
329329
mainClass("net.minecraftforge.bootstrap.ForgeBootstrap")
330330

331331
// Configure resources
332+
jvmArgs("-Dsponge.dev.root=" + project.rootDir)
332333
jvmArgs("-Dsponge.dev.boot=" + bootLayerConfig.get().resolvedConfiguration.resolvedArtifacts.joinToString(";") { it.file.name })
333334
jvmArgs("-Dsponge.dev.gameShaded=" + gameShadedLibrariesConfig.get().resolvedConfiguration.resolvedArtifacts.joinToString(";") { it.file.name })
334335
}

vanilla/src/devlaunch/java/org/spongepowered/vanilla/devlaunch/SourceSet.java

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import java.util.ArrayList;
3030
import java.util.List;
3131

32-
public record SourceSet(String project, String name, String format) {
32+
public record SourceSet(Path project, String name, String format) {
3333

3434
@Override
3535
public String toString() {
@@ -57,32 +57,34 @@ public static SourceSet identify(Path path) {
5757
}
5858

5959
// from right to left
60-
final List<String> parts = new ArrayList<>();
60+
final List<String> names = new ArrayList<>();
61+
final List<Path> paths = new ArrayList<>();
6162
while (path != null) {
62-
parts.add(path.getFileName().toString());
63-
if (parts.size() >= 5) {
63+
names.add(path.getFileName().toString());
64+
paths.add(path);
65+
if (names.size() >= 5) {
6466
break;
6567
}
6668
path = path.getParent();
6769
}
6870

69-
if (parts.size() >= 4 && (parts.get(0).equals("classes") || parts.get(0).equals("resources"))) {
70-
final String name = parts.get(1);
71-
return new SourceSet(parts.get(3), name.equals("production") ? "main" : name, "IntelliJ");
71+
if (names.size() >= 4 && (names.get(0).equals("classes") || names.get(0).equals("resources"))) {
72+
final String name = names.get(1);
73+
return new SourceSet(paths.get(3), name.equals("production") ? "main" : name, "IntelliJ");
7274
}
7375

74-
if (parts.size() >= 4 && (parts.get(1).equals("resources") || parts.get(1).equals("generated"))) {
75-
return new SourceSet(parts.get(3), parts.get(0), "Gradle");
76+
if (names.size() >= 4 && (names.get(1).equals("resources") || names.get(1).equals("generated"))) {
77+
return new SourceSet(paths.get(3), names.get(0), "Gradle");
7678
}
7779

78-
if (parts.size() >= 5 && parts.get(2).equals("classes")) {
79-
return new SourceSet(parts.get(4), parts.get(0), "Gradle");
80+
if (names.size() >= 5 && names.get(2).equals("classes")) {
81+
return new SourceSet(paths.get(4), names.get(0), "Gradle");
8082
}
8183

82-
if (parts.size() >= 3 && parts.get(1).equals("bin")) {
83-
return new SourceSet(parts.get(2), parts.get(0), "Eclipse");
84+
if (names.size() >= 3 && names.get(1).equals("bin")) {
85+
return new SourceSet(paths.get(2), names.get(0), "Eclipse");
8486
}
8587

86-
return new SourceSet("", parts.get(0), "Unknown");
88+
return new SourceSet(paths.get(0), "?", "Unknown");
8789
}
8890
}

vanilla/src/devlaunch/java/org/spongepowered/vanilla/devlaunch/SpongeDevClasspathFixer.java

Lines changed: 48 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
import java.nio.file.Files;
3030
import java.nio.file.Path;
31+
import java.nio.file.Paths;
3132
import java.util.ArrayList;
3233
import java.util.HashMap;
3334
import java.util.LinkedList;
@@ -51,6 +52,7 @@ public String name() {
5152
*/
5253
@Override
5354
public boolean process(final List<Path[]> classpath) {
55+
final Path spongeRoot = Paths.get(System.getProperty("sponge.dev.root")).toAbsolutePath();
5456
final Set<String> bootLibs = Set.of(System.getProperty("sponge.dev.boot").split(";"));
5557
final Set<String> gameShadedLibs = Set.of(System.getProperty("sponge.dev.gameShaded").split(";"));
5658

@@ -67,46 +69,55 @@ public boolean process(final List<Path[]> classpath) {
6769
return false;
6870
}
6971

70-
final Path path = paths[0];
72+
final Path path = paths[0].toAbsolutePath();
7173
final SourceSet sourceSet = SourceSet.identify(path);
7274
if (sourceSet != null) {
73-
if (DEBUG) {
74-
System.out.println("SourceSet (" + sourceSet + "): " + path);
75-
}
75+
if (sourceSet.project().startsWith(spongeRoot)) {
76+
if (DEBUG) {
77+
System.out.println("Sponge SourceSet (" + sourceSet + "): " + path);
78+
}
7679

77-
switch (sourceSet.project()) {
78-
case "modlauncher-transformers":
79-
bootSourceSets.computeIfAbsent("transformers", k -> new LinkedList<>()).add(path);
80-
break;
81-
case "SpongeAPI":
82-
switch (sourceSet.name()) {
83-
case "ap":
84-
// ignore
85-
break;
86-
case "main":
87-
hasAPISourceSet.set(true);
88-
// no break
89-
default:
90-
spongeImplUnion.add(path);
91-
break;
92-
}
93-
break;
94-
case "Sponge", "vanilla":
95-
switch (sourceSet.name()) {
96-
case "devlaunch":
97-
// ignore
98-
break;
99-
case "applaunch":
100-
bootSourceSets.computeIfAbsent("applaunch", k -> new LinkedList<>()).add(path);
101-
break;
102-
default:
103-
spongeImplUnion.add(path);
104-
break;
105-
}
106-
break;
107-
default:
108-
unknownProjects.computeIfAbsent(sourceSet.project(), k -> new LinkedList<>()).add(path);
109-
break;
80+
final String projectName = spongeRoot.relativize(sourceSet.project()).toString();
81+
switch (projectName) {
82+
case "modlauncher-transformers":
83+
bootSourceSets.computeIfAbsent("transformers", k -> new LinkedList<>()).add(path);
84+
break;
85+
case "SpongeAPI":
86+
switch (sourceSet.name()) {
87+
case "ap":
88+
// ignore
89+
break;
90+
case "main":
91+
hasAPISourceSet.set(true);
92+
// no break
93+
default:
94+
spongeImplUnion.add(path);
95+
break;
96+
}
97+
break;
98+
case "", "vanilla":
99+
switch (sourceSet.name()) {
100+
case "devlaunch":
101+
// ignore
102+
break;
103+
case "applaunch":
104+
bootSourceSets.computeIfAbsent("applaunch", k -> new LinkedList<>()).add(path);
105+
break;
106+
default:
107+
spongeImplUnion.add(path);
108+
break;
109+
}
110+
break;
111+
default:
112+
unknownProjects.computeIfAbsent(projectName, k -> new LinkedList<>()).add(path);
113+
break;
114+
}
115+
} else {
116+
if (DEBUG) {
117+
System.out.println("External SourceSet (" + sourceSet + "): " + path);
118+
}
119+
120+
unknownProjects.computeIfAbsent(sourceSet.project().toString(), k -> new LinkedList<>()).add(path);
110121
}
111122
return true;
112123
}

0 commit comments

Comments
 (0)