Export rumtime remap classpath to DLI (#277)
* Export rumtime remap classpath for https://github.com/FabricMC/fabric-loader/pull/241 * Fix bad merge
This commit is contained in:
parent
21a9209b86
commit
9917f30518
1 changed files with 33 additions and 0 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue