-
Notifications
You must be signed in to change notification settings - Fork 929
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support scala 2.13 console in thin client
In order to make the console task work with scala 2.13 and the thin client, we need to provide a way for the scala repl to use an sbt provided jline3 terminal instead of the default terminal typically built by the repl. We also need to put jline 3 higher up in the classloading hierarchy to ensure that two versions of jline 3 are not loaded (which makes it impossible to share the sbt terminal with the scala terminal). One impact of this change is the decoupling of the version of jline-terminal used by the in process scala console and the version of jline-terminal specified by the scala version itself. It is possible to override this by setting the `useScalaReplJLine` flag to true. When that is set, the scala REPL will run in a fully isolated classloader. That will ensure that the versions are consistent. It will, however, for sure break the thin client and may interfere with the embedded shell ui. As part of this work, I also discovered that jline 3 Terminal.getSize is very slow. In jline 2, the terminal attributes were automatically cached with a timeout of, I think, 1 second so it wasn't a big deal to call Terminal.getAttributes. The getSize method in jline 3 is not cached and it shells out to run a tty command. This caused a significant performance regression in sbt because when progress is enabled, we call Terminal.getSize whenever we log any messages. I added caching of getSize at the TerminalImpl level to address this. The timeout is 1 second, which seems responsive enough for most use cases. We could also move the calculation onto a background thread and have it periodically updated, but that seems like overkill.
- Loading branch information
Showing
27 changed files
with
352 additions
and
62 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
21 changes: 21 additions & 0 deletions
21
internal/util-logging/src/main/java/sbt/internal/util/DeprecatedJLine.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,21 @@ | ||
/* | ||
* sbt | ||
* Copyright 2011 - 2018, Lightbend, Inc. | ||
* Copyright 2008 - 2010, Mark Harrah | ||
* Licensed under Apache License 2.0 (see LICENSE) | ||
*/ | ||
|
||
package sbt.internal.util; | ||
|
||
import org.jline.terminal.TerminalBuilder; | ||
|
||
/** | ||
* This exists to a provide a wrapper to TerminalBuilder.setTerminalOverride that will not emit a | ||
* deprecation warning when called from scala. | ||
*/ | ||
public class DeprecatedJLine { | ||
@SuppressWarnings("deprecation") | ||
public static void setTerminalOverride(final org.jline.terminal.Terminal terminal) { | ||
TerminalBuilder.setTerminalOverride(terminal); | ||
} | ||
} |
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
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
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
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
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
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
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
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 @@ | ||
/* | ||
* sbt | ||
* Copyright 2011 - 2018, Lightbend, Inc. | ||
* Copyright 2008 - 2010, Mark Harrah | ||
* Licensed under Apache License 2.0 (see LICENSE) | ||
*/ | ||
|
||
package sbt.internal; | ||
|
||
import java.net.URL; | ||
import java.net.URLClassLoader; | ||
|
||
class JLineLoader extends URLClassLoader { | ||
JLineLoader(final URL[] urls, final ClassLoader parent) { | ||
super(urls, parent); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
final StringBuilder result = new StringBuilder(); | ||
result.append("JLineLoader("); | ||
final URL[] urls = getURLs(); | ||
for (int i = 0; i < urls.length; ++i) { | ||
result.append(urls[i].toString()); | ||
if (i < urls.length - 1) result.append(", "); | ||
} | ||
result.append(")"); | ||
return result.toString(); | ||
} | ||
|
||
static { | ||
registerAsParallelCapable(); | ||
} | ||
} |
Oops, something went wrong.