-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1f72e56
commit 0846f6a
Showing
6 changed files
with
61 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
plugins { | ||
id 'java' | ||
id 'java-library' | ||
} | ||
|
||
dependencies { | ||
implementation('org.junit.platform:junit-platform-launcher:1.9.3') | ||
implementation('cpw.mods:bootstraplauncher:1.1.8-test') | ||
// BSL should not be exposed and the actual version should be provided by the neo dep | ||
compileOnly("cpw.mods:bootstraplauncher:${project.bootstraplauncher_version}") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 7 additions & 12 deletions
19
junit/src/main/java/net/neoforged/fml/junit/JUnitService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
junit/src/main/java/net/neoforged/fml/junit/LaunchWrapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright (c) Forge Development LLC and contributors | ||
* SPDX-License-Identifier: LGPL-2.1-only | ||
*/ | ||
|
||
package net.neoforged.fml.junit; | ||
|
||
import cpw.mods.bootstraplauncher.BootstrapLauncher; | ||
|
||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
|
||
public class LaunchWrapper { | ||
private static ClassLoader transformingCL; | ||
|
||
public static synchronized ClassLoader getTransformingLoader() { | ||
if (transformingCL != null) return transformingCL; | ||
final var oldLoader = Thread.currentThread().getContextClassLoader(); | ||
|
||
try { | ||
final String[] args = Files.readAllLines(Path.of(System.getProperty("fml.junit.argsfile", "mainargs.txt"))).toArray(String[]::new); | ||
BootstrapLauncher.main(args); | ||
|
||
transformingCL = Thread.currentThread().getContextClassLoader(); | ||
} catch (Exception exception) { | ||
System.err.println("Failed to start Minecraft: " + exception); | ||
throw new RuntimeException(exception); | ||
} finally { | ||
Thread.currentThread().setContextClassLoader(oldLoader); | ||
} | ||
|
||
return transformingCL; | ||
} | ||
} |
7 changes: 6 additions & 1 deletion
7
loader/src/main/java/net/neoforged/fml/loading/targets/JUnitDevLaunchTarget.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 6 additions & 1 deletion
7
loader/src/main/java/net/neoforged/fml/loading/targets/JUnitUserDevLaunchTarget.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters