gnodet commented on code in PR #1189:
URL: https://github.com/apache/maven-mvnd/pull/1189#discussion_r1854549764


##########
daemon/src/main/java/org/apache/maven/cli/DaemonMavenInvoker.java:
##########
@@ -18,68 +18,60 @@
  */
 package org.apache.maven.cli;
 
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
 import java.io.OutputStream;
 import java.io.PrintStream;
-import java.io.PrintWriter;
-import java.nio.charset.StandardCharsets;
+import java.util.Optional;
 
+import org.apache.maven.api.cli.InvokerException;
+import org.apache.maven.api.cli.InvokerRequest;
 import org.apache.maven.api.cli.Options;
-import org.apache.maven.api.cli.mvn.MavenInvokerRequest;
-import org.apache.maven.api.cli.mvn.MavenOptions;
-import org.apache.maven.api.services.MavenException;
 import org.apache.maven.cling.invoker.ContainerCapsuleFactory;
 import org.apache.maven.cling.invoker.ProtoLookup;
-import org.apache.maven.cling.invoker.mvn.resident.DefaultResidentMavenInvoker;
+import org.apache.maven.cling.invoker.mvn.resident.ResidentMavenContext;
+import org.apache.maven.cling.invoker.mvn.resident.ResidentMavenInvoker;
+import org.apache.maven.cling.utils.CLIReportingUtils;
+import org.apache.maven.execution.MavenExecutionRequest;
 import org.apache.maven.jline.MessageUtils;
 import org.apache.maven.logging.BuildEventListener;
 import org.apache.maven.logging.LoggingOutputStream;
 import org.jline.terminal.Terminal;
-import org.jline.terminal.impl.ExternalTerminal;
+import org.jline.terminal.TerminalBuilder;
 import org.mvndaemon.mvnd.common.Environment;
 
-public class DaemonMavenInvoker extends DefaultResidentMavenInvoker {
+public class DaemonMavenInvoker extends ResidentMavenInvoker {
     public DaemonMavenInvoker(ProtoLookup protoLookup) {
         super(protoLookup);
     }
 
-    // TODO: this is a hack, and fixes issue in DefaultResidentMavenInvoker 
that does not copy TCCL
-    private ClassLoader tccl;
-
-    protected int doInvoke(LocalContext context) throws Exception {
-        try {
-            if (tccl != null) {
-                context.currentThreadContextClassLoader = tccl;
-                
Thread.currentThread().setContextClassLoader(context.currentThreadContextClassLoader);
-            }
-            return super.doInvoke(context);
-        } finally {
-            this.tccl = context.currentThreadContextClassLoader;
+    @Override
+    protected void createTerminal(ResidentMavenContext context) {
+        MessageUtils.systemInstall(
+                builder -> {
+                    builder.streams(
+                            context.invokerRequest.in().orElseThrow(),
+                            context.invokerRequest.out().orElseThrow());
+                    
builder.systemOutput(TerminalBuilder.SystemOutput.ForcedSysOut);
+                    builder.provider(TerminalBuilder.PROP_PROVIDER_EXEC);
+                    if (context.coloredOutput != null) {
+                        builder.color(context.coloredOutput);
+                    }
+                },
+                terminal -> doConfigureWithTerminal(context, terminal));
+        context.terminal = MessageUtils.getTerminal();
+        context.closeables.add(MessageUtils::systemUninstall);
+        MessageUtils.registerShutdownHook();

Review Comment:
   Maven 3 did not create a `Terminal`, so this was needed. But now it should 
go away.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to