diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index b1923d2d9..9a14cffe5 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -12,7 +12,7 @@ mapping-io = "0.5.1" lorenz-tiny = "4.0.2" mercury = "0.4.1" kotlinx-metadata = "0.9.0" -loom-native = "0.1.1" +loom-native = "0.2.0" # Plugins spotless = "6.25.0" diff --git a/src/main/java/net/fabricmc/loom/util/ExceptionUtil.java b/src/main/java/net/fabricmc/loom/util/ExceptionUtil.java index 8f9422600..2f6d91ea8 100644 --- a/src/main/java/net/fabricmc/loom/util/ExceptionUtil.java +++ b/src/main/java/net/fabricmc/loom/util/ExceptionUtil.java @@ -32,10 +32,15 @@ import java.util.function.BiFunction; import org.gradle.api.Project; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import net.fabricmc.loom.nativeplatform.LoomNativePlatform; +import net.fabricmc.loom.nativeplatform.LoomNativePlatformException; public final class ExceptionUtil { + private static final Logger LOGGER = LoggerFactory.getLogger(ExceptionUtil.class); + /** * Creates a descriptive user-facing wrapper exception for an underlying cause. * @@ -74,7 +79,14 @@ private static void printFileLocks(String filename, Project project) { return; } - final List processes = LoomNativePlatform.getProcessesWithLockOn(path); + final List processes; + + try { + processes = LoomNativePlatform.getProcessesWithLockOn(path); + } catch (LoomNativePlatformException e) { + LOGGER.error("{}, Failed to query processes holding a lock on {}", e.getMessage(), path); + return; + } if (processes.isEmpty()) { return; diff --git a/src/main/java/net/fabricmc/loom/util/ProcessUtil.java b/src/main/java/net/fabricmc/loom/util/ProcessUtil.java index 93f8e1e37..8b36e549f 100644 --- a/src/main/java/net/fabricmc/loom/util/ProcessUtil.java +++ b/src/main/java/net/fabricmc/loom/util/ProcessUtil.java @@ -31,11 +31,15 @@ import org.gradle.api.Project; import org.gradle.api.logging.LogLevel; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import net.fabricmc.loom.nativeplatform.LoomNativePlatform; +import net.fabricmc.loom.nativeplatform.LoomNativePlatformException; public record ProcessUtil(LogLevel logLevel) { private static final String EXPLORER_COMMAND = "C:\\Windows\\explorer.exe"; + private static final Logger LOGGER = LoggerFactory.getLogger(ProcessUtil.class); public static ProcessUtil create(Project project) { return new ProcessUtil(project.getGradle().getStartParameter().getLogLevel()); @@ -92,7 +96,14 @@ private Optional getWindowTitles(ProcessHandle processHandle) { return Optional.empty(); } - List titles = LoomNativePlatform.getWindowTitlesForPid(processHandle.pid()); + List titles; + + try { + titles = LoomNativePlatform.getWindowTitlesForPid(processHandle.pid()); + } catch (LoomNativePlatformException e) { + LOGGER.error("{}, Failed to query window title for pid {}", e.getMessage(), processHandle.pid()); + return Optional.empty(); + } if (titles.isEmpty()) { return Optional.empty();