Commit Graph

9390 Commits

Author SHA1 Message Date
Eugene Yokota 9c18fb0cf6 Remove tests that are in Zinc repo 2020-07-25 00:23:58 -04:00
Eugene Yokota 7741b9ae2d Zinc 1.4.0-M7 2020-07-24 23:50:54 -04:00
Ethan Atkins eb88d523e0 Update sbt for latest zinc apis 2020-07-22 15:00:56 -07:00
Ethan Atkins 88e0bd678a
Merge pull request #5695 from eatkins/client-system-err
Support System.err in thin client
2020-07-22 14:54:17 -07:00
Ethan Atkins 7b39118214
Merge branch 'develop' into client-system-err 2020-07-22 09:16:10 -07:00
eugene yokota 3908949d73
Merge pull request #5688 from eatkins/client-jline-ui-fixes
Miscellaneous ui/jline fixes
2020-07-21 23:06:44 -04:00
Ethan Atkins 9b332379dd Clear prompt on log messages
Printing a new line was not great ux. You might see something like:

[info] set current project to project (in build file:project)
sbt:project>
[info] new client connected: network-1
sbt:project>

instead of initially

[info] set current project to project (in build file:project)
sbt:project>

and then after the client connects:
[info] set current project to project (in build file:project)
[info] new client connected: network-1
sbt:project>
2020-07-21 13:27:44 -07:00
Ethan Atkins 12112741cb Revert "Unprompt channels during project load"
This reverts commit b1dcf031a5.

I found that b1dcf031a5 had some
unintended consequences that seemed to mess up the prompt state. The
real problem that it was trying to address was that the prompt was being
interleaved with log messages in some scenarios. There was a different
way to fix that in ProgressState that was both simpler and more
reliable.
2020-07-21 13:27:44 -07:00
Ethan Atkins 901c8ee5df Use new history file path for jline3
The jline2 history file format is incompatible with jline3 and jline3
prints a very noisy warning if it detects such a file. History will also
not work with jline3 until you remove or reformat the old file.
2020-07-21 13:27:44 -07:00
Ethan Atkins 761c926944 Catch ClosedChannelException in TaskTraceEvent
sbt would print a stack trace on exit when run with
-Dsbt.task.timings=true. This removes that annoying stack trace.
2020-07-21 13:27:44 -07:00
Ethan Atkins cd26abd656 Print ClearScreenAfterCursor on shutdown
There are scenarios in which sbt can leave behind stray progress lines
after it exits. This attempts to delete them.
2020-07-21 13:27:44 -07:00
Ethan Atkins e82c3405b9 Support System.err in thin client
I noticed that when reloading the build, that certain errors are logged
by sbt to System.err. These were not shown to a thin client because we
weren't forwarding System.err. This change remedies that.

System.err is handled more simply than System.out. We do not put
System.err through the progress state because generally System.err is
tends to be unbuffered. I had hesitated to add System.err to the
Terminal interface at all to give users an escape hatch but I couldn't
get project loading to work well with the thin client without it.
2020-07-21 13:27:32 -07:00
eugene yokota d53ebaa686
Merge pull request #5680 from adpi2/develop
Make the BuildServerReporter stop blinking
2020-07-21 15:35:32 -04:00
eugene yokota e985d77ace
Merge pull request #5690 from eatkins/jline2-raw-mode
Use jline2 for raw mode
2020-07-20 07:23:07 -04:00
eugene yokota 23ade8c650
Merge pull request #5692 from eatkins/task-progress
Clear singleton TaskProgress between runs
2020-07-20 07:19:58 -04:00
adpi2 6c694fb04d Rework BuildServerReporter
Make it stop blinking
Use `reset` field to reduce verbosity
2020-07-20 09:17:12 +02:00
Ethan Atkins f7f25bea81
Merge branch 'develop' into task-progress 2020-07-19 21:42:00 -07:00
Ethan Atkins 8bd43a9fa3
Merge pull request #5689 from eatkins/parallel-stamping
Stamp source files in parallel
2020-07-19 21:41:44 -07:00
Ethan Atkins c6ef4c477d
Merge branch 'develop' into parallel-stamping 2020-07-19 18:31:21 -07:00
Ethan Atkins 28ded81fba
Merge pull request #5521 from eatkins/external-hooks
Restore zinc source file invalidation performance
2020-07-19 18:30:53 -07:00
Ethan Atkins d227b6423f Clear singleton TaskProgress between runs
In db4878c786, TaskProgress became an
object which mostly made things easier to reason about. The one problem
was that it started leaking tasks with every run because the timings map
would accumulate tasks that weren't cleared. To fix this, we can clear
the timings and activeTasksMap in the TaskProgress object in the
afterAllCompleted callback. Some extra null checks needed to be added
since it's possible for the maps to not contain a previously added key
after reset has been called.
2020-07-19 13:08:56 -07:00
Ethan Atkins a19ec581c0 Use jline2 for raw mode
Using the JLine3 implementation of raw mode breaks the scala console for
the console channel.
2020-07-19 12:51:19 -07:00
Ethan Atkins 1b5cbd8ead Stamp source files in parallel
I noticed a modest performance increase could be achieved by stamping
the source files in parallel.
2020-07-19 12:21:25 -07:00
Ethan Atkins e81d459f69 Remove custom ExternalHooks
This is now handled by passing a custom instance of ReadStamps to
CompileOptions instead.
2020-07-19 12:16:37 -07:00
Ethan Atkins 329d989e73 Use sbt source file stamps in zinc
This fixes the nio/external-hooks test and also restores the performance
of the benchmarks for the latest sbt version in
https://github.com/eatkins/scala-build-watch-performance which had
regressed when the custom ExternalHooks were disabled in
7c4b01d9f7.

The main change is that it changes the ReadStamps object that is passed
into the compiler options to one that uses the unmanagedFileStampCache
and managedFileStampCache for source files and falls back to the default
stamper otherwise. This improves the performance quite significantly
since we only hash the files once. It also makes it so that the analysis
file will contain the source file stamps of the files when compilation
began, rather than when compilation ended. That is what
nio/external-hooks was testing. In the real world what could happen was
that one modified a source file during compilation but then no
incremental re-compilation would occur because after the initial
compilation completed, zinc wrote the stamp of the modified source file
in the analysis file even though it may have actually compiled a
different version of the source file.
2020-07-19 12:16:37 -07:00
eugene yokota b678d2115f
Merge pull request #5687 from eatkins/rejected-execution
Handle closed executor in network channel flush
2020-07-19 13:47:15 -04:00
Ethan Atkins 4acf3d14c2 Handle closed executor in network channel flush
I noticed some RejectedExecutionExceptions in travis failures of
ClientTest. This could happen if we try to write output to the
network channel after it has been closed. To avoid this problem, we can
catch RejectedExecutionExceptions and do an immediate flush if the
executor has been shutdown.
2020-07-19 10:09:54 -07:00
eugene yokota 8b73d2bc2a
Merge pull request #5674 from adpi2/fix/connection-details
Specify full java path in BSP connection details
2020-07-13 14:27:31 -04:00
adpi2 2c0d09dfb3 Specify full java path in BSP connection details
Use System properties to add java path and classpath to BSP connection details
2020-07-13 13:13:54 +02:00
eugene yokota eceb1d896e
Merge pull request #5672 from eatkins/xmain-configuration-fix
Add improved classloader construction short circuit
2020-07-12 23:58:16 -04:00
Ethan Atkins 464ea1b97e Add improved classloader construction short circuit
In order for sbt to function well, it needs the test interface, jansi
and forked jline jars provided by a classloader that is parent to all
other sbt classloaders. To do this for just the test interface jar, I
just checked if the top loader in the app configuration had the correct
name. Now that there are three jars, this is more complicated so I
updated the launcher to create a top loader with the method getEarlyJars
implemented and returning the three needed jars. This is a much more
scalable design.

If sbt is entered with a configuration that does not have a top loader
with the getEarlyJars method defined, then we just fall back on
constructing the default layered classlaoder from the configuration
classpath.

The motivation for this change is that I discovered that sbt immediately
crashed when I tried to run a non-snapshot version. After this change, I
verified that both snapshot and non-snapshot versions of the latest sbt
code could load with both an obsolete and up-to-date launcher.
2020-07-12 17:49:01 -07:00
eugene yokota 6110734383
Merge pull request #5673 from eatkins/client-watch-fixes
UI fixes for remote client in watch
2020-07-12 00:55:03 -04:00
eugene yokota ab5e57afb1
Merge pull request #5671 from eatkins/upgrade-to-jline3
Upgrade to jline3
2020-07-11 20:35:10 -04:00
Ethan Atkins baa96be6dc Use unprompt in watch to better manage ui state
The unprompt method will actually kill the ui thread if its running. If
we don't to this, we can get into a weird state where after watch is
exited by <enter>, the ask user thread spins up but before it can print
the prompt, the terminal prompt is changed to Running, which has an
empty prompt. The end result is that jline3 never displays the prompt
even though the line reader is active and reading bytes. When the user
typed <enter> a prompt would appear. They also could input a command and
it would run but it wasn't obvious what would happen since the prompt
was missing.
2020-07-10 14:26:16 -07:00
Ethan Atkins 3ddc7bd744 Remove unneeded println
While I'm sure this was added for a reason, it presently is creating
unnecessary and ugly newlines to the console during `~`.
2020-07-10 14:26:14 -07:00
Ethan Atkins 9dc3c6b17f Use terminal printstream in CheckBuildSources
The build source check is evaluated at times when we can't be completely
sure that global logger is pointing at the terminal that initiated the
reload (which may be a passive watch client). To work around this, we
can inspect the exec to determine which terminal initiated the check and
write any output directly to that terminal.
2020-07-10 13:37:54 -07:00
Ethan Atkins 25e83d8fec Add Terminal.withRawOutput api
In the scala console, it's essential that we not process the bytes that
are written to the terminal by jline.
2020-07-10 13:37:54 -07:00
Ethan Atkins bc4fe0a31a Cross build collectionProj 2020-07-10 13:37:54 -07:00
Ethan Atkins e1c9ed5a55 Buffer terminal lines
It is useful to store a buffer of the lines written to each terminal. We
can use those lines to replay the terminal log lines to a different
client. This is particularly nice when a remote client connects to sbt
while it's booting. We can show the remote client all the lines
displayed by the console prior to the client connecting.
2020-07-10 13:37:54 -07:00
Ethan Atkins 6faf460a1b Add loop to SelectMainClass
Rather than exiting when the user enters an invalid line, we can
reprompt them.
2020-07-10 13:37:54 -07:00
Ethan Atkins fb803a0994 Return correct path in native executable task
Bonus: throw an error if native building fails
2020-07-10 13:37:54 -07:00
Ethan Atkins 2ecf5967ee Upgrade LineReader to JLine3
This commit upgrades sbt to using jline3. The advantage to jline3 is
that it has a significantly better tab completion engine that is more
similar to what you get from zsh or fish.

The diff is bigger than I'd hoped because there are a number of
behaviors that are different in jline3 vs jline2 in how the library
consumes input streams and implements various features. I also was
unable to remove jline2 because we need it for older versions of the
scala console to work correctly with the thin client. As a result, the
changes are largely additive.

A good amount of this commit was in adding more protocol so that the
remote client can forward its jline3 terminal information to the server.

There were a number of minor changes that I made that either fixed
outstanding ui bugs from #5620 or regressions due to differences between
jline3 and jline2.

The number one thing that caused problems is that the jline3 LineReader
insists on using a NonBlockingInputStream. The implementation ofo
NonBlockingInputStream seems buggy. Moreover, sbt internally uses a
non blocking input stream for system in so jline is adding non blocking
to an already non blocking stream, which is frustrating.

A long term solution might be to consider insourcing LineReader.java
from jline3 and just adapting it to use an sbt terminal rather than
fighting with the jline3 api. This would also have the advantage of not
conflicting with other versions of jline3. Even if we don't, we may want to
shade jline3 if that is possible.
2020-07-10 13:37:53 -07:00
Ethan Atkins ed4d40d3e2 Move ProgressState into its own file
This didn't really belong in ConsoleAppender.scala anymore.
2020-07-10 13:36:32 -07:00
Ethan Atkins b6354656b1 Fix copied scaladoc 2020-07-10 13:36:01 -07:00
Ethan Atkins dea7bdfa89 Don't start an ask user thread for dead console
If there is no system console available, then there is no point in
making an ask user thread. An ask user thread can only be created when
the terminal prompt is in the Prompt.Running or Prompt.Loading state.
The console channel will now set itself to be in the Prompt.NoPrompt
state if it detects that there is no System.console available.

The motivation for this change is that jline was printing a lot of extra
text during scripted and server tests. Whenever a jline3 linereader is
closed, it prints a newline so the logs were filled with unnecessary
newlines.
2020-07-10 13:35:12 -07:00
Ethan Atkins 366c49a764 Aggregate watch events
It is possible for sbt to get into a weird state when in a continuous
build when the auto reload feature is on and a source file and a build
file are changed in a small window of time. If sbt detects the source
file first, it will start running the command but then it will
autoreload when it runs the command because of the build file change.
This causes the watch to get into a broken state because it is necessary
to completely restart the watch after sbt exits.

To fix this, we can aggregate the detected events in a 100ms window. The
idea is to handle bursts of file events so we poll in 5ms increments and
as soon as no events are detected, we trigger a build.
2020-07-10 13:04:08 -07:00
Ethan Atkins eb688c9ecd Buffer output to the remote client
Remote clients sometimes flicker when updating progress. This is especially
noticeable when there are two clients and one of them is running a command,
the other will tend to have some visible flickering and character ghosting.
As an experiment, I buffered calls to flush in the NetworkChannel output
stream and the artifacts went away.
2020-07-09 17:17:15 -07:00
Ethan Atkins 6aa1333adb Don't log systemOut messages in jsonRpcNotify
Whatever debugging utility these may have is not worth spamming the task
logs with these.
2020-07-09 16:54:29 -07:00
Ethan Atkins d826e93ddf Only trigger reload if sources have changed
Running a `~` command in a local build off the latest develop branch
will cause the build to reload even if the build sources were only
touched and not actually modified.
2020-07-09 16:54:29 -07:00
Ethan Atkins de1423d662 Clarify boolean flag
I found this difficult to read.
2020-07-09 16:54:29 -07:00