aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/net/fabricmc/loom
diff options
context:
space:
mode:
authormodmuss50 <modmuss50@gmail.com>2020-09-26 18:46:35 +0100
committerGitHub <noreply@github.com>2020-09-26 18:46:35 +0100
commit9917f30518b61183c95451a502689300f12523c5 (patch)
tree1fc7bd7243befb22bd3b554168a78893a2a9984b /src/main/java/net/fabricmc/loom
parent21a9209b86a3fff33cc9ada6377396a745215160 (diff)
downloadarchitectury-loom-9917f30518b61183c95451a502689300f12523c5.tar.gz
architectury-loom-9917f30518b61183c95451a502689300f12523c5.tar.bz2
architectury-loom-9917f30518b61183c95451a502689300f12523c5.zip
Export rumtime remap classpath to DLI (#277)
* Export rumtime remap classpath for https://github.com/FabricMC/fabric-loader/pull/241 * Fix bad merge
Diffstat (limited to 'src/main/java/net/fabricmc/loom')
-rw-r--r--src/main/java/net/fabricmc/loom/providers/LaunchProvider.java33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/main/java/net/fabricmc/loom/providers/LaunchProvider.java b/src/main/java/net/fabricmc/loom/providers/LaunchProvider.java
index 2bc52bd2..8c001d6b 100644
--- a/src/main/java/net/fabricmc/loom/providers/LaunchProvider.java
+++ b/src/main/java/net/fabricmc/loom/providers/LaunchProvider.java
@@ -36,12 +36,14 @@ import java.util.List;
import java.util.Map;
import java.util.StringJoiner;
import java.util.function.Consumer;
+import java.util.stream.Collectors;
import org.apache.commons.io.FileUtils;
import org.gradle.api.Project;
import net.fabricmc.loom.util.Constants;
import net.fabricmc.loom.util.DependencyProvider;
+import net.fabricmc.loom.util.RemappedConfigurationEntry;
public class LaunchProvider extends DependencyProvider {
public LaunchProvider(Project project) {
@@ -52,6 +54,7 @@ public class LaunchProvider extends DependencyProvider {
public void provide(DependencyInfo dependency, Consumer<Runnable> postPopulationScheduler) throws IOException {
final LaunchConfig launchConfig = new LaunchConfig()
.property("fabric.development", "true")
+ .property("fabric.remapClasspathFile", getRemapClasspathFile().getAbsolutePath())
.property("log4j.configurationFile", getLog4jConfigFile().getAbsolutePath())
.property("client", "java.library.path", getExtension().getNativesDirectory().getAbsolutePath())
@@ -75,12 +78,18 @@ public class LaunchProvider extends DependencyProvider {
addDependency(Constants.Dependencies.DEV_LAUNCH_INJECTOR + Constants.Dependencies.Versions.DEV_LAUNCH_INJECTOR, "runtimeOnly");
addDependency(Constants.Dependencies.TERMINAL_CONSOLE_APPENDER + Constants.Dependencies.Versions.TERMINAL_CONSOLE_APPENDER, "runtimeOnly");
addDependency(Constants.Dependencies.JETBRAINS_ANNOTATIONS + Constants.Dependencies.Versions.JETBRAINS_ANNOTATIONS, "compileOnly");
+
+ postPopulationScheduler.accept(this::writeRemapClassPath);
}
private File getLog4jConfigFile() {
return new File(getExtension().getDevLauncherConfig().getParentFile(), "log4j.xml");
}
+ private File getRemapClasspathFile() {
+ return new File(getExtension().getDevLauncherConfig().getParentFile(), "remapClasspath.txt");
+ }
+
private void writeLog4jConfig() {
try (InputStream is = LaunchProvider.class.getClassLoader().getResourceAsStream("log4j2.fabric.xml")) {
Files.deleteIfExists(getLog4jConfigFile().toPath());
@@ -90,6 +99,30 @@ public class LaunchProvider extends DependencyProvider {
}
}
+ private void writeRemapClassPath() {
+ List<String> inputConfigurations = new ArrayList<>();
+ inputConfigurations.add(Constants.Configurations.MINECRAFT_DEPENDENCIES);
+ inputConfigurations.addAll(Constants.MOD_COMPILE_ENTRIES.stream().map(RemappedConfigurationEntry::getSourceConfiguration).collect(Collectors.toList()));
+
+ List<File> remapClasspath = new ArrayList<>();
+
+ for (String inputConfiguration : inputConfigurations) {
+ remapClasspath.addAll(getProject().getConfigurations().getByName(inputConfiguration).getFiles());
+ }
+
+ remapClasspath.add(getExtension().getMinecraftMappedProvider().getIntermediaryJar());
+
+ String str = remapClasspath.stream()
+ .map(File::getAbsolutePath)
+ .collect(Collectors.joining(File.pathSeparator));
+
+ try {
+ Files.write(getRemapClasspathFile().toPath(), str.getBytes(StandardCharsets.UTF_8));
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to generate remap classpath", e);
+ }
+ }
+
@Override
public String getTargetConfig() {
return Constants.Configurations.MINECRAFT_NAMED;