Commit Graph

374 Commits

Author SHA1 Message Date
eugene yokota b3aae681bf
Merge pull request #6711 from xuwei-k/fix-scala-2-13-warn
fix Scala 2.13 warnings
2021-11-14 21:53:57 -05:00
xuwei-k 535b15b83e fix Scala 2.13 warnings 2021-11-14 22:59:34 +09:00
xuwei-k aa8b1141f8 Update scalatest 2021-11-14 22:03:59 +09:00
Adrien Piquerez 5d5edf2fdc Fix infinte loop when server fails to load with batch client
Shut down server when it is waiting for user input
but stdin has ended.
2021-11-11 22:35:18 +01:00
Samuel CLARENC e3f2371655
Merge branch 'develop' into bspStartTry 2021-07-26 16:12:41 +02:00
Samuel CLARENC 964c1cbaa4 Use java home to launch BSP server 2021-07-26 11:40:53 +02:00
Samuel CLARENC 0be658d299
Merge branch 'develop' into bspStartTry 2021-07-26 09:30:28 +02:00
Samuel CLARENC 5cdec34beb Add a Try around process execution 2021-07-26 09:30:08 +02:00
Adrien Piquerez c31503cca2 Warn when using -sbt-launch-jar 2021-07-22 09:17:22 +02:00
Adrien Piquerez c9ca2d4afa Use `-Dsbt.script` to start sbt server
In order to start the sbt server we must use the sbt script because
it is the only way to load the .sbtopts and the .jvmopts file properly.

To do so the sbt script can pass a -Dsbt.script prop to the java server.
It is used in the NetworkClient to start the server, and it is replicated
in the BuildServerConnection file (.bsp/sbt.json).
2021-07-12 14:20:17 +02:00
Amina Adewusi f12b0baef0 make -client the same as --client
The problem was that -client was different from --client, which
makes for a confusing user experience. So, this change makes
them the same and re-names -client to --java-client. The value
of this is that hopefully -client and --client being the same
feels more logical to users.
2021-05-07 16:07:42 +01:00
Eugene Yokota d0f540aea1 Patch for unidoc 2021-03-08 22:41:19 -05:00
Ondra Pelech 81457e60ec
Give an explanation in case of ServerAlreadyBootingException (#6353)
Give and explanation in case of ServerAlreadyBootingException
2021-03-04 23:21:42 -05:00
Eugene Yokota 22d12f6618 Use nowarn annotation 2021-02-06 22:31:47 -05:00
Sam Halliday 88baafa034 nohup the server from GNU Emacs 2021-01-21 10:51:00 +00:00
Adrien Piquerez fdcfe87dbf
Merge branch 'develop' into client-launch-jar 2021-01-11 13:20:49 +01:00
Eugene Yokota 8f5759e48d Cross build to Scala 2.13 2021-01-10 20:24:05 -05:00
eugene yokota 58d4ef41be
Merge pull request #6181 from smarter/dotty-library-rename
dotty-library is called scala3-library now
2020-12-24 11:53:18 -05:00
João Ferreira 08eaa9fb3b regen contraband 2020-12-21 17:21:54 +00:00
Guillaume Martres 7f3ce50014 dotty-library is called scala3-library now
I though this would help with
https://github.com/lampepfl/dotty/issues/10558 but `sbt repl` still
hides the input after typing a line and pressing enter even after this
change.
2020-11-30 17:08:04 +01:00
Ethan Atkins d167dee7d2 Add --sbt-launch-jar command line arg to client
The intellij bsp integration launches sbt with the launcher and runs
-bsp. This doesn't work if sbt is not on intellij's path. To try and
work around this, we can add an option --sbt-launch-jar that is
recognized by the network client and will make it use the launch jar
rather than the sbt script to launch a new server if needed.
2020-11-27 12:21:21 -08:00
Erlend Hamnaberg 341e09a07e Make it possible to not write the bsp connection file
Made the bspConfig task dependendant on the bspConfig value.
Changed the bspConfig setting to use a attributeKey so we can use it in the server as well.
2020-11-27 20:00:12 +01:00
Ethan Atkins 3f3e219e0f Update ipcsocket
The new version provides an apple silicon arm64 jni implementation of
the ipcsocket api. It also adds a jni implementation for getting the max
socket length which is necessary because jna isn't supported on the
apple arm64 platform yet.
2020-11-25 07:34:11 -08:00
Ethan Atkins 5769f80cbe Use jni if required when running client from xMain
See https://github.com/sbt/sbt/issues/6162#issuecomment-733207878.
2020-11-24 12:35:53 -08:00
Ethan Atkins ab2875e837 Use jni implementation of ipcsocket apis on arm macs
There isn't yet a version of the jna available that works with the new
apple silicon using arm64. To workaround this, we can use the jni
implementation by default on arm64 macs. If the user wants to force the
jni implementation for any supported platform, they can opt in with the
`sbt.ipcsocket.jni` system property and/or by setting the serverUseJni
setting.
2020-11-23 12:31:15 -08:00
Ethan Atkins 62ebe70e5c
Merge branch 'develop' into bsp-watch-fix 2020-11-20 07:51:26 -08:00
Ethan Atkins 2b45183d09 Cleanup user thread task submission
I found this code difficult to reason about so I refactored it so that
it was easier for me to understand.
2020-11-19 18:57:26 -08:00
Ethan Atkins f3b3148c58 Use NetworkClient to implement `sbt -bsp`
Network client already supports the -bsp command (since
65ab7c94d0). This commit reworks the
BspClient.run method so that it delegates to the NetworkClient. The
advantage to doing it this way is that improvements to starting up the
sbt server by the thin client will automatically propagate to the -bsp
command. The way that it is implemented, all of the output generated
during server startup will be redirected to System.err which is useful
for debugging without messing up the bsp protocol, which relies on only
bsp messages being written to System.out.
2020-11-19 16:03:26 -08:00
Ethan Atkins 8137c80782 Fix thin client sbt process startup output
The boot server socket was not working correctly when the sbt server was
started by the thin client. This was because it is necessary for us to
create a ConsoleTerminal in order for System.out and System.err to be
properly forwarded to the clients connected over the boot server socket.
As a result, if you started a server instance of sbt with the thin
client, you wouldn't see any output util you connected to the server.
The fix is to just make sure that we create a console terminal if sbt is
run as a subprocess.
2020-11-18 12:38:44 -08:00
Ethan Atkins 29ce18edec Don't print socket exception on exit
When exiting the thin client when using tcp rather than a domain socket,
an error message is printed about a socket exception.
2020-11-17 16:46:28 -08:00
Adrien Piquerez c71c9c9227 Detach stdio in BSP server 2020-11-16 15:01:42 +01:00
eugene yokota 031d2c6655
Merge pull request #6071 from eatkins/join-thread
Throw timeoutexception in JoinThread
2020-11-06 17:37:24 -05:00
Ethan Atkins 748dfd6e67 Throw timeoutexception in JoinThread
Rather than throwing an interrupted exception if we fail to join a
thread, we should throw a timeout exception.
2020-11-05 11:09:01 -08:00
Ethan Atkins 583ad06aac Remove unnecessary log line in thin client
When a batch command is run with the thin client, it logs an info
message that the command completed. This is unnecessary given that
completion is implied by the success or failure method that follows. It
made the output look a little different in the thin client vs the
console.
2020-11-05 10:13:21 -08:00
Ethan Atkins 65ab7c94d0 Support -bsp in thin client
This refactors the thin client so that it can run the BspClient if
invoked with -bsp.
2020-10-26 14:46:25 -07:00
Ethan Atkins 0d69705e73 Refactor BspClient
This is a refactoring so that the thin client can invoke the bsp client.
2020-10-26 14:46:25 -07:00
Ethan Atkins d255481ade Replace %20 with space in sbt script name
We replace spaces in the sbt script with %20 and we need to replace the
%20s with spaces.
2020-10-25 19:17:13 -07:00
Ethan Atkins c66f31d8a1 Avoid throwing interrupted exception in JoinThread
I saw a stacktrace when exiting sbtn on windows due to an interrupted
exception being thrown during thread joining. We only want to throw this
exception if we didn't successfully join the thread. I also noticed that
we would try to join the thread forever. There was supposed to be a
timelimit so that we would eventually stop blocking even if we were
unable to join the thread. The limit was set but not respected.
2020-10-25 15:14:04 -07:00
Ethan Atkins 69510b126b Parse network client arguments early
With sbtn, the system properties are passed in as regular command
arguments. We need to parse them before we call Terminal.withStreams or
else system properties like -Dsbt.color=false are ignored.
2020-10-24 12:54:14 -07:00
Ethan Atkins a0db985c36 Fix canonical input for network client
It is valid for the thin client input stream to return -1 as an EOF when
the user inputs ctrl+d in canonical mode.
2020-10-21 14:26:21 -07:00
Ethan Atkins 7ad20edbd3
Merge branch 'develop' into evaluate-task-memory-leak 2020-10-21 11:49:01 -07:00
Ethan Atkins d9acfed220 Fix EvaluateTask memory leak
EvaluateTask was holding references to SafeState that could be quite
large. This was reported as #5992. In that project, I ran the `ci` task
and observed the OOM as reported. I took a heap dump prior to OOM and
got the retained size graph from visualvm (which took hours to compute).
The lastEvaluatedState was holding a reference to SafeState that was
1.7GB. The project max heap size was set to 2GB. Instead of using the
lastEvaluatedState, we can just use StandardMain.exchange.withState.
The cached instances of state were used for task cancellation and
completions. While it is possible that early on in booting
StandardMain.exchange.withState could return a null state, in practice
this won't happen because it is set early on during the sbt boot
commands.

After this change, I successfully ran the `ci` task in the #5992 issue
project with the same memory parameters as their ci config.
2020-10-21 08:01:40 -07:00
Ethan Atkins 78620cd902 Manage ansi codes and color codes separately
The ConsoleAppender formatEnabledInEnv field was being used both as an
indicator that ansi codes were supported and that color codes are
enabled. There are cases in which general ansi codes are not supported
but color codes are and these use cases need to be handled separately.
To make things more explicit, this commit adds isColorEnabled and
isAnsiSupported to the Terminal companion object so that we can be more
specific about what the requirements are (general ansi escape codes or
just colors). There are a few cases in ConsoleAppender itself where
formatEnabledInEnv was used to set flags for both color and ansi codes.
When that is the case, we use Terminal.isAnsiSupported because when that
is true, colors should at least work but there are terminals that
support color but not general ansi escape codes.
2020-10-21 08:01:12 -07:00
Ethan Atkins efec7bce31 Check if target is directory before creating
When project/target is a symbolic link, sbt 1.4.0 crashes on startup
because Files.createDirectories will throw a FileAlreadyExistsException.
The fix is to first check if the target directory exists before trying
to create it.
2020-10-13 08:17:22 -07:00
eugene yokota 715bccacd9
Merge pull request #5945 from eatkins/boot-system-in-fix
Fix sbt hangs with invalid build.sbt and --batch
2020-10-06 16:20:54 -04:00
Ethan Atkins 10c549a0b9 Fix sbt hangs with invalid build.sbt and --batch
When sbt is starting up and there is an error with the build loading, we
need to read input from the user to determine to restart the build or
not. What is tricky is that there are potentially two sources of input:
thin clients connected through the boot server socket and the actual sbt
console process. If there are not connected thin clients and no system
console is available, we should return -1 in System.in.read, which will
cause sbt to exit.
2020-10-06 11:43:00 -07:00
Ethan Atkins 08aa64e703 Restore terminal prompt for some dumb terminals
A user reported that no prompt was displayed when they used sbt from the
jEdit console. The reason no prompt was displayed was because
System.console was null which caused the ConsoleChannel to be
initialized with its prompt set to NoPrompt. I don't remember why it was
doing this but this bug seems worse than whatever it was trying to
address.
2020-10-06 09:55:49 -07:00
Ethan Atkins 90f6d77d59 Send exit in network client before shutdown
In the client test, the sbt server would keep open the the client
connection even after it had exited because the client was only shutting
down its side of the connection. Since in the test it wasn't exiting the
jvm, the read side of the connection was still open.
2020-09-28 07:28:24 -07:00
Ethan Atkins 8a23f1e440 Add ability to timeout ClientTest cases
It is possible for the test cases in ClientTest to block indefinitely.
To avoid that, we can instead run them on a background thread and cancel
the thread if that happens.
2020-09-28 07:03:28 -07:00
Ethan Atkins e3731994de Timeout completion requests 2020-09-28 07:03:28 -07:00