mirror of
https://github.com/architectury/architectury-loom.git
synced 2026-04-02 13:37:45 -05:00
Use XVFB on Linux CI, allows running the client prod tasks on a headless OS (#1243)
This commit is contained in:
@@ -43,6 +43,16 @@ import net.fabricmc.loom.util.Platform;
|
||||
*/
|
||||
@ApiStatus.Experimental
|
||||
public abstract non-sealed class ClientProductionRunTask extends AbstractProductionRunTask {
|
||||
/**
|
||||
* Whether to use XVFB to run the game, using a virtual framebuffer. This is useful for CI environments that don't have a display server.
|
||||
*
|
||||
* <p>Defaults to true only on Linux and when the "CI" environment variable is set.
|
||||
*
|
||||
* <p>XVFB must be installed, on Debian-based systems you can install it with: <code>apt install -y xvfb</code>
|
||||
*/
|
||||
@Input
|
||||
public abstract Property<Boolean> getUseXVFB();
|
||||
|
||||
// Internal options
|
||||
@Input
|
||||
protected abstract Property<String> getAssetsIndex();
|
||||
@@ -52,6 +62,11 @@ public abstract non-sealed class ClientProductionRunTask extends AbstractProduct
|
||||
|
||||
@Inject
|
||||
public ClientProductionRunTask() {
|
||||
getUseXVFB().convention(getProject().getProviders().environmentVariable("CI")
|
||||
.map(value -> Platform.CURRENT.getOperatingSystem().isLinux())
|
||||
.orElse(false)
|
||||
);
|
||||
|
||||
getAssetsIndex().set(getExtension().getMinecraftVersion()
|
||||
.map(minecraftVersion -> getExtension()
|
||||
.getMinecraftProvider()
|
||||
@@ -71,6 +86,22 @@ public abstract non-sealed class ClientProductionRunTask extends AbstractProduct
|
||||
dependsOn("downloadAssets");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configureCommand(ExecSpec exec) {
|
||||
if (getUseXVFB().get()) {
|
||||
if (!Platform.CURRENT.getOperatingSystem().isLinux()) {
|
||||
throw new UnsupportedOperationException("XVFB is only supported on Linux");
|
||||
}
|
||||
|
||||
exec.commandLine("/usr/bin/xvfb-run");
|
||||
exec.args("-a", getJavaLauncher().get().getExecutablePath());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
super.configureCommand(exec);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configureJvmArgs(ExecSpec exec) {
|
||||
super.configureJvmArgs(exec);
|
||||
|
||||
Reference in New Issue
Block a user