Commit Graph

2635 Commits

Author SHA1 Message Date
eugene yokota 4592493617
Merge pull request #5549 from adpi2/issue/json-response
Prevent more than one response per json RPC request
2020-05-12 22:07:11 -04:00
Adrien Piquerez c221f57812 code review 2020-05-12 19:20:43 +02:00
Adrien Piquerez 8df754eeb1 rename publish to either respond or notify 2020-05-12 16:26:33 +02:00
Adrien Piquerez 255a0a6ea6 send response to the source channel only 2020-05-12 14:44:10 +02:00
Adrien Piquerez df293fbfd5 prevent multiple response to a single request 2020-05-12 10:38:47 +02:00
Adrien Piquerez 781584d137 id is mandatory in json rpc responses 2020-05-11 16:51:34 +02:00
Brice Jaglin 331ca6ec9b enable ServiceLoader discovery across classloader layers
java.util.ServiceLoader uses findResources(), which was not
overriden in ReverseLookupClassLoader, causing resources available
in the descendant classloader not to be discovered when a service
loader instance was using the top classloader.
2020-05-08 12:41:44 +02:00
eugene yokota f5eae27c69
Merge pull request #5531 from eatkins/optimize-task-progress
Optimize task progress performance
2020-05-06 23:07:39 -04:00
eugene yokota d2fa0f100e
Merge pull request #5533 from eatkins/ivy-xml
Make IvyXml.writeFiles private[sbt]
2020-05-06 11:46:29 -04:00
Ethan Atkins e3e53df797 Make IvyXml.writeFiles private[sbt]
I got confused an changed the access for the wrong method to support
https://github.com/sbt/sbt/pull/5364.

Partially reverts 5c55393f1b.
2020-05-06 07:43:22 -07:00
Ethan Atkins 9b2bbdd4cc Report progress on background thread
Having the progress reports directly generated in beforeWork delays the
task from being submitted to the executor. This commit moves all of the
reporting onto the background thread to avoid these delays since
progress is less important than task evaluation.
2020-05-05 21:28:08 -07:00
Ethan Atkins f4c11a63ab Re-implement meta build source checking
The old implementation of checkBuildSources can easily take 20ms to run
when called in MainLoop.processCommand. It is rarely faster than 4-5ms.
To reduce this overhead, I stopped using the checkBuildSources task in
processCommand. Instead, I manually cache the build source hashes in a
global state variable and add a file monitor that invalidate the entire
set of source hashes if any changes are detected. This could probably be
more efficient, but I figure that build sources change infrequently
enough that it's fine to just invalidate the entire list of source
hashes.

Because the CheckBuildSources instance is already watching the meta
build, I reworked Continuous to use that FileTreeRepository for the
build sources if it is available.

Bonus: fixes https://github.com/sbt/sbt/issues/5482
2020-05-05 21:26:04 -07:00
Ethan Atkins b829ac9796 Remove FileManagement
This was unused.
2020-05-05 21:25:56 -07:00
Ethan Atkins 0a06bfe2d5 Optimize TaskProgress.containsSkipTasks
I was surprised to find this method in a flamegraph* so I optimized it.
TaskProgress was actually on the hotpath of task evaluation so every
single task was slower to be enqueued with the CompletionService. After
this change, containsSkipTasks dropped out of the flamegraph.

*The flamegraph was for a compile loop where sbt constantly modified a
single source file and re-compiled it. The containsSkipTasks method
appeared in over 2% of the method calls.
2020-05-05 21:04:09 -07:00
frosforever d1cf37b2ca Update Tests.Group to be bin compat by manually implementing case class methods 2020-05-04 09:29:31 -04:00
frosforever 18d51eac58 Add tags to inProccess group as well 2020-05-04 09:29:31 -04:00
frosforever b2942f6321 Add user defined tags to Tests.Group 2020-05-04 09:29:31 -04:00
Ethan Atkins a1ea5b72f3 Support capital letter options in doLoadFailed
Also display invalid response character.
2020-05-01 13:12:37 -07:00
Ethan Atkins 73235d12e0 Switch to lower case for some messages
There is push to move away from complete sentences in warnings.
2020-05-01 13:12:13 -07:00
Ethan Atkins 24d4b3549b Set default supershell blank zone to 1
We do not need a large blank zone with the virtual system.out.
2020-05-01 12:35:43 -07:00
Ethan Atkins 5c42c20cdc Simplify setting dumbTerm variable 2020-05-01 12:35:43 -07:00
Ethan Atkins 58822cc3f5 Add virtual System.out for supershell
In order to make supershell work with println, this commit introduces a
virtual System.out to sbt. While sbt is running, we override the default
java.lang.System.out, java.lang.System.in, scala.Console.out and
scala.Console.in (unless the property `sbt.io.virtual` is set to
something other than true). When using virtual io, we buffer all of the
bytes that are written to System.out and Console.out until flush is
called. When flushing the output, we check if there are any progress
lines. If so, we interleave them with the new lines to print.

The flushing happens on a background thread so it should hopefully not
impede task progress.

This commit also adds logic for handling progress when the cursor is not
all the way to the left. We now track all of the bytes that have been
written since the last new line. Supershell will then calculate the
cursor position from those bytes* and move the cursor back to the
correct position. The motivation for this was to make the run command
work with supershell even when multiple main classes were specified.

* This might not be completely reliable if the string contains ansi
cursor movement characters.
2020-05-01 12:35:43 -07:00
Ethan Atkins a0012bab75 Apply minimum task progress length threshold
To reduce the noise of supershell, this commit imposes a 10 millisecond
minimum duration before a task will appear in the supershell lines.
2020-05-01 12:35:43 -07:00
Ethan Atkins 9218d3c087 Redraw command prompt after network command
Presently if a server command comes in while in the shell, the client
output can appear on the same line as the command prompt and the command
prompt will not appear again until the user hits enter. This is a
confusing ux. For example, if I start an sbt server and type
the partial command "comp" and then start up a client and run the clean
command followed by a compile, the output looks like:

[info] sbt server started at local:///Users/ethanatkins/.sbt/1.0/server/51cfad3281b3a8a1820a/sock
sbt:scala-compile> comp[info] new client connected: network-1
[success] Total time: 0 s, completed Dec 12, 2019, 7:23:24 PM
[success] Total time: 0 s, completed Dec 12, 2019, 7:23:27 PM
[success] Total time: 2 s, completed Dec 12, 2019, 7:23:31 PM

Now, if I type "ile\n", I get:
[info] sbt server started at local:///Users/ethanatkins/.sbt/1.0/server/51cfad3281b3a8a1820a/sock
ile
[success] Total time: 0 s, completed Dec 12, 2019, 7:23:34 PM
sbt:scala-compile>

Following the same set of inputs after this change, I get:
[info] sbt server started at local:///Users/ethanatkins/.sbt/1.0/server/51cfad3281b3a8a1820a/sock
sbt:scala-compile> comp
[info] new client connected: network-1
[success] Total time: 0 s, completed Dec 12, 2019, 7:25:58 PM
sbt:scala-compile> comp
[success] Total time: 0 s, completed Dec 12, 2019, 7:26:14 PM
sbt:scala-compile> comp
[success] Total time: 1 s, completed Dec 12, 2019, 7:26:17 PM
sbt:scala-compile> compile
[success] Total time: 0 s, completed Dec 12, 2019, 7:26:19 PM
sbt:scala-compile>

To implement this change, I added the redraw() method to LineReader
which is a wrapper around ConsoleReader.drawLine; ConsoleReader.flush().
We invoke LineReader.redraw whenever the ConsoleChannel receives a
ConsolePromptEvent and there is a running thread.

To prevent log lines from being appended to the prompt line, in the
CommandExchange we print a newline character whenever a new command is
received from the network or a network client connects and we believe
that there is an active prompt.
2020-05-01 12:35:43 -07:00
Ethan Atkins 08091d64c1 Log server commands
Prior to this change, if a network command came in, it would run in the
background with no real feedback in the server ui. Prior to this change,
running compile from the thin client would look like:

sbt:scala-compile>
[success] Total time: 1 s, completed Dec 12, 2019, 7:24:43 PM
sbt:scala-compile>

Now it looks like:
sbt:scala-compile>
[info] Running remote command: compile
[success] Total time: 1 s, completed Dec 12, 2019, 7:26:17 PM
sbt:scala-compile>
2020-05-01 12:35:43 -07:00
Ethan Atkins 5afc0f0fdf Don't require newline for load failed commands
It's a bit annoying to have to hit enter here.

Also, this should fix https://github.com/sbt/sbt/issues/5162 because if
there is no System.in attached, the read will return -1 which will cause
sbt to quit.
2020-05-01 12:35:43 -07:00
Ethan Atkins c7b52203a0 Don't require newlines for main classes
There typically are fewer than 10 main classes in a project so allow the
user to just input a single digit in those cases. Otherwise fallback to
a line reader.
2020-05-01 12:35:43 -07:00
Ethan Atkins 44ef718448 Improve run command warning
When the user inputs `run` or `runMain` we shouldn't print the warning
about multiple classes because in the case of run they already will be
prompted to select the classes and in the case of runMain, they are
already required to specify the class name.

Bonus:
 * improve punctuation
 * add clear screen to selector dialogue
 * print selector dialogue in one call to println -- this should prevent
   the possibility of messages from other threads being interlaced with
   the dialogue
2020-05-01 12:35:43 -07:00
Ethan Atkins 7902ec3b7d Add Terminal abstraction
This commit aims to centralize all of the terminal interactions
throughout sbt. It also seeks to hide the jline implementation details
and only expose the apis that sbt needs for interacting with the
terminal.

In general, we should be able to assume that the terminal is in
canonical (line buffered) mode with echo enabled. To switch to raw mode
or to enable/disable echo, there are apis: Terminal.withRawSystemIn and
Terminal.withEcho that take a thunk as parameter to ensure that the
terminal is reset back to the canonical mode afterwards.
2020-05-01 12:35:43 -07:00
Ethan Atkins cd65543d10 Deprecate unused ConsoleUnpromptEvent 2020-05-01 12:28:44 -07:00
Ethan Atkins 2f4c603be6 Stop continuous input thread if System.in is closed
The watch tests take forever on windows because wrapped.read() always
returns -1 during scripted.
2020-05-01 12:28:44 -07:00
Ethan Atkins 7d07bbabbf Fix DefinesClass implementation for jdk > 8
When trying to use any jdk > 8 with the latest sbt, sbt will die in some
projects because it tries to call Locate.defineClass on rt.jar, which
is represented with a DummyVirtualFile and causes a crash.
2020-04-30 20:43:04 -07:00
Eugene Yokota 7c4b01d9f7 Comment out external hooks
Zinc now uses farm hash to invalidate the virtual paths. To use watch to detect initial changes, we need to revalidate using content hash.
2020-04-24 17:44:15 -04:00
Eugene Yokota 2396b449fe Contraband 0.4.6 2020-04-24 17:44:15 -04:00
Eugene Yokota 3ce4d22b84 integrate with VirtualFile changes
Ref https://github.com/sbt/zinc/pull/712
2020-04-24 17:44:14 -04:00
Eugene Yokota 0a5c2edddf Fix strict switch command so +task is fixed 2020-04-24 01:18:16 -04:00
Eugene Yokota 11a403251a Fix cross + input task 2020-04-24 01:08:21 -04:00
Eugene Yokota 063b32bbba Fix cross + scoped task 2020-04-24 01:06:18 -04:00
Eugene Yokota 588d01b2dd Fix switch command -v flag 2020-04-24 01:04:05 -04:00
Anil Kumar Myla 41c3f433e6
Update semanticdb to work with scala 2.12.11 2020-03-20 16:12:07 -07:00
João Ferreira 09b2113379
fix units 2020-03-19 15:20:22 +00:00
João Ferreira 030252b653
Fix TaskTimings scaladocs 2020-03-19 15:07:26 +00:00
Anil Kumar Myla 887eb17f9e
Update scala to 2.12.11 2020-03-18 00:49:14 -07:00
Dale Wijnand b58c99efee Make ScriptedLauncher support Scala pre-releases
Also add a dash of sanity checks here and there.
2020-03-12 15:32:02 +00:00
eugene yokota 0b12862caf
Merge pull request #5439 from dwijnand/introduce-Taskable
Introduce Taskable & toTaskable
2020-02-28 10:43:16 -05:00
eugene yokota a2563f0088
Merge pull request #5447 from eed3si9n/wip/ordering
Make bare setting loading order alphabetical
2020-02-26 16:25:24 -05:00
Eugene Yokota 4b847b148f Make bare setting loading order alphabetical
Fixes https://github.com/sbt/sbt/issues/2697
Ref https://twitter.com/not_xuwei_k/status/1230140477959286848

Note that this is could potentially break an existing build that was relying on previous behavior, which seem to return `build.sbt` at the end if you have `a.sbt`, `b.sbt`, `c.sbt`, and `build.sbt`.
2020-02-24 18:16:01 -05:00
Alex Zolotko 92b2eaadf8 Prevent RejectedExecutionException during BackgroundRunnable.cleanup 2020-02-21 10:45:51 +01:00
Dale Wijnand 722022ae97 Add conversions from Init/+Task to Taskable 2020-02-17 12:22:53 +00:00
Dale Wijnand fdfdd1ca47 Extract Taskable from ScopedTaskable 2020-02-17 12:22:53 +00:00