Merge pull request #3782 from eed3si9n/wip/bump

Merge 1.0.x + bump modules
This commit is contained in:
eugene yokota 2017-11-30 10:23:14 -05:00 committed by GitHub
commit 74ddddc8e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 530 additions and 193 deletions

View File

@ -108,7 +108,9 @@ lazy val sbtRoot: Project = (project in file("."))
Transform.conscriptSettings(bundledLauncherProj),
publish := {},
publishLocal := {},
skip in publish := true
skip in publish := true,
commands in Global += Command.single("sbtOn")((state, dir) =>
s"sbtProj/test:runMain sbt.RunFromSourceMain $dir" :: state),
)
// This is used to configure an sbt-launcher for this version of sbt.
@ -429,28 +431,38 @@ lazy val mainProj = (project in file("main"))
// with the sole purpose of providing certain identifiers without qualification (with a package object)
lazy val sbtProj = (project in file("sbt"))
.dependsOn(mainProj, scriptedSbtProj % "test->test")
.enablePlugins(BuildInfoPlugin)
.settings(
baseSettings,
name := "sbt",
normalizedName := "sbt",
crossScalaVersions := Seq(baseScalaVersion),
crossPaths := false,
javaOptions ++= Seq("-Xdebug", "-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005"),
mimaSettings,
mimaBinaryIssueFilters ++= Vector(
// Added more items to Import trait.
exclude[ReversedMissingMethodProblem]("sbt.Import.sbt$Import$_setter_$WatchSource_="),
exclude[ReversedMissingMethodProblem]("sbt.Import.WatchSource"),
// Dropped in favour of kind-projector's polymorphic lambda literals
exclude[DirectMissingMethodProblem]("sbt.Import.Param"),
exclude[DirectMissingMethodProblem]("sbt.package.Param"),
// Dropped in favour of plain scala.Function, and its compose method
exclude[DirectMissingMethodProblem]("sbt.package.toFn1"),
)
mimaBinaryIssueFilters ++= sbtIgnoredProblems,
addBuildInfoToConfig(Test),
buildInfoObject in Test := "TestBuildInfo",
buildInfoKeys in Test := Seq[BuildInfoKey](fullClasspath in Compile),
connectInput in run in Test := true,
)
.configure(addSbtCompilerBridge)
lazy val sbtIgnoredProblems = {
Vector(
// Added more items to Import trait.
exclude[ReversedMissingMethodProblem]("sbt.Import.sbt$Import$_setter_$WatchSource_="),
exclude[ReversedMissingMethodProblem]("sbt.Import.WatchSource"),
// Dropped in favour of kind-projector's polymorphic lambda literals
exclude[DirectMissingMethodProblem]("sbt.Import.Param"),
exclude[DirectMissingMethodProblem]("sbt.package.Param"),
// Dropped in favour of plain scala.Function, and its compose method
exclude[DirectMissingMethodProblem]("sbt.package.toFn1"),
)
}
def runNpm(command: String, base: File, log: sbt.internal.util.ManagedLogger) = {
val npm = if (sbt.internal.util.Util.isWindows) "npm.cmd" else "npm"
import scala.sys.process._

View File

@ -13,6 +13,7 @@ import sbt.internal.inc.Analysis
import TaskExtra._
import sbt.internal.util.FeedbackProvidedException
import xsbti.api.Definition
import xsbti.api.ClassLike
import xsbti.compile.CompileAnalysis
import ConcurrentRestrictions.Tag
@ -389,7 +390,11 @@ object Tests {
defined(subclasses, d.baseClasses, d.isModule) ++
defined(annotations, d.annotations, d.isModule)
val discovered = Discovery(firsts(subclasses), firsts(annotations))(definitions)
val discovered = Discovery(firsts(subclasses), firsts(annotations))(definitions.filter {
case c: ClassLike =>
c.topLevel
case _ => false
})
// TODO: To pass in correct explicitlySpecified and selectors
val tests = for ((df, di) <- discovered; fingerprint <- toFingerprints(di))
yield new TestDefinition(df.name, fingerprint, false, Array(new SuiteSelector))

View File

@ -9,7 +9,8 @@ package sbt
package internal
package client
import java.net.{ URI, Socket, InetAddress, SocketException }
import java.io.IOException
import java.net.{ URI, Socket, InetAddress }
import java.util.UUID
import java.util.concurrent.atomic.{ AtomicBoolean, AtomicReference }
import scala.collection.mutable.ListBuffer
@ -111,7 +112,7 @@ class NetworkClient(arguments: List[String]) { self =>
try {
connection.publish(bytes)
} catch {
case _: SocketException =>
case _: IOException =>
// log.debug(e.getMessage)
// toDel += client
}

View File

@ -327,11 +327,13 @@ object Defaults extends BuildCommon {
excludeFilter in unmanagedSources).value,
watchSources in ConfigGlobal ++= {
val baseDir = baseDirectory.value
val bases = unmanagedSourceDirectories.value ++ (if (sourcesInBase.value) Seq(baseDir)
else Seq.empty)
val bases = unmanagedSourceDirectories.value
val include = (includeFilter in unmanagedSources).value
val exclude = (excludeFilter in unmanagedSources).value
bases.map(b => new Source(b, include, exclude))
val baseSources =
if (sourcesInBase.value) Seq(new Source(baseDir, include, exclude, recursive = false))
else Nil
bases.map(b => new Source(b, include, exclude)) ++ baseSources
},
managedSourceDirectories := Seq(sourceManaged.value),
managedSources := generate(sourceGenerators).value,
@ -777,21 +779,24 @@ object Defaults extends BuildCommon {
}
def intlStamp(c: String, analysis: Analysis, s: Set[String]): Long = {
if (s contains c) Long.MinValue
else {
val x = {
import analysis.{ relations => rel, apis }
rel.internalClassDeps(c).map(intlStamp(_, analysis, s + c)) ++
rel.externalDeps(c).map(stamp) +
(apis.internal.get(c) match {
case Some(x) => x.compilationTimestamp
case _ => Long.MinValue
})
}.max
if (x != Long.MinValue) {
stamps(c) = x
}
x
}
else
stamps.getOrElse(
c, {
val x = {
import analysis.{ relations => rel, apis }
rel.internalClassDeps(c).map(intlStamp(_, analysis, s + c)) ++
rel.externalDeps(c).map(stamp) +
(apis.internal.get(c) match {
case Some(x) => x.compilationTimestamp
case _ => Long.MinValue
})
}.max
if (x != Long.MinValue) {
stamps(c) = x
}
x
}
)
}
def noSuccessYet(test: String) = succeeded.get(test) match {
case None => true

View File

@ -8,7 +8,7 @@
package sbt
package internal
import java.net.SocketException
import java.io.IOException
import java.util.concurrent.ConcurrentLinkedQueue
import java.util.concurrent.atomic.AtomicInteger
import scala.collection.mutable.ListBuffer
@ -170,7 +170,7 @@ private[sbt] final class CommandExchange {
try {
c.notifyEvent(method, params)
} catch {
case _: SocketException =>
case _: IOException =>
toDel += c
}
}
@ -213,7 +213,7 @@ private[sbt] final class CommandExchange {
}
}
} catch {
case _: SocketException =>
case _: IOException =>
toDel += c
}
}
@ -225,7 +225,7 @@ private[sbt] final class CommandExchange {
try {
c.publishEvent(event)
} catch {
case _: SocketException =>
case _: IOException =>
toDel += c
}
}
@ -267,7 +267,7 @@ private[sbt] final class CommandExchange {
try {
c.publishObjectEvent(event)
} catch {
case _: SocketException =>
case _: IOException =>
toDel += c
}
}
@ -305,7 +305,7 @@ private[sbt] final class CommandExchange {
c.publishEventMessage(event)
}
} catch {
case e: SocketException =>
case e: IOException =>
toDel += c
}
}
@ -317,7 +317,7 @@ private[sbt] final class CommandExchange {
try {
c.publishEventMessage(event)
} catch {
case _: SocketException =>
case _: IOException =>
toDel += c
}
}

View File

@ -109,6 +109,14 @@ object LogManager {
}
}
// to change from global being the default to overriding, switch the order of state.get and data.get
def getOr[T](key: AttributeKey[T],
data: Settings[Scope],
scope: Scope,
state: State,
default: T): T =
data.get(scope, key) orElse state.get(key) getOrElse default
// This is the main function that is used to generate the logger for tasks.
def defaultLogger(
data: Settings[Scope],
@ -125,13 +133,10 @@ object LogManager {
val execId: Option[String] = execOpt flatMap { _.execId }
val log = LogExchange.logger(loggerName, channelName, execId)
val scope = task.scope
// to change from global being the default to overriding, switch the order of state.get and data.get
def getOr[T](key: AttributeKey[T], default: T): T =
data.get(scope, key) orElse state.get(key) getOrElse default
val screenLevel = getOr(logLevel.key, Level.Info)
val backingLevel = getOr(persistLogLevel.key, Level.Debug)
val screenTrace = getOr(traceLevel.key, defaultTraceLevel(state))
val backingTrace = getOr(persistTraceLevel.key, Int.MaxValue)
val screenLevel = getOr(logLevel.key, data, scope, state, Level.Info)
val backingLevel = getOr(persistLogLevel.key, data, scope, state, Level.Debug)
val screenTrace = getOr(traceLevel.key, data, scope, state, defaultTraceLevel(state))
val backingTrace = getOr(persistTraceLevel.key, data, scope, state, Int.MaxValue)
val extraBacked = state.globalLogging.backed :: relay :: Nil
val consoleOpt = consoleLocally(state, console)
val config = MainAppender.MainAppenderConfig(
@ -188,6 +193,9 @@ object LogManager {
relay: Appender,
extra: List[Appender]
): ManagedLogger = {
val scope = task.scope
val screenLevel = getOr(logLevel.key, data, scope, state, Level.Info)
val backingLevel = getOr(persistLogLevel.key, data, scope, state, Level.Debug)
val execOpt = state.currentCommand
val loggerName: String = s"bg-${task.key.label}-${generateId.incrementAndGet}"
val channelName: Option[String] = execOpt flatMap (_.source map (_.channelName))
@ -197,7 +205,7 @@ object LogManager {
val consoleOpt = consoleLocally(state, console)
LogExchange.bindLoggerAppenders(
loggerName,
(consoleOpt.toList map { _ -> Level.Debug }) ::: (relay -> Level.Debug) :: Nil)
(consoleOpt.toList map { _ -> screenLevel }) ::: (relay -> backingLevel) :: Nil)
log
}

View File

@ -116,7 +116,9 @@ private[sbt] object SbtParser {
scalacGlobalInitReporter = Some(new ConsoleReporter(settings))
// Mix Positions, otherwise global ignores -Yrangepos
val global = new Global(settings, globalReporter) with Positions
val global = new Global(settings, globalReporter) with Positions {
override protected def synchronizeNames = true // https://github.com/scala/bug/issues/10605
}
val run = new global.Run
// Add required dummy unit for initialization...
val initFile = new BatchSourceFile("<wrapper-init>", "")

View File

@ -1,7 +0,0 @@
### Bug fixes
- Fixes `addSbtPlugin` to use the correct version of sbt. [#3393][]/[#3397][] by [@dwijnand][]
[#3393]: https://github.com/sbt/sbt/issues/3393
[#3397]: https://github.com/sbt/sbt/pull/3397
[@dwijnand]: http://github.com/dwijnand

61
notes/1.0.3.markdown Normal file
View File

@ -0,0 +1,61 @@
This is a hotfix release for sbt 1.0.x series.
### Bug fixes
- Fixes `~` recompiling in loop (when a source generator or sbt-buildinfo is present). [#3501][3501]/[#3634][3634] by [@dwijnand][@dwijnand]
- Fixes undercompilation on inheritance on same source. [zinc#424][zinc424] by [@eed3si9n][@eed3si9n]
- Fixes the compilation of package-protected objects. [zinc#431][zinc431] by [@jvican][@jvican]
- Workaround for Java returning `null` for `getGenericParameterTypes`. [zinc#446][zinc446] by [@jvican][@jvican]
- Fixes test detection regression. sbt 1.0.3 filters out nested objects/classes from the list, restoring compatibility with 0.13. [#3669][3669] by [@cunei][@cunei]
- Uses Scala 2.12.4 for the build definition. This includes fix for runtime reflection of empty package members under Java 9. [#3587][3587] by [@eed3si9n][@eed3si9n]
- Fixes extra `/` in Ivy style patterns. [lm#170][lm170] by [@laughedelic][@laughedelic]
- Fixes "destination file exist" error message by including the file name. [lm171][lm171] by [@leonardehrenfried][@leonardehrenfried]
- Fixes JDK 9 warning "Illegal reflective access" in library management module and Ivy. [lm173][lm173] by [@dwijnand][@dwijnand]
### Improvements
- Adds `sbt.watch.mode` system property to allow switching back to old polling behaviour for watch. See below for more details.
#### Alternative watch mode
sbt 1.0.0 introduced a new mechanism for watching for source changes based on the NIO `WatchService` in Java 1.7. On
some platforms (namely macOS) this has led to long delays before changes are picked up. An alternative `WatchService`
for these platforms is planned for sbt 1.1.0 ([#3527][3527]), in the meantime an option to select which watch service
has been added.
The new `sbt.watch.mode` JVM flag has been added with the following supported values:
- `polling`: (default for macOS) poll the filesystem for changes (mechanism used in sbt 0.13).
- `nio` (default for other platforms): use the NIO based `WatchService`.
If you are experiencing long delays on a non-macOS machine then try adding `-Dsbt.watch.mode=polling` to your sbt
options.
[#3597][3597] by [@stringbean][@stringbean]
### Contributors
A huge thank you to everyone who's helped improve sbt and Zinc 1 by using them, reporting bugs, improving our documentation, porting builds, porting plugins, and submitting and reviewing pull requests.
This release was brought to you by 15 contributors, according to `git shortlog -sn --no-merges v1.0.2..v1.0.3` on sbt, zinc, librarymanagement, util, io, and website: Eugene Yokota, Dale Wijnand, Michael Stringer, Jorge Vicente Cantero (jvican), Alexey Alekhin, Antonio Cunei, Andrey Artemov, Jeffrey Olchovy, Kenji Yoshida (xuwei-k), Dominik Winter, Long Jinwei, Arnout Engelen, Justin Kaeser, Leonard Ehrenfried, Sakib Hadžiavdić. Thank you!
[@dwijnand]: https://github.com/dwijnand
[@cunei]: https://github.com/cunei
[@eed3si9n]: https://github.com/eed3si9n
[@jvican]: https://github.com/jvican
[@stringbean]: https://github.com/stringbean
[@laughedelic]: https://github.com/laughedelic
[@leonardehrenfried]: https://github.com/leonardehrenfried
[3669]: https://github.com/sbt/sbt/pull/3669
[3583]: https://github.com/sbt/sbt/issues/3583
[3587]: https://github.com/sbt/sbt/issues/3587
[3527]: https://github.com/sbt/sbt/issues/3527
[3597]: https://github.com/sbt/sbt/pull/3597
[3501]: https://github.com/sbt/sbt/issues/3501
[3634]: https://github.com/sbt/sbt/pull/3634
[lm170]: https://github.com/sbt/librarymanagement/pull/170
[lm171]: https://github.com/sbt/librarymanagement/pull/171
[lm173]: https://github.com/sbt/librarymanagement/pull/173
[zinc424]: https://github.com/sbt/zinc/pull/424
[zinc431]: https://github.com/sbt/zinc/pull/431
[zinc446]: https://github.com/sbt/zinc/pull/446

View File

@ -1,9 +0,0 @@
[@panaeon]: https://github.com/panaeon
[#3464]: https://github.com/sbt/sbt/issues/3464
[#3566]: https://github.com/sbt/sbt/pull/3566
### Bug fixes
- Escape imports from sbt files, so if user creates a backquoted definition then task evalution will not fail.

View File

@ -1,26 +0,0 @@
### Fixes with compatibility implications
### Improvements
- Add `sbt.watch.mode` system property to allow switching back to old polling behaviour for watch. See below for more details. [#3597][3597] by [@stringbean][@stringbean]
### Bug fixes
#### Alternative watch mode
sbt 1.0.0 introduced a new mechanism for watching for source changes based on the NIO `WatchService` in Java 1.7. On
some platforms (namely macOS) this has led to long delays before changes are picked up. An alternative `WatchService`
for these platforms is planned for sbt 1.1.0 ([#3527][3527]), in the meantime an option to select which watch service
has been added.
The new `sbt.watch.mode` JVM flag has been added with the following supported values:
- `polling`: (default for macOS) poll the filesystem for changes (mechanism used in sbt 0.13).
- `nio` (default for other platforms): use the NIO based `WatchService`.
If you are experiencing long delays on a non-macOS machine then try adding `-Dsbt.watch.mode=polling` to your sbt
options.
[@stringbean]: https://github.com/stringbean
[3527]: https://github.com/sbt/sbt/issues/3527
[3597]: https://github.com/sbt/sbt/pull/3597

51
notes/1.0.4.markdown Normal file
View File

@ -0,0 +1,51 @@
This is a hotfix release for sbt 1.0.x series.
### Bug fixes
- Fixes undercompilation of value classes when the underlying type changes. [zinc#444][zinc444] by [@smarter][@smarter]
- Fixes `ArrayIndexOutOfBoundsException` on Ivy when running on Java 9. [ivy#27][ivy27] by [@xuwei-k][@xuwei-k]
- Fixes Java 9 warning by upgrading to launcher 1.0.2. [ivy#26][ivy26]/[launcher#45][launcher45] by [@dwijnand][@dwijnand]
- Fixes `run` outputing debug level logs. [#3655][3655]/[#3717][3717] by [@cunei][@cunei]
- Fixes performance regression caused by classpath hashing. [zinc#452][zinc452] by [@jvican][@jvican]
- Fixes performance regression of `testQuick`. [#3680][3680]/[#3720][3720] by [@OlegYch][@OlegYch]
- Disables Ivy log4j caller location calculation for performance regression reported in [#3711][3711]. [util#132][util132] by [@leonardehrenfried][@leonardehrenfried]
- Works around Scala compiler's `templateStats()` not being thread-safe. [#3743][3743] by [@cunei][@cunei]
- Fixes "Attempting to overwrite" error message. [lm#174][lm174] by [@dwijnand][@dwijnand]
- Fixes incorrect eviction warning message. [lm#179][lm179] by [@xuwei-k][@xuwei-k]
- Registers Ivy protocol only for `http:` and `https:` to be more plugin friendly. [lm183][lm183] by [@tpunder][@tpunder]
### Enhancement
- Adds Scala 2.13.0-M2 support. [zinc#453][zinc453] by [@eed3si9n][@eed3si9n] and [@jan0sch][@jan0sch]
### Internal
- Improves Zinc scripted testing. [zinc440][zinc#440] by [@jvican][@jvican]
[@dwijnand]: https://github.com/dwijnand
[@cunei]: https://github.com/cunei
[@eed3si9n]: https://github.com/eed3si9n
[@jvican]: https://github.com/jvican
[@OlegYch]: https://github.com/OlegYch
[@leonardehrenfried]: https://github.com/leonardehrenfried
[@xuwei-k]: https://github.com/xuwei-k
[@tpunder]: https://github.com/tpunder
[@smarter]: https://github.com/smarter
[@jan0sch]: https://github.com/jan0sch
[3655]: https://github.com/sbt/sbt/issues/3655
[3717]: https://github.com/sbt/sbt/pull/3717
[ivy26]: https://github.com/sbt/ivy/pull/26
[ivy27]: https://github.com/sbt/ivy/pull/27
[launcher45]: https://github.com/sbt/launcher/pull/45
[3680]: https://github.com/sbt/sbt/issues/3680
[3720]: https://github.com/sbt/sbt/pull/3720
[3743]: https://github.com/sbt/sbt/pull/3743
[3711]: https://github.com/sbt/sbt/issues/3711
[util132]: https://github.com/sbt/util/pull/132
[lm174]: https://github.com/sbt/librarymanagement/pull/174
[lm179]: https://github.com/sbt/librarymanagement/pull/179
[lm183]: https://github.com/sbt/librarymanagement/pull/183
[zinc452]: https://github.com/sbt/zinc/pull/452
[zinc444]: https://github.com/sbt/zinc/pull/444
[zinc453]: https://github.com/sbt/zinc/pull/453
[zinc440]: https://github.com/sbt/zinc/pull/440

170
notes/1.1.0.markdown Normal file
View File

@ -0,0 +1,170 @@
### Features, fixes, changes with compatibility implications
- sbt server feature is reworked in sbt 1.1.0. See below.
- Changes `version` setting default to `0.1.0-SNAPSHOT` for compatibility with Semantic Versioning. [#3577][3577] by [@laughedelic][@laughedelic]
### Features
- Unifies sbt shell and build.sbt syntax. See below.
### Fixes
- Fixes over-compilation bug with Java 9. [zinc#450][zinc450] by [@retronym][@retronym]
- Fixes handling of deeply nested Java classes. [zinc#423][zinc423] by [@romanowski][@romanowski]
- Fixes JavaDoc not printing all errors. [zinc#415][zinc415] by [@raboof][@raboof]
- Preserves JAR order in `ScalaInstance.otherJars`. [zinc#411][zinc411] by [@dwijnand][@dwijnand]
- Fixes used name when it contains NL. [zinc#449][zinc449] by [@jilen][@jilen]
- Fixes handling of `ThisProject`. [#3609][3609] by [@dwijnand][@dwijnand]
- Escapes imports from sbt files, so if user creates a backquoted definition then task evalution will not fail. [#3635][3635] by [@panaeon][@panaeon]
- Removes reference to version 0.14.0 from a warning message. [#3693][3693] by [@saniyatech][@saniyatech]
- Fixes screpl throwing "Not a valid key: console-quick". [#3762][3762] by [@xuwei-k][@xuwei-k]
### Improvements
- Filters scripted tests based on optional `project/build.properties`. See below.
- Adds `Project#withId` to change a project's id. [#3601][3601] by [@dwijnand][@dwijnand]
- Adds `reboot dev` command, which deletes the current artifact from the boot directory. This is useful when working with development versions of sbt. [#3659][3659] by [@eed3si9n][@eed3si9n]
- Adds a check for a change in sbt version before `reload`. [#1055][1055]/[#3673][3673] by [@RomanIakovlev][@RomanIakovlev]
- Adds a new setting `insideCI`, which indicates that sbt is likely running in an Continuous Integration environment. [#3672][3672] by [@RomanIakovlev][@RomanIakovlev]
- Adds `nameOption` to `Command` trait. [#3671][3671] by [@miklos-martin][@miklos-martin]
- Adds POSIX persmission operations in IO, such as `IO.chmod(..)`. [io#76][io76] by [@eed3si9n][@eed3si9n]
- Treat sbt 1 modules using Semantic Versioning in the eviction warning. [lm#188][lm188] by [@eed3si9n][@eed3si9n]
- Uses kind-projector in the code. [#3650][3650] by [@dwijnand][@dwijnand]
- Make `displayOnly` etc methods strict in `Completions`. [#3763][3763] by [@xuwei-k][@xuwei-k]
### Unified slash syntax for sbt shell and build.sbt
This adds unified slash syntax for both sbt shell and the build.sbt DSL.
Instead of the current `<project-id>/config:intask::key`, this adds
`<project-id>/<config-ident>/intask/key` where `<config-ident>` is the Scala identifier
notation for the configurations like `Compile` and `Test`. (The old shell syntax will continue to function)
These examples work both from the shell and in build.sbt.
Global / cancelable
ThisBuild / scalaVersion
Test / test
root / Compile / compile / scalacOptions
ProjectRef(uri("file:/xxx/helloworld/"),"root")/Compile/scalacOptions
Zero / Zero / name
The inspect command now outputs something that can be copy-pasted:
> inspect compile
[info] Task: sbt.inc.Analysis
[info] Description:
[info] Compiles sources.
[info] Provided by:
[info] ProjectRef(uri("file:/xxx/helloworld/"),"root")/Compile/compile
[info] Defined at:
[info] (sbt.Defaults) Defaults.scala:326
[info] Dependencies:
[info] Compile/manipulateBytecode
[info] Compile/incCompileSetup
....
[#1812][1812]/[#3434][3434]/[#3617][3617]/[#3620][3620] by [@eed3si9n][@eed3si9n] and [@dwijnand][@dwijnand]
### sbt server
sbt server feature was reworked to use Language Server Protocol 3.0 (LSP) as the wire protocol, a protocol created by Microsoft for Visual Studio Code.
To discover a running server, sbt 1.1.0 creates a port file at `./project/target/active.json` relative to a build:
```
{"uri":"local:///Users/foo/.sbt/1.0/server/0845deda85cb41abcdef/sock"}
```
`local:` indicates a UNIX domain socket. Here's how we can say hello to the server using `nc`. (`^M` can be sent `Ctrl-V` then `Return`):
```
$ nc -U /Users/foo/.sbt/1.0/server/0845deda85cb41abcdef/sock
Content-Length: 99^M
^M
{ "jsonrpc": "2.0", "id": 1, "method": "initialize", "params": { "initializationOptions": { } } }^M
```
sbt server adds network access to sbt's shell command so, in addition to accepting input from the terminal, server also to accepts input from the network. Here's how we can call `compile`:
```
Content-Length: 93^M
^M
{ "jsonrpc": "2.0", "id": 2, "method": "sbt/exec", "params": { "commandLine": "compile" } }^M
```
The running sbt session should now queue `compile`, and return back with compiler warnings and errors, if any:
```
Content-Length: 296
Content-Type: application/vscode-jsonrpc; charset=utf-8
{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:/Users/foo/work/hellotest/Hello.scala","diagnostics":[{"range":{"start":{"line":2,"character":26},"end":{"line":2,"character":27}},"severity":1,"source":"sbt","message":"object X is not a member of package foo"}]}}
```
[#3524][3524]/[#3556][3556] by [@eed3si9n][@eed3si9n]
### VS Code extension
The primary use case we have in mind for the sbt server is tooling integration such as editors and IDEs. As a proof of concept, we created a Visual Studio Code extension called [Scala (sbt)][vscode-sbt-scala].
Currently this extension is able to:
- Run `compile` at the root project when `*.scala` files are saved. [#3524][3524] by [@eed3si9n][@eed3si9n]
- Display compiler errors.
- Display log messages. [#3740][3740] by [@laughedelic][@laughedelic]
- Jump to class definitions. [#3660][3660]
### Filtering scripted tests using `project/build.properties`
For all scripted tests in which `project/build.properties` exist, the value of the `sbt.version` property is read. If its binary version is different from `sbtBinaryVersion in pluginCrossBuild` the test will be skipped and a message indicating this will be logged.
This allows you to define scripted tests that track the minimum supported sbt versions, e.g. 0.13.9 and 1.0.0-RC2. [#3564][3564]/[#3566][3566] by [@jonas][@jonas]
[@eed3si9n]: https://github.com/eed3si9n
[@dwijnand]: http://github.com/dwijnand
[@jvican]: https://github.com/jvican
[@Duhemm]: https://github.com/Duhemm
[@jonas]: https://github.com/jonas
[@laughedelic]: https://github.com/laughedelic
[@panaeon]: https://github.com/panaeon
[@RomanIakovlev]: https://github.com/RomanIakovlev
[@miklos-martin]: https://github.com/miklos-martin
[@saniyatech]: https://github.com/saniyatech
[@xuwei-k]: https://github.com/xuwei-k
[@wpopielarski]: https://github.com/wpopielarski
[@retronym]: https://github.com/retronym
[@romanowski]: https://github.com/romanowski
[@raboof]: https://github.com/raboof
[@jilen]: https://github.com/jilen
[vscode-sbt-scala]: https://marketplace.visualstudio.com/items?itemName=lightbend.vscode-sbt-scala
[1812]: https://github.com/sbt/sbt/issues/1812
[3524]: https://github.com/sbt/sbt/pull/3524
[3556]: https://github.com/sbt/sbt/pull/3556
[3564]: https://github.com/sbt/sbt/issues/3564
[3566]: https://github.com/sbt/sbt/pull/3566
[3577]: https://github.com/sbt/sbt/pull/3577
[3434]: https://github.com/sbt/sbt/pull/3434
[3601]: https://github.com/sbt/sbt/pull/3601
[3609]: https://github.com/sbt/sbt/pull/3609
[3617]: https://github.com/sbt/sbt/pull/3617
[3620]: https://github.com/sbt/sbt/pull/3620
[3464]: https://github.com/sbt/sbt/issues/3464
[3635]: https://github.com/sbt/sbt/pull/3635
[3659]: https://github.com/sbt/sbt/pull/3659
[3650]: https://github.com/sbt/sbt/pull/3650
[3673]: https://github.com/sbt/sbt/pull/3673
[1055]: https://github.com/sbt/sbt/issues/1055
[3672]: https://github.com/sbt/sbt/pull/3672
[3671]: https://github.com/sbt/sbt/pull/3671
[3693]: https://github.com/sbt/sbt/issues/3693
[3763]: https://github.com/sbt/sbt/pull/3763
[3762]: https://github.com/sbt/sbt/pull/3762
[3740]: https://github.com/sbt/sbt/pull/3740
[3660]: https://github.com/sbt/sbt/pull/3660
[io76]: https://github.com/sbt/io/pull/76
[lm188]: https://github.com/sbt/librarymanagement/pull/188
[zinc450]: https://github.com/sbt/zinc/pull/450
[zinc423]: https://github.com/sbt/zinc/pull/423
[zinc415]: https://github.com/sbt/zinc/issues/415
[zinc411]: https://github.com/sbt/zinc/pull/411
[zinc449]: https://github.com/sbt/zinc/pull/449

View File

@ -1,14 +0,0 @@
[@jonas]: https://github.com/jonas
[#3564]: https://github.com/sbt/sbt/issues/3564
[#3566]: https://github.com/sbt/sbt/pull/3566
### Improvements
- Filter scripted tests based on optional `project/build.properties`. [#3564]/[#3566] by [@jonas]
### Filtering scripted tests using `project/build.properties`.
For all scripted tests in which `project/build.properties` exist, the value of the `sbt.version` property is read. If its binary version is different from `sbtBinaryVersion in pluginCrossBuild` the test will be skipped and a message indicating this will be logged.
This allows you to define scripted tests that track the minimum supported sbt versions, e.g. 0.13.9 and 1.0.0-RC2.

View File

@ -1,3 +0,0 @@
### Improvements
- Changes `version` setting default to `0.1.0-SNAPSHOT` for compatibility with Semantic Versioning

View File

@ -1,11 +0,0 @@
[@dwijnand]: https://github.com/dwijnand
[#3601]: https://github.com/sbt/sbt/pull/3601
### Fixes with compatibility implications
### Improvements
- Adds `Project#withId` to change a project's id. [#3601][] by [@dwijnand][]
### Bug fixes

View File

@ -1,3 +0,0 @@
### Improvements
- Adds `reboot dev` command, which deletes the current artifact from the boot directory. This is useful when working with development versions of sbt.

View File

@ -1,11 +0,0 @@
[@saniyatech]: https://github.com/saniyatech
[#3693]: https://github.com/sbt/sbt/issues/3693
### Bug fixes
- Removes reference to version 0.14.0 from a warning message. [#3693][] by [@saniyatech][]
### Improvements
### Fixes with compatibility implications

View File

@ -1,49 +0,0 @@
### Fixes with compatibility implications
-
### Improvements
- Unifies sbt shell and build.sbt syntax. See below.
### Bug fixes
-
### Unified slash syntax for sbt shell and build.sbt
This adds unified slash syntax for both sbt shell and the build.sbt DSL.
Instead of the current `<project-id>/config:intask::key`, this adds
`<project-id>/<config-ident>/intask/key` where `<config-ident>` is the Scala identifier
notation for the configurations like `Compile` and `Test`. (The old shell syntax will continue to function)
These examples work both from the shell and in build.sbt.
Global / cancelable
ThisBuild / scalaVersion
Test / test
root / Compile / compile / scalacOptions
ProjectRef(uri("file:/xxx/helloworld/"),"root")/Compile/scalacOptions
Zero / Zero / name
The inspect command now outputs something that can be copy-pasted:
> inspect compile
[info] Task: sbt.inc.Analysis
[info] Description:
[info] Compiles sources.
[info] Provided by:
[info] ProjectRef(uri("file:/xxx/helloworld/"),"root")/Compile/compile
[info] Defined at:
[info] (sbt.Defaults) Defaults.scala:326
[info] Dependencies:
[info] Compile/manipulateBytecode
[info] Compile/incCompileSetup
....
[#3434][3434] by [@eed3si9n][@eed3si9n]
[3434]: https://github.com/sbt/sbt/pull/3434
[@eed3si9n]: https://github.com/eed3si9n
[@dwijnand]: http://github.com/dwijnand

View File

@ -6,16 +6,16 @@ object Dependencies {
val scala282 = "2.8.2"
val scala292 = "2.9.2"
val scala293 = "2.9.3"
val scala210 = "2.10.6"
val scala211 = "2.11.8"
val scala212 = "2.12.3"
val scala210 = "2.10.7"
val scala211 = "2.11.12"
val scala212 = "2.12.4"
val baseScalaVersion = scala212
// sbt modules
private val ioVersion = "1.1.0"
private val utilVersion = "1.0.2"
private val lmVersion = "1.0.2"
private val zincVersion = "1.0.2"
private val ioVersion = "1.1.1"
private val utilVersion = "1.1.0"
private val lmVersion = "1.1.0"
private val zincVersion = "1.1.0-RC1"
private val sbtIO = "org.scala-sbt" %% "io" % ioVersion
@ -30,8 +30,8 @@ object Dependencies {
private val libraryManagementCore = "org.scala-sbt" %% "librarymanagement-core" % lmVersion
private val libraryManagementIvy = "org.scala-sbt" %% "librarymanagement-ivy" % lmVersion
val launcherInterface = "org.scala-sbt" % "launcher-interface" % "1.0.0"
val rawLauncher = "org.scala-sbt" % "launcher" % "1.0.0"
val launcherInterface = "org.scala-sbt" % "launcher-interface" % "1.0.2"
val rawLauncher = "org.scala-sbt" % "launcher" % "1.0.2"
val testInterface = "org.scala-sbt" % "test-interface" % "1.0"
private val compilerInterface = "org.scala-sbt" % "compiler-interface" % zincVersion
@ -101,7 +101,7 @@ object Dependencies {
}
val jline = "jline" % "jline" % "2.14.4"
val scalatest = "org.scalatest" %% "scalatest" % "3.0.1"
val scalatest = "org.scalatest" %% "scalatest" % "3.0.4"
val scalaCheck = "org.scalacheck" %% "scalacheck" % "1.13.4"
val specs2 = "org.specs2" %% "specs2-junit" % "4.0.1"
val junit = "junit" % "junit" % "4.11"

View File

@ -108,6 +108,8 @@ object Scripted {
prescripted: File => Unit,
launchOpts: Seq[String]): Unit = {
System.err.println(s"About to run tests: ${args.mkString("\n * ", "\n * ", "\n")}")
// Force Log4J to not use a thread context classloader otherwise it throws a CCE
sys.props(org.apache.logging.log4j.util.LoaderUtil.IGNORE_TCCL_PROPERTY) = "true"
val noJLine = new classpath.FilteredLoader(scriptedSbtInstance.loader, "jline." :: Nil)
val loader = classpath.ClasspathUtilities.toLoader(scriptedSbtClasspath.files, noJLine)
val bridgeClass = Class.forName("sbt.test.ScriptedRunner", true, loader)

View File

@ -12,3 +12,4 @@ addSbtPlugin("org.scala-sbt" % "sbt-contraband" % "0.3.1")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.0-M1")
addSbtPlugin("com.lucidchart" % "sbt-scalafmt" % "1.14")
addSbtPlugin("de.heikoseeberger" % "sbt-header" % "3.0.2")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.7.0")

View File

@ -0,0 +1,8 @@
libraryDependencies += "org.scalacheck" %% "scalacheck" % "1.13.5" % "test"
version := "0.0.1"
name := "broken"
organization := "org.catastrophe"
//scalaVersion := "2.10.6"
scalaVersion := "2.12.3"

View File

@ -0,0 +1,25 @@
package q
//
// On 1.0.3+ this test will say:
// [info] + Nesting.startsWith: OK, passed 100 tests.
// [info] Passed: Total 1, Failed 0, Errors 0, Passed 1
//
// On 1.0.0 to 1.0.2 it will crash with:
// [error] java.lang.ClassNotFoundException: q.X.Y$
//
import org.scalacheck.{Prop, Properties}
import Prop.forAll
class U extends Properties("Nesting")
object X extends U {
property("startsWith") = forAll { (a: String, b: String) =>
(a+b).startsWith(a)
}
object Y extends U {
property("endsWith") = forAll { (a: String, b: String) =>
(a+b).endsWith(b)
}
}
}

View File

@ -0,0 +1,2 @@
> test

View File

@ -0,0 +1,117 @@
/*
* sbt
* Copyright 2011 - 2017, Lightbend, Inc.
* Copyright 2008 - 2010, Mark Harrah
* Licensed under BSD-3-Clause license (see LICENSE)
*/
package sbt
import scala.annotation.tailrec
import xsbti._
object RunFromSourceMain {
private val sbtVersion = "1.0.3" // "dev"
private val scalaVersion = "2.12.4"
def main(args: Array[String]): Unit = args match {
case Array() => sys.error(s"Must specify working directory as the first argument")
case Array(wd, args @ _*) => run(file(wd), args)
}
// this arrangement is because Scala does not always properly optimize away
// the tail recursion in a catch statement
@tailrec private def run(baseDir: File, args: Seq[String]): Unit =
runImpl(baseDir, args) match {
case Some((baseDir, args)) => run(baseDir, args)
case None => ()
}
private def runImpl(baseDir: File, args: Seq[String]): Option[(File, Seq[String])] =
try launch(getConf(baseDir, args)) map exit
catch {
case r: xsbti.FullReload => Some((baseDir, r.arguments()))
case scala.util.control.NonFatal(e) => e.printStackTrace(); errorAndExit(e.toString)
}
@tailrec private def launch(conf: AppConfiguration): Option[Int] =
new xMain().run(conf) match {
case e: xsbti.Exit => Some(e.code)
case _: xsbti.Continue => None
case r: xsbti.Reboot => launch(getConf(conf.baseDirectory(), r.arguments()))
case x => handleUnknownMainResult(x)
}
private val noGlobalLock = new GlobalLock {
def apply[T](lockFile: File, run: java.util.concurrent.Callable[T]) = run.call()
}
private def getConf(baseDir: File, args: Seq[String]): AppConfiguration = new AppConfiguration {
def baseDirectory = baseDir
def arguments = args.toArray
def provider = new AppProvider { appProvider =>
def scalaProvider = new ScalaProvider { scalaProvider =>
def scalaOrg = "org.scala-lang"
def launcher = new Launcher {
def getScala(version: String) = getScala(version, "")
def getScala(version: String, reason: String) = getScala(version, reason, scalaOrg)
def getScala(version: String, reason: String, scalaOrg: String) = scalaProvider
def app(id: xsbti.ApplicationID, version: String) = appProvider
def topLoader = new java.net.URLClassLoader(Array(), null)
def globalLock = noGlobalLock
def bootDirectory = file(sys.props("user.home")) / ".sbt" / "boot"
def ivyRepositories = Array()
def appRepositories = Array()
def isOverrideRepositories = false
def ivyHome = file(sys.props("user.home")) / ".ivy2"
def checksums = Array("sha1", "md5")
}
def version = scalaVersion
def libDir: File = launcher.bootDirectory / s"scala-$version" / "lib"
def jar(name: String): File = libDir / s"$name.jar"
def libraryJar = jar("scala-library")
def compilerJar = jar("scala-compiler")
def jars = libDir.listFiles(f => !f.isDirectory && f.getName.endsWith(".jar"))
def loader = new java.net.URLClassLoader(jars map (_.toURI.toURL), null)
def app(id: xsbti.ApplicationID) = appProvider
}
def id = ApplicationID(
"org.scala-sbt",
"sbt",
sbtVersion,
"sbt.xMain",
Seq("xsbti", "extra"),
CrossValue.Disabled,
Nil
)
def mainClasspath =
buildinfo.TestBuildInfo.fullClasspath.iterator
.map(s => file(s.stripPrefix("Attributed(").stripSuffix(")")))
.toArray
def loader = new java.net.URLClassLoader(mainClasspath map (_.toURI.toURL), null)
def entryPoint = classOf[xMain]
def mainClass = classOf[xMain]
def newMain = new xMain
def components = new ComponentProvider {
def componentLocation(id: String) = ???
def component(componentID: String) = ???
def defineComponent(componentID: String, components: Array[File]) = ???
def addToComponent(componentID: String, components: Array[File]) = ???
def lockFile = ???
}
}
}
private def handleUnknownMainResult(x: MainResult): Nothing = {
val clazz = if (x eq null) "" else " (class: " + x.getClass + ")"
errorAndExit("Invalid main result: " + x + clazz)
}
private def errorAndExit(msg: String): Nothing = { System.err.println(msg); exit(1) }
private def exit(code: Int): Nothing = System.exit(code).asInstanceOf[Nothing]
}