Commit Graph

10107 Commits

Author SHA1 Message Date
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
eugene yokota cf78d18d63
Merge pull request #6008 from adpi2/fake-positions
Fix #5994: sourceMappers handles fake positions
2020-10-26 12:53:43 -04:00
Adrien Piquerez 3ca7951d13 Add serverIdleTimeout to the list of excluded lint keys 2020-10-26 16:12:47 +01:00
Adrien Piquerez e4b93182ba Test Source Mapper on Windows 2020-10-26 08:40:00 +01:00
Adrien Piquerez d51057db4f Add tests on sourcePositionMappers 2020-10-26 08:40:00 +01:00
Adrien Piquerez 2425ca4950 handle fake positions in absoluteSourceMapper 2020-10-26 08:40:00 +01:00
eugene yokota 7a7bc5d0f9
Merge pull request #6025 from eatkins/thin-client-spaces
Replace %20 with space in sbt script name
2020-10-26 00:54:27 -04: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
eugene yokota a757f3e6e8
Merge pull request #6024 from eatkins/join-thread
Avoid throwing interrupted exception in JoinThread
2020-10-25 21:33:45 -04: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 b5fc17cc7a
Merge pull request #6022 from eatkins/network-flush
Flush terminal output stream after readline
2020-10-24 19:58:26 -07:00
Ethan Atkins fd0fb12e06
Merge branch 'develop' into network-flush 2020-10-24 16:47:56 -07:00
Ethan Atkins 28a788a17e
Merge pull request #6021 from eatkins/strip-colors
Strip ansi and color codes from terminal output
2020-10-24 16:47:13 -07:00
Ethan Atkins 3aeede3774 Flush terminal output stream after readline
With the thin client, when running the command `exit`, it is often the
case that the log message `[info] disconnected` is printed on the same
line as the prompt. This is because there is a small flush delay on the
network client's output stream channel that causes the disconnected info
message to be logged before the the newline that jline 3 echoes to the
client has been printed. To fix this we can manually flush the terminal
output stream before exiting.
2020-10-24 15:49:02 -07:00
Ethan Atkins 7eafcaf544 Strip ansi and color codes from terminal output
It is possible for downstream dependencies to print or log messages
containing ansi escape sequences and/or color codes. In older versions
of sbt, these would be printed even if the user had disabled ansi codes
or color via the sbt.log.noformat or sbt.color parameters. This commit
adds a general api to EscHelpers that strips general ansi codes and
color codes independently via flags. We can then use that api to ensure
that all bytes written to System.out are stripped of ansi escape and
color codes if the terminal properties demand this.

The motivation was that JLine 3 will prepend the prompt string with
\E[?2004h, which turns on bracketed paste mode
(https://en.wikipedia.org/wiki/ANSI_escape_code). If the sbt shell is
started with a terminal that doesn't support general ansi escape codes,
such as the jEdit shell, ?2004h gets printed to the shell. To fix this,
we can strip ansi codes from all output if the terminal doesn't support
general ansic codes. This has the additional side effect of any ansi
codes that appear in log messages or printlns that are added by non-sbt
code will be stripped. It's unlikely that this is all that common.

In addition to the JLine use case, I've noticed that utest prints
colored output during test runs. Prior to this change, the colored
output was present even when sbt was run with `-Dsbt.color=false` and
after this change, the colors are correctly stripped.
2020-10-24 15:31:00 -07:00
eugene yokota 1692b93ec3
Merge pull request #6019 from eatkins/client-properties
Parse network client arguments early
2020-10-24 17:30:18 -04:00
eugene yokota 078b9c69c5
Merge pull request #6017 from eatkins/log-format-color
Set color by default only if log format enabled
2020-10-24 17:20:04 -04: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 0d332101f9
Merge branch 'develop' into log-format-color 2020-10-24 12:48:47 -07:00
Ethan Atkins fad905020c
Merge pull request #6018 from eatkins/watch-before
Reinstate watchBeforeCommand callback
2020-10-24 12:48:32 -07:00
Ethan Atkins 69be879684 Reinstate watchBeforeCommand callback
A user reported that the watchBeforeCommand callback was not being
invoked in sbt 1.4.{0, 1}. This was an oversight that occurred when
refactoring watch for the thin client and there previously had been no
regression test for that callback.
2020-10-24 10:59:33 -07:00
Ethan Atkins 4937ce563d
Merge branch 'develop' into log-format-color 2020-10-24 10:58:08 -07:00
eugene yokota a09e6e2a25
Merge pull request #6016 from eatkins/windows-echo
Fix console echo for windows batch commands
2020-10-24 13:55:49 -04:00
Ethan Atkins 46c5f8b0d8 Fix console echo for windows batch commands
For reasons I don't fully understand, it is necessary to go in and out
of raw mode to get console input to echo on windows. This was reported
as sbt new not echoing input in #5952.
2020-10-24 09:49:12 -07:00
Ethan Atkins 0e63873032 Set color by default only if log format enabled
I noticed that if you run `sbt -Dsbt.log.noformat=true` there are colors
printed when using the latest sbt code. When running with that property
set, the expectation is there are no colors.
2020-10-23 08:25:06 -07:00
eugene yokota 7a3ca0d9c2
Merge pull request #6011 from adpi2/fix-bsp-semanticdb-warning
Fix #5977: Fix semanticdb warning
2020-10-22 12:14:45 -04:00
eugene yokota 3536959c31
Merge pull request #6005 from eed3si9n/wip/prefixpaths
Fix earlyOutput and remoteCachePom paths
2020-10-22 11:36:49 -04:00
Adrien Piquerez 22e5308381 Fix BSP warning about semanticdb 2020-10-22 16:18:12 +02:00
Eugene Yokota 3d01d7fbbe Use different artifactPath for remoteCachePom
Fixes https://github.com/sbt/sbt/issues/6004

```
sbt:foo> remoteCachePom
[info] Wrote /private/tmp/foo/target/scala-2.13/remote-cache/foo_2.13-0.1.0-SNAPSHOT.pom

sbt:foo> makePom
[info] Wrote /private/tmp/foo/target/scala-2.13/foo_2.13-0.1.0-SNAPSHOT.pom
```
2020-10-22 00:07:46 -04:00
Eugene Yokota 88d7da5141 Fix earlyOutput paths
Fixes https://github.com/sbt/sbt/issues/5929
2020-10-22 00:03:48 -04:00
eugene yokota 6871d66c3f
Merge pull request #6003 from eatkins/simple-input-stream
Fix SimpleInputStream reads into array
2020-10-21 21:31:29 -04:00
Ethan Atkins 7894938c7d Revert "Don't ever use jline 3 dumb terminal"
This reverts commit 6f63b2ccfa. It turns
out the DumbTerminal does work in some cases such as when the TERM
environment variable is set to DUMB.
2020-10-21 14:26:21 -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 50f649c3c9 Fix SimpleInputStream reads into array
When the read methods of InputStream that take an Array[Byte] as input
are called, they are supposed to return -1 if there are no bytes
available due to an EOF. Previously it was incorrectly writing the -1 as
a byte in the array and returning 1. Now it correctly returns -1.

The condition for closing the WriteableInputStream was also incorrect.
We should only close the input stream if it returns -1 in raw mode.

Fixes #5999
2020-10-21 14:26:21 -07:00
Ethan Atkins f35675286b
Merge pull request #6001 from eatkins/evaluate-task-memory-leak
Fix EvaluateTask memory leak
2020-10-21 14:26:10 -07:00
Ethan Atkins 7ad20edbd3
Merge branch 'develop' into evaluate-task-memory-leak 2020-10-21 11:49:01 -07:00
eugene yokota f217b59868
Merge pull request #5996 from xuwei-k/remote-cache-extract-message
improve remote cache extract log message
2020-10-21 14:32:18 -04:00
eugene yokota 872fde1144
Merge pull request #5998 from eatkins/ansi-color-fixes
Fix more color/ansi issues
2020-10-21 14:31:31 -04: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 c46de920ab Enable color by default in ci builds
This channge should turn color on by default in ci builds (see
https://github.com/sbt/sbt/issues/5269). It can still be disabled with
-Dsbt.color=false.
2020-10-21 08:01:12 -07:00
Ethan Atkins a892a83681 Only disable virtual io automatically in ci
Disabling virtual io prevents the thin client from working. It is
possible that a user may manually start a server with -Dsbt.color=false
but still want to connect a thin client.
2020-10-21 08:01:12 -07:00
Ethan Atkins 6f63b2ccfa Don't ever use jline 3 dumb terminal
When using the DumbTerminal, no input is successfully read. I must not
have actually tested this when I added it.
2020-10-21 08:01:12 -07:00
Ethan Atkins 3d179cda75 Enable ansi codes if supershell is enabled
Running sbt with -Dsbt.supershell=true and -Dsbt.color=true doesn't work
well because the isAnsiSupported flag is set to false when
-Dsbt.color=false. This causes the processing that ensures that
supershell lines do not get interleaved with normal log lines to be
skipped. To fix this, we can enable ansi codes when supershell is
explicitly enabled.
2020-10-21 08:01:12 -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 29d9c14edf Improve log formatting logic for ci use cases
It is currently the case that all tagged log messages going through a
ConsoleAppender have color codes added and then subsequently stripped
out. This didn't work well in combination with -Dsbt.color=true and
-Dsbt.ci=true because the -Dsbt.color=true was causing
ConsoleAppender.formatEnabledInEnv to be set to true which caused ansi
codes to be enabled. Travis CI supports color codes but not other ansi
escape sequences (this is also often true of embedded shells like in
intellij or jedit). This commit reworks the ConsoleAppender so that we
only add colors if useFormat is enable dand only add
ClearScreenAfterCursor if ansi codes are supported. It also reworks the
ConsoleAppender.write method so that if useFormat is true but
ansiCodesSupported is false that we only remove the non color related
ansi escape sequences so that colors remain.
2020-10-21 08:01:12 -07:00
eugene yokota d1ff067d54
Merge pull request #6000 from eatkins/canonical-ctrl-d
Handle ctrl+d in canonical mode
2020-10-20 22:58:50 -04:00
Ethan Atkins 82d6a050de Handle ctrl+d in canonical mode
In canonical mode, System.in will return -1 for ctrl+d on an empty line.
The result of this behavior was that if a user entered ctrl+d during run
in a task that was reading from System.in, sbt would end up exiting
whenever the task exited. This happened because the WriteableInputStream
would close itself when it read -1 from the input stream, which it
assumed meant that the underlying input stream itself had been closed.
When the jline reader tried to read from the closed
WriteableInputStream, it would throw an exception and if the line reader
was for the console channel, it would be interpreted as the user had
inputted ctrl+d in the sbt shell which is supposed to exit sbt. This
change fixes that behavior so that sbt can continue reading input after
the run task exits.
2020-10-20 16:57:17 -07:00
xuwei-k 37fa5573f0 improve remote cache extract log message
build.sbt

```
lazy val common = Def.settings(
  scalaVersion := "2.12.12",
  pushRemoteCacheTo := Some(
    MavenCache("local-cache", (ThisBuild / baseDirectory).value / "remote-cache")
  ),
  remoteCacheId := "fixed-id",
  remoteCacheIdCandidates := Seq(remoteCacheId.value)
)

pushRemoteCache := {}
pullRemoteCache := {}

lazy val p1 = project.settings(common)
lazy val p2 = project.settings(common)
lazy val p3 = project.settings(common)
lazy val p4 = project.settings(common)
lazy val p5 = project.settings(common)
lazy val p6 = project.settings(common)
lazy val p7 = project.settings(common)
lazy val p8 = project.settings(common)
lazy val p9 = project.settings(common)
```

run: `sbt pushRemoteCache clean pullRemoteCache`

before

```
[info] remote cache artifact extracted for Some(cached-compile)
[info] remote cache artifact extracted for Some(cached-compile)
[info] remote cache artifact extracted for Some(cached-compile)
[info] remote cache artifact extracted for Some(cached-compile)
[info] remote cache artifact extracted for Some(cached-compile)
[info] remote cache artifact extracted for Some(cached-compile)
[info] remote cache artifact extracted for Some(cached-test)
[info] remote cache artifact extracted for Some(cached-test)
[info] remote cache artifact extracted for Some(cached-test)
[info] remote cache artifact extracted for Some(cached-test)
[info] remote cache artifact extracted for Some(cached-test)
[info] remote cache artifact extracted for Some(cached-test)
[info] remote cache artifact extracted for Some(cached-compile)
[info] remote cache artifact extracted for Some(cached-test)
[info] remote cache artifact extracted for Some(cached-compile)
[info] remote cache artifact extracted for Some(cached-test)
[info] remote cache artifact extracted for Some(cached-compile)
[info] remote cache artifact extracted for Some(cached-test)
```

after

```
[info] remote cache artifact extracted for p2:p2:0.0.0-fixed-id Some(cached-compile)
[info] remote cache artifact extracted for p9:p9:0.0.0-fixed-id Some(cached-compile)
[info] remote cache artifact extracted for p8:p8:0.0.0-fixed-id Some(cached-compile)
[info] remote cache artifact extracted for p7:p7:0.0.0-fixed-id Some(cached-compile)
[info] remote cache artifact extracted for p5:p5:0.0.0-fixed-id Some(cached-compile)
[info] remote cache artifact extracted for p1:p1:0.0.0-fixed-id Some(cached-compile)
[info] remote cache artifact extracted for p5:p5:0.0.0-fixed-id Some(cached-test)
[info] remote cache artifact extracted for p7:p7:0.0.0-fixed-id Some(cached-test)
[info] remote cache artifact extracted for p2:p2:0.0.0-fixed-id Some(cached-test)
[info] remote cache artifact extracted for p8:p8:0.0.0-fixed-id Some(cached-test)
[info] remote cache artifact extracted for p9:p9:0.0.0-fixed-id Some(cached-test)
[info] remote cache artifact extracted for p1:p1:0.0.0-fixed-id Some(cached-test)
[info] remote cache artifact extracted for p3:p3:0.0.0-fixed-id Some(cached-compile)
[info] remote cache artifact extracted for p3:p3:0.0.0-fixed-id Some(cached-test)
[info] remote cache artifact extracted for p4:p4:0.0.0-fixed-id Some(cached-compile)
[info] remote cache artifact extracted for p4:p4:0.0.0-fixed-id Some(cached-test)
[info] remote cache artifact extracted for p6:p6:0.0.0-fixed-id Some(cached-compile)
[info] remote cache artifact extracted for p6:p6:0.0.0-fixed-id Some(cached-test)
```
2020-10-20 23:13:33 +09:00
eugene yokota 9f7985a2d9
Merge pull request #5991 from eed3si9n/wip/release-lint
Exclude keys starting with some prefixes from linting
2020-10-19 15:36:33 -04:00
eugene yokota 73ba82f390
Merge pull request #5990 from eed3si9n/wip/cfm-logger
Properly log the ClassfileManager output
2020-10-19 14:51:04 -04:00