Commit Graph

2853 Commits

Author SHA1 Message Date
Ethan Atkins a946cbf702 Skip contents of symlinked directories in clean
The clean task was previously deleting the contents of directories that
were symlinked into the target directory. This was an oversight because
it never occurred to me that users might symlink a directory whose
contents they did not want deleted into the target directory.
2020-09-15 09:24:04 -07:00
eugene yokota 66308bae45
Merge pull request #5847 from eed3si9n/wip/promise_propagate
Cancel all promises if one fails
2020-09-14 22:33:18 -04:00
eugene yokota f033aa5ca1
Merge pull request #5844 from eed3si9n/wip/pipelining_adjustments
Fix mixed pipelining
2020-09-14 22:32:48 -04:00
Adrien Piquerez ac85117841 Add BSP workspace/reload 2020-09-14 13:10:11 +02:00
Eugene Yokota 55d2b0a3c6 Cancel all promises if one fails
Fixes https://github.com/sbt/sbt/issues/5822

Currently the entire shell gets stuck when there's a compilation error with pipelining.
This at least returns to sbt shell.
2020-09-14 01:04:10 -04:00
Eugene Yokota 350a6af6ef Demote [sig files written]
It gets ridiculous seeing the screen fill up with [sig files written] after a while.
Here's a quick hack to demote that stuff.
2020-09-13 17:54:36 -04:00
Eugene Yokota 2a8c184a51 Fix mixed pipelining
Together with https://github.com/sbt/zinc/pull/920 this fixes most of the mixed pipelining issues.

1. Previous values are carried from `compileScalaBackend` in `compileJavaTask`.
2. `compileJava / compileOptions ` now uses `compile / compileOptions` to avoid unintentional change of javac or scalac options.
3. Hooks up early compile analysis store.
2020-09-13 16:25:09 -04:00
Eugene Yokota d24cd2b3f7 Rename --close-io-streams to --detach-stdio 2020-09-12 14:19:37 -04:00
Eugene Yokota bba3d08aac Add pseudo --server command
Ref https://github.com/sbt/sbt/issues/5665

This adds `--server` command that is immediately filtered out in Main.scala.
The purpose of `--server` is so we can invoke thin client from `sbt` script at some point in the future when Bash script can parse `project/build.properties`.

`sbtn` would need to call `sbt` again to start the server, and at that point the shell script would need to actually invoke the server. The intent of `--server` is to be used as the tie breaker.

Also build users may want to sometimes call `sbt --server`.
2020-09-12 14:12:02 -04:00
eugene yokota 8160035f41
Merge pull request #5840 from eatkins/play-progress
Skip task progress work if already shutdown
2020-09-12 08:27:42 -04:00
Ethan Atkins 476cfc6649 Change terminalShellPrompt to colorShellPrompt
I introduced the terminalShellPrompt so that we could generate a prompt
that was colored only if the terminal supported color. Rather than
expose the terminal implementation detail, we can just use a boolean
flag that toggles whether or not color is enabled and sbt can pass in
the value of terminal.isColorEnabled into the function.
2020-09-11 11:47:36 -07:00
Ethan Atkins 5e88d4b233 Warn on progress RejectedExecutionException
It shouldn't be the case that a RejectedExecutionException is thrown
by TaskProgress. If that assumption is violated, log the exception but
don't crash sbt.
2020-09-11 11:39:53 -07:00
Ethan Atkins 4a2bf67eb8 Skip task progress work if already shutdown
The play plugin seems to do out of band task evaluation on a stale State
object in the `run` task. As a result, when sbt tries to schedule tasks
to run, they tried to register the work with a closed TaskProgress
instance. There was no guard against this and it ended up causing a
RejectedExecutionException.
2020-09-11 11:37:17 -07:00
Ethan Atkins a471e7384d Honor shellPrompt override
sbt 1.4.0 generates the shell prompt using the terminal properties for
the specific terminal for which the prompt is rendered. The mechanism
for doing this broke the prompt for projects that overrode the
shellPrompt key, notably the play plugin. After this change, the play
custom prompt is correctly rendered with 1.4.0-SNAPSHOT.
2020-09-11 10:50:21 -07:00
Ethan Atkins 3d6d847947 Use null ConsoleOut for RelayAppender
The RelayAppender should not log directly to console out since it is
supposed to be relaying json log messages to connected clients. This was
manifesting as double printing on some success messages.
2020-09-10 16:40:47 -07:00
Ethan Atkins 31f36eeff3 Add serverConnectionType to excludeLintKeys 2020-09-10 11:56:42 -07:00
Ethan Atkins f23aecfdbf Suggest using alternate gc implementation
Running publishLocal in the zinc project can cause gc thrashing with the
default parallelgc collector using jdk8 on my laptop. If I switch to
G1GC, it does not thrash even if I leave the heap the same size.
2020-09-08 11:12:13 -07:00
Ethan Atkins 4e3d351e71 Set initial collection time in gc monitor
The java GarbageCollectorMXBean.getCollectionTime returns the cumulative
amount of time the collector has run during the jvm session. The GC
monitor is tracking how much time has been spent in garbage collection
during each task evaluation run. In order for this calculation to work
correctly, it is necessary to set the initial elapsed time to the bean's
current collection time when we create the gc monitor. Without doing
this, we can get completely incorrect results that are reporting based
on the total gc time for the entire process, not just in the last 10
seconds.

Should fix https://github.com/sbt/sbt/issues/5818
2020-09-08 11:07:30 -07:00
Ethan Atkins fdce1eb7e6 Add gc monitor to warn users about excessive gc
It is not uncommon in large projects for the jvm to silently be running
frequent full gcs in the background. This can slow progress to a crawl.
Usually the fix is to bump the -Xmx parameter but if the users do not
realize that their tasks are slow because of gc thrashing, they may not
think to do that. This PR adds a monitor that hooks into the jvm's event
notification system to keep track of how much time is spent in GC. If
the ratio of the amount of time in gc to the total elapsed time exceeds
some threshold, we emit a warning.

I was motivated to do this because publishLocal can take forever in the
zinc project because a 1G heap isn't big enough.
2020-09-05 13:47:39 -07:00
Ethan Atkins 4f734ebeaa Hide compileEarly and pickleProducts from progress
These tasks show up during task progress and they clutter up the
display. Since my understanding is that both of these tasks are more or
less just waiting for other work to complete, I don't think they are
helpful for debugging.
2020-09-02 22:06:38 -07:00
eugene yokota 460a6f2291
Merge pull request #5806 from eatkins/zinc-sandwich-fix
Allow incompatible mixed scala versions
2020-09-02 19:51:17 -04:00
Ethan Atkins 443ebcd3d7 Sanitize builder server protocol uri
The lift-json project couldn't load in the community build because the
generated uri contained two # identifiers.
2020-09-02 15:58:19 -07:00
Ethan Atkins c6021ecdf6 Allow incompatible mixed scala versions
The zinc scripted project depends on all of the compiler bridges. As a
result the introduction of the strict scala binary version check in
f8139da192 broke zinc scripted. This
commit reverts to the old behavior in the non scala sandwich case.

I also switched to a for comprehension instead of a pattern match
because this is a rare case where I think it made the code significantly
more readable.
2020-09-02 11:49:05 -07:00
Ethan Atkins c931b005ab Change ctrl+c behavior in ~
While in a continuous build, when the user enters ctrl+c into the sbt
server console (not a thin client connection) when sbt has been launched
in interactive mode, the server exits.  This commit makes it so that
instead we just cancel the watch. As a result, if sbt was started in
batch mode, e.g. `sbt ~compile`, ctrl+c will still exit sbt but in
interactive mode ctrl+c will take the user back to the shell.
2020-08-31 11:41:08 -07:00
Ethan Atkins afac5e5067 Block watch until threads spin up
I occassionally end up in a state where watch input does not seem to be
read. To rule out the possibility that the background thread that reads
input has not successfully started, this commit makes it so that we
block until the thread signals that it has started via a CountDownLatch.

The diff is superficially big because of an indentation change at the
bottom.
2020-08-31 11:36:39 -07:00
Adrien Piquerez 23c8889e26 Add bspEnabled setting 2020-08-27 09:11:52 +02:00
eugene yokota 788fd4aa28
Merge pull request #5793 from eatkins/kill-processes
Kill external processes on sigint
2020-08-26 11:07:52 -04:00
Ethan Atkins 1c21f13b99 Reduce sbt memory utilization
The sbt Server is initialized with a callback onIncomingSocket. That
callback was created in CommandExchange and held references to a build
structure and a state. Neither the state nor structure would ever go out
of scope so they effectively leaked. It is possible for each
NetworkChannel to access a recent instance of state through the
CommandExchange.withState method. Using this, we can eliminate the
references to state and build structure in the onIncomingSocket
callback. In the sbt project, this reduced the memory utilization by
about 50mb on startup.
2020-08-24 10:30:43 -07:00
Ethan Atkins d3f8cc8161 Kill external processes on sigint
On linux and mac, entering ctrl+c will automatically kill any forked
processes that were created by the sbt server because sigint is
automatically forwarded to the child process. This is not the case on
windows where it is necessary to forcibly kill these processes.
2020-08-23 10:15:07 -07:00
Ethan Atkins 41c33ba92f Fix intellij import with 1.4.x
The intellij import currentlly works by forking an sbt process and
writing command input through the process input stream. To make this
work, we need the SimpleTerminal (which is used when sbt is run with
-Dsbt.log.noformat=true) to be able to read input.

Attaching the input to the simple terminal caused watch tests to fail on
windows. This can be fixed by checking if the byte read from the input
stream is -1 and ignoring it if so.
2020-08-23 08:59:08 -07:00
Ethan Atkins 02366fdf49 Honor formatEnabledInEnv at the Terminal level
The sbt.log.noformat parameter should be treated very similarly to
sbt.io.virtual. When it is true, we should just use the raw io streams
for the process. This came up because of
https://github.com/sbt/sbt/issues/5784 which reported that intellij
imports were not working and that ansi control characters were being
written to the output.
2020-08-23 08:51:55 -07:00
Ethan Atkins 329baf4b0b Use more aggressive strategy to join ui threads
There can be race conditions where we try to interrupt and join a ui
thread before it becomes interruptible by blockign on a queue. To
workaround this, we can add the JoinThread class which adds an
extension method Thread.joinFor that takes a FiniteDuration parameter.
This variant of join will repeatedly interrupt and attempt to join the
thread for up to 10 milliseconds before retrying until the limit is
reached. If the limit is reached, we print a noisy error to the console.

I'm not 100% sure if we are leaking threads in the latest sbt version
but this gives me more piece of mind that either we are always
successfully joining the threads or we will be alerted if the joining
fails.
2020-08-21 12:57:37 -07:00
eugene yokota b8dac52338
Merge pull request #5774 from adpi2/feature/bsp-config-task
Add bspConfig task
2020-08-20 10:27:06 -04:00
Adrien Piquerez 4a02292b6f Enable semanticdb with Dotty 2020-08-17 17:39:43 +02:00
Adrien Piquerez 97b0347c15 Add bspConfig task 2020-08-17 17:33:48 +02:00
eugene yokota 31dc975ec7
Merge pull request #5769 from eed3si9n/wip/banner
Advertise versionScheme instead
2020-08-16 21:15:58 -04:00
eugene yokota da9cf449c7
Merge pull request #5767 from eed3si9n/wip/dotty-mixed
Implement Scala 2.13-3.0 sandwich
2020-08-16 21:15:21 -04:00
Eugene Yokota 1ae4f76e29 Advertise versionScheme instead
Ref https://github.com/sbt/sbt/pull/5724
2020-08-16 19:26:43 -04:00
Eugene Yokota f8139da192 Implement Scala 2.13-3.0 sandwich
Fixes https://github.com/sbt/sbt/issues/5369
Ref https://contributors.scala-lang.org/t/roadmap-for-the-tasty-reader-for-scala-2/4231

This implements support for inter-project dependencies between Scala 2.13 and Dotty, and vice versa. Scala 2.13 depending on Dotty would require 2.13.4 and above.
2020-08-16 19:19:05 -04:00
Ethan Atkins 74e407f4a1 Restore binary compatibility for LogManager.defaults
Although log manager is in the internal package, akka uses it and it
seems worth preserving binary compatibility in their build, at least for
sbt 1.4.0-M2. Once the community build is passing, we can consider
reverting this.
2020-08-16 15:45:26 -07:00
eugene yokota 8b5f212010
Merge pull request #5766 from eed3si9n/wip/use_pipelining
Add exportPipelining setting to implement subproject opt-out
2020-08-16 18:03:06 -04:00
Eugene Yokota 1dc9a76a14 Banner for 1.4.0 beta
```
[info] welcome to sbt 1.4.0-SNAPSHOT (AdoptOpenJDK Java 1.8.0_232)
[info] loading settings for project global-plugins from ...
[info] loading global plugins from ...
[info] loading project definition from /private/tmp/hello/project
[info] loading settings for project root from build.sbt ...
[info] set current project to hello (in build file:/private/tmp/hello/)
[info]
[info] Here are some highlights of this release:
[info]   - Build server protocol (BSP) support
[info]   - sbtn: a native thin client for sbt
[info]   - VirtualFile + RemoteCache: caches build artifacts across different machines
[info]   - Incremental build pipelining. Try it using `ThisBuild / usePipelining := true`.
[info] See http://eed3si9n.com/sbt-1.4.0-beta for full release notes.
[info] Hide the banner for this release by running `skipBanner`.
[info] sbt server started at local:///Users/eed3si9n/.sbt/1.0/server/478e6db75688771ddcf1/soc
```
2020-08-16 16:21:27 -04:00
Eugene Yokota 755fbf4dcd Add exportPipelining setting to implement subproject opt-out
Fixes https://github.com/sbt/sbt/issues/5762
Fixes https://github.com/sbt/sbt/issues/5754

Ref https://github.com/sbt/zinc/pull/883
2020-08-16 15:47:44 -04:00
Ethan Atkins 64c0f0acdd Cancel all running tasks with ctrl+c
Frequently ctrl+c does not work to cancel the running tasks. This seems
to be because the signal handler is bound to a specific instance of
evaluate task but there may be multiple instances of evaluate task
running at any given time. Shutting down just one of the running engines
does not ensure that task evaluation stops. To work around this, we can
globally store all of the completion services in a weak hash map and
cancel all of them whenever a signal is received. Closing the service,
which happens at the end of task evaluation will remove the service from
the map so hopefully this shouldn't introduce a memory leak.
2020-08-14 14:52:57 -07:00
eugene yokota 423d8fc33f
Merge pull request #5702 from eatkins/lint-ignore
Add lintUnusedKeysOnLoad to lint ignore keys
2020-08-14 12:08:27 -04:00
eugene yokota 7809bd4a38
Merge pull request #5748 from eatkins/watch-reload
Add reload to watch commands
2020-08-14 12:08:04 -04:00
eugene yokota 1769a55fed
Merge pull request #5743 from eed3si9n/wip/semanticdb
Upgrade scala version to 2.12.12, take 2
2020-08-14 11:18:47 -04:00
eugene yokota ca660f25da
Merge pull request #5747 from eatkins/watch-threads
Ensure watch threads are joined
2020-08-14 05:09:37 -04:00
Ethan Atkins 415341ec8b Add reload to watch commands
I have this in my global git config and think it's useful enough to
promote to the default.
2020-08-13 18:03:55 -07:00
Ethan Atkins 59c3d73f83 Ensure watch threads are joined
While dogfooding the latest sbt, I noticed that sometimes the watch
input threads leak. I suspect this happens when a build is immediately
triggered by a file that was modified during compilation. Though I
didn't fully verify this, it's likely that we interrupted the input
reading thread before it actually started reading. When it started
reading after the interrupt, it would block until the user entered
another input character. The result was that the zombie thread would
effectively steal the next character from the input stream which
manifested as the first character being ignored when the user tried to
enter a watch input option. If more than one thread leaked, then it may
take a number of keystrokes before the user regained control.

To fix this, we can ensure that all watch related threads are joined
before we exit watch. To avoid completely blocking the ui, we only try
to join the threads for a second and print an error if the join fails.
This shouldn't be the case so if users see this error, then we need to
fix the bug.
2020-08-13 18:03:26 -07:00