Commit Graph

2984 Commits

Author SHA1 Message Date
Ethan Atkins b70bdce683 Set the exit value when sbt is started with -client 2020-11-27 12:12:15 -08:00
João Ferreira e1d8f0cafd
Updates to Coursier 2.0.7 (#6120)
* Updates to Coursier 2.0.7

https://github.com/coursier/sbt-coursier/releases/tag/v2.0.4 which includes https://github.com/coursier/coursier/releases/tag/v2.0.7

> Memo-ize classes that can be created at a high rate

coursier.core.{Dependency, Module, Publication} are now memo-ized (using weak references). This can lower the amount of duplicate instances of these objects, and lower GC pressure.
2020-11-26 19:25:37 -05:00
Ethan Atkins 5c508e4275 Fix waitWatch failure handling
The waitWatch command is very similar to shell in that it should
override the onFailure command to be itself. It also enqueues itself to
remaining commands whenever it reads a new command which made it
unnecessary to append waitWatch to the runCommmand in Continuous.
2020-11-25 14:54:13 -08:00
eugene yokota 1051690d61
Merge pull request #5515 from jtjeferreira/better_file_input
introduce a new Input/Output: FileInput/FileOutput
2020-11-25 11:11:04 -05:00
João Ferreira dd411cac9f introduce a new new Input/Output: FileInput/FileOutput
* FileInput avoids the intermediate String parsing of PlainInput
* FileOuput also avoid the intermediate String representation of PlainOutput
2020-11-25 14:04:56 +00:00
Ethan Atkins c6ab4d843e Fix watch shell option
When a user returns to the shell with 's' in recent versions of sbt, the
prompt is not initially displayed. This ends up being because MainLoop
was incorrectly setting the terminal prompt to Prompt.Watch when it
exited watch. I realized in debugging the issue that it didn't make
sense to restort the terminal prompt to the initial value before task
evaluation. By removing that logic, the 's' option option started
working correctly again.
2020-11-23 14:25:11 -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 a9957e5d73 Make the thin client `cancel` command work reliably
When the sbt server is running a task, it presents all connected clients
with a message that instructs them that they cancel the running task.
Unfortunately, this often didn't work and the task would keep running
after cancel was entered. The reason for this was because the exec id
passed in to NetworkChannel did not necessarily match the exec id of the
running task. Because cancel in this case is not really exec specific,
this commit adds a flag to NetworkChannel.cancel that forces it to
cancel the running task regardless of what execID is passed in.
2020-11-23 10:05:47 -08:00
Eugene Yokota 00265bf912 Work around "a pure expression does nothing" warning, take 2
In https://github.com/sbt/sbt/pull/5981 I tried to work around the spruious post-macro "a pure expression does nothing" warning (https://github.com/scala/bug/issues/12112) by trying to remove some pure-looking expressions out of the tree.

This quickly backfired when it was reported that sbt 1.4.3 was not evaluating some code. This backs out the macro-level manipulation, and instead try to silence the warning at the reporter level. This feels safer, and it seems to work just as well.
2020-11-22 17:04:19 -05:00
Eugene Yokota bd7a2e05bf Use `Global / localCacheDirectory` for remote caching
Fixes https://github.com/sbt/sbt/issues/6102

https://github.com/sbt/sbt/pull/6026 changed the implementation of remote cache to NOT use dependency resolution (Coursier), and directly use Ivy resolver for efficiency. This was good, but when I made the change, I've changed the cache directory to be `crossTarget.value / "remote-cache"`. This was ok for local testing purpose, but not great for real usage since we don't want the cache to be wiped out either in the CI machines or on a local laptop.

This adds a new Global key called `localCacheDirectory`. Similar to Coursier cache, this is meant to be shared across all builds running on a machine. Also similar to Coursier cache this will try to follow the operating system specifc caching directory.

### localCacheDirectory location

- Environment variable: `SBT_LOCAL_CACHE`
- System property: `sbt.global.localcache`
- Windows: %LOCALAPPDATA%\sbt\v1
- macOS: $HOME/Library/Caches/sbt/v1
- Linux: $HOME/.cache/sbt/v1
2020-11-22 14:35:20 -05:00
eugene yokota f4f8b6a97e
Merge pull request #6151 from eatkins/scripted-batch-execution
Only set scriptedBatchExcution true for >= 1.4
2020-11-21 13:41:01 -05:00
Ethan Atkins d686bead0b Only set scriptedBatchExcution true for >= 1.4
In #6091, we updated the ScriptedPlugin to set scriptedBatchExecution :=
true for all 1.x versions but not 0.13. This commit further restricts
the setting so that it is only set for sbt >= 1.4, which seems necessary
based on the comments in #6094.
2020-11-21 08:31:49 -08:00
Adrien Piquerez 136d0ab297 Bump semanticdb version 2020-11-21 16:43:40 +01:00
Ethan Atkins 5448a16ba4 Prepend scala instance jars to sbt classpath
When using the launcher's classpath for the metabuild, the
scala-compiler jar can be missing. This is because the managedJars only
method returns the scala-library jar and not the rest of the scala
instance. To fix this, we can always prepend the scala instance jars to
the classpath.

In order to simulate the issue in scripted, I had to manually remove the
scala-compiler.jar from the scripted classpath or else the scripted test
that I added doesn't actually do anything because the scala-compiler.jar
would end up on the app.provider.mainClasspath.

Fixes #4452
2020-11-20 13:11:24 -08:00
Ethan Atkins 62ebe70e5c
Merge branch 'develop' into bsp-watch-fix 2020-11-20 07:51:26 -08:00
Ethan Atkins 8ee28d5693
Merge branch 'develop' into bsp-consolidate 2020-11-20 07:29:35 -08:00
Ethan Atkins 14dee32d6b Stop CI hangs in background job service shutdown
A periodic stacktrace showed that scripted tests were still hanging in ci
trying to shutdown the background job service (I had previously thought
that I'd fixed that in 16bef0cfc8). It
appears that there is a logical bug that prevents some jobs from being
removed from the jobSet even though they have finished. If that happens,
the shutdown will never exit. That is highly undesirable and can be
avoided by adding a timeout and also only trying to shutdown the job if
it is actually running.
2020-11-19 22:26:41 -08:00
Ethan Atkins 600628e8e9 Fix watch with metals sbt bsp implementation
I discovered that the metals bsp implementation worked very badly with
continuous builds. The problem was that metals is able to trigger a bsp
compile slightly before the continuous build would trigger. This would
cause the ui to get in a bad state. The worst case was that it would
actually cause sbt (or the thin client) to exit. A less catastrophic
issue was that it was possible for the wrong count to be printed by the
continuous message.

This commit fixes the issue by more carefully managing the prompt state
and only resetting the ui when the prompt is not in the Prompt.Watch
state.
2020-11-19 18:57:24 -08:00
Ethan Atkins 7a8a5e5dac Disable console ui for client launched server
If the sbt server is launched by the remote client, it should not have a
console ui thread because there is no way to even feed input to it once
the server has launched. Having the ui thread can cause the server to
exit unexpectedly if an EOF is read from the console input stream.
2020-11-19 16:10:03 -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
eugene yokota f4921e3dd7
Merge pull request #6105 from eatkins/jline3-upgrade
JLine 3.17.1
2020-11-18 22:31:02 -05:00
eugene yokota 9985cb4b1c
Merge pull request #6115 from eatkins/thin-client-startup
Fix thin client sbt process startup output
2020-11-18 18:26:28 -05: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 39af464dfd Fix shutdown for thin client shell
When a user enters shutdown in the thin client console, it only exits
the thin client, it does not actually shutdown sbt. Running `sbtn
shutdown` did work to shutdown the server, however. It turned out that
this was because there was special handling for shutdown when processed
through jline. We would enqueue the shutdown command and also close the
client connection. Closing the client connection though removed all of
the enqueued commands for the client, which included the shutdown
command. To fix this, we just make sure that we don't remove the
shutdown command when clearing the client commands.
2020-11-18 12:20:48 -08:00
Ethan Atkins c34678e9db Upgrade jline 3
We no longer need to use the forked version of jline because they have
merged in our required changes. The latest version of jline does upgrade
jansi, however, and some of the apis we were relying on for windows were
removed so they had to be manually implemented. I verified that console
input still worked on my windows vm after this change.
2020-11-18 12:18:08 -08:00
Ethan Atkins 927151485d Exclude jansi classes from metabuild top loader
The launcher embeds a fixed version of jansi above the rest of the
classpath on windows. This causes problems for the scala 2.12 console
because it tries to load methods that don't exist from the old jansi
jar. This can be fixed by excluding all jansi classes from the top
loader.

We also need to exclude jansi classes in the scala instance top class
loader to make the 2.10 console work because scala 2.10 uses a shaded
jline that requires a very old jansi version. Due to the shading, the
thin client doesn't work with the 2.10 console.
2020-11-18 12:18:08 -08:00
Ethan Atkins d52d413867 Fix watch for dumb terminals
On terminals with virtual io disabled, we'd spin up a thread for each
watch iteration that performed a blocking read from the terminal input
stream. This thread could not be joined which would cause the triggered
execution to be delayed by 1 second while sbt blocked trying to join
that thread. It also meant that input probably didn't work correctly
since the user would end up with many threads polling from system in.
The fix to this problem is to poll the terminal input stream if it is
unsafe to do a blocking read, which is the case for dumb terminals or if
virtual io is disabled.
2020-11-17 16:47:53 -08:00
Taichi Yamakawa c0b6b97990 Move sys props related things to SysProp 2020-11-17 21:11:33 +09:00
Taichi Yamakawa 0557171930
Merge branch 'develop' into system-property-for-on-changed-build-source 2020-11-17 01:42:41 +09:00
Taichi Yamakawa 5bdba54a3c Support a system property for onChangedBuildSource
Resolve the issue https://github.com/sbt/sbt/issues/5679
2020-11-17 00:58:25 +09:00
kenji yoshida eba3596e5d
Update main/src/main/scala/sbt/ScriptedPlugin.scala
Co-authored-by: eugene yokota <eed3si9n@gmail.com>
2020-11-16 15:39:57 +09:00
xuwei-k fd967d1215 set "scriptedBatchExecution := false" if sbt 0.13 2020-11-16 15:23:41 +09:00
eugene yokota d34c34d177
Merge pull request #6085 from eed3si9n/wip/metabuild-classpath2
Use the classpath obtained by the launcher for metabuild, take 2
2020-11-15 14:40:28 -05:00
Eugene Yokota b1a8f11011 Use the classpath obtained by the launcher for metabuild, take 2
Ref https://github.com/sbt/sbt/pull/4443
Fixes https://github.com/sbt/sbt/issues/5750

In #4443 I implemented an optimization where the metabuild would no longer re-resolve numerous sbt artifacts for metabuilds each time, and instead use whatever the JARs provided by the launcher. At the time, this technique didn't work for Coursier so I've placed in some workarounds for it. Now that Coursier's resolution has improved, it seems like the workaround is actually causing more harm. This removes the bandaid, and local testing shows that it seems to be working.

For instance, we no longer need to put in `ThisBuild / useCoursier := false` in sbt/sbt's `project/plugins.sbt`.
2020-11-15 12:19:03 -05:00
nafg 3c2565722a Tweak warning text 2020-11-15 00:05:06 -05:00
Naftoli Gugenheim 889b101cbd Update tests for fixed GCMonitor 2020-11-15 00:00:50 -05:00
Naftoli Gugenheim 6cca595420 Add file headers 2020-11-15 00:00:50 -05:00
Naftoli Gugenheim 1c258b8fc9 GCMonitor: Unit tests, refactor, and improve
* Refactor so as to be testable
 * Queue stores the _beginning_ timestamp of each GC time delta
 * Message states the correct time over which the GC time was recorded
 * Add heap stats from java.lang.Runtime to the message
2020-11-15 00:00:50 -05:00
Naftoli Gugenheim af7346f565 Program to manually test GCMonitor 2020-11-15 00:00:50 -05:00
eugene yokota 19ae383f9f
Merge pull request #6041 from eatkins/active-json
Start server if active.json file is removed
2020-11-04 23:06:45 -05:00
Ethan Atkins 749d32df36 Set the default scriptedBatchExecution to true
sbt itself effectively runs its scripted test with
scriptedBatchExecution true and scriptedParallelInstances 1. The
performance is much better when this works. This can cause issues, see
https://github.com/sbt/sbt/issues/6042, but we inadvertently made this
behavior the default in 1.4.0 and it took about a month before #6042 was
reported so I think most users would benefit from this default.
2020-11-04 18:47:31 -08:00
Ethan Atkins 452c49f84c Start server if active.json file is removed
If there are two sbt instances and one of them is running a server, the
other instance is presently prevented from ever starting a server. If an
sbt instance is unable to start a local server because of the presence
of another server, we can monitor the active.json file for changes and,
if it is deleted, we can then try again to start a new server instance.
2020-11-02 08:36:46 -08:00
eugene yokota 8c3f2a50f7
Merge pull request #6026 from eed3si9n/wip/content
Make remoteCacheId content-based
2020-11-01 22:06:37 -05:00
Eugene Yokota 744cfefa6c Refactor remote cache to per-config
Refactor remote caching to be scoped to configuration.
In addition, this avoid the use of dependency resolver (since I'm not resolving anything) and directly invoke the Ivy resolver for the artifact, somewhat analogus to publishing process.
This should speed up the `pullRemoteCache` since it avoids the POM download as well.

For sbt-binrary-remote-cache this created a bit of complication since the (publishing) resolver doesn't act correctly as (downloading) resolver in terms of the credentials, so I had to create a new key `remoteCacheResolvers` to have asymmetric resolver.
2020-11-01 19:15:28 -05:00
Eugene Yokota 6a356c61e0 Refactor remoteCacheId 2020-10-29 09:47:27 -04:00
Eugene Yokota 86e793cd74 Make remoteCacheId content-based
Fixes https://github.com/sbt/sbt/issues/5842
2020-10-27 10:36:53 -04:00
eugene yokota 1436960b34
Merge pull request #6023 from eatkins/sbtn-wizard
Add wizard for installing sbtn and completions
2020-10-26 18:59:42 -04:00
eugene yokota 8c3ea7d470
Merge pull request #6007 from adpi2/fix-bsp-reporter
Fix #6006: BuildServerReporter on Dotty
2020-10-26 18:59:06 -04:00
Ethan Atkins b107bdc09d
Merge branch 'develop' into sbtn-wizard 2020-10-26 15:09:57 -07:00
eugene yokota 1f770bc1c0
Merge pull request #6028 from adpi2/lint-exclude-idle-timeout
Add serverIdleTimeout to the list of excluded lint keys
2020-10-26 17:09:02 -04:00