@@ -55,26 +55,40 @@ public static synchronized JsonObject read() throws Exception {
5555 Path javaExecutable = Path .of (System .getProperty ("java.home" ), "bin" , "java" );
5656 if (!Files .isExecutable (javaExecutable )) javaExecutable = javaExecutable .resolveSibling ("java.exe" );
5757 Path log = evidence .resolve ("forge-resources.log" );
58- Process process = new ProcessBuilder (javaExecutable .toString (), "-XX:ActiveProcessorCount=4" , "-Xmx512m" ,
59- "--add-opens" , "java.base/java.lang.invoke=ALL-UNNAMED" , "-cp" , classpath ,
60- NativePackResourceProof .class .getName (), Path .of ("build/resources/main" ).toAbsolutePath ().toString (),
61- evidence .toString ()).directory (evidence .toFile ())
62- .redirectErrorStream (true ).redirectOutput (log .toFile ()).start ();
58+ Process process = proofProcess (javaExecutable , classpath ,
59+ Path .of ("build/resources/main" ).toAbsolutePath (), evidence , log ).start ();
6360 if (!process .waitFor (90 , TimeUnit .SECONDS )) {
6461 process .destroyForcibly ().waitFor ();
6562 throw new AssertionError ("Native Forge resource proof timed out: " + log );
6663 }
6764 String output = Files .readString (log );
6865 if (process .exitValue () != 0 ) throw new AssertionError ("Native Forge resource proof failed: " + log + "\n " + output );
66+ requireCleanOutput (output , log );
67+ receipt = JsonParser .parseString (Files .readString (evidence .resolve ("receipt.json" ))).getAsJsonObject ();
68+ return receipt .deepCopy ();
69+ }
70+
71+ static ProcessBuilder proofProcess (Path javaExecutable , String classpath , Path resources , Path evidence , Path log ) {
72+ // The child has redirected output, not an interactive terminal. Disable only JLine, never diagnostics.
73+ ProcessBuilder builder = new ProcessBuilder (javaExecutable .toString (), "-XX:ActiveProcessorCount=4" , "-Xmx512m" ,
74+ "-Dterminal.jline=false" , "--add-opens" , "java.base/java.lang.invoke=ALL-UNNAMED" , "-cp" , classpath ,
75+ NativePackResourceProof .class .getName (), resources .toString (), evidence .toString ())
76+ .directory (evidence .toFile ()).redirectErrorStream (true ).redirectOutput (log .toFile ());
77+ builder .environment ().put ("TERM" , "dumb" );
78+ return builder ;
79+ }
80+
81+ static void requireCleanOutput (String output , Path log ) {
6982 if (java .util .regex .Pattern .compile ("(?m)(?:\\ [[^\\ r\\ n]*\\ b(?:WARN|ERROR|FATAL)\\ b[^\\ r\\ n]*\\ ]|\\ bmain (?:WARN|ERROR|FATAL)\\ b)" )
7083 .matcher (output ).find ()) {
7184 throw new AssertionError ("Native Forge resource diagnostic in " + log + "\n " + output );
7285 }
73- receipt = JsonParser .parseString (Files .readString (evidence .resolve ("receipt.json" ))).getAsJsonObject ();
74- return receipt .deepCopy ();
7586 }
7687
7788 public static void main (String [] args ) throws Exception {
89+ if (!"false" .equals (System .getProperty ("terminal.jline" ))) {
90+ throw new AssertionError ("The redirected proof child must not initialise an interactive terminal" );
91+ }
7892 SharedConstants .tryDetectVersion ();
7993 Bootstrap .bootStrap ();
8094 Path resources = Path .of (args [0 ]);
@@ -105,6 +119,7 @@ public static void main(String[] args) throws Exception {
105119 var logger = (org .apache .logging .log4j .core .Logger )LogManager .getRootLogger ();
106120 logger .addAppender (appender );
107121 JsonObject result = new JsonObject ();
122+ result .addProperty ("interactiveTerminalDisabled" , true );
108123 JsonArray dependencies = new JsonArray ();
109124 for (var dependency : mod .getModInfos ().getFirst ().getDependencies ()) {
110125 JsonObject entry = new JsonObject ();
@@ -191,6 +206,6 @@ public static void main(String[] args) throws Exception {
191206 result .add ("warningsAndErrors" , messages );
192207 Files .writeString (evidence .resolve ("receipt.json" ), result .toString (), StandardCharsets .UTF_8 );
193208 if (!diagnostics .isEmpty ()) throw new AssertionError ("Native Forge resource diagnostics: " + diagnostics );
194- System .out .println ("BASESTEAM_NATIVE_PACK_RESOURCES_PASS " + result );
209+ System .out .println ("BASEPOWER_NATIVE_PACK_RESOURCES_PASS " + result );
195210 }
196211}
0 commit comments