Merge branch 'develop' into feature/3212/new-plugins-view

This commit is contained in:
Andrii 2020-10-06 23:08:41 +03:00 committed by GitHub
commit aae6493701
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 142 additions and 61 deletions

View File

@ -11,10 +11,11 @@ ThisBuild / version := {
val v = "1.4.0-SNAPSHOT"
nightlyVersion.getOrElse(v)
}
ThisBuild / versionScheme := Some("early-semver")
ThisBuild / scalafmtOnCompile := !(Global / insideCI).value
ThisBuild / Test / scalafmtOnCompile := !(Global / insideCI).value
ThisBuild / turbo := true
ThisBuild / SettingKey[Boolean]("usePipelining") := !(Global / insideCI).value
ThisBuild / usePipelining := !(Global / insideCI).value
val excludeLint = SettingKey[Set[Def.KeyedInitialize[_]]]("excludeLintKeys")
Global / excludeLint := (Global / excludeLint).?.value.getOrElse(Set.empty)

View File

@ -306,11 +306,12 @@ object Terminal {
}
}
private[sbt] lazy val formatEnabledInEnv: Boolean = logFormatEnabled.getOrElse(useColorDefault)
private[this] val isDumbTerminal = "dumb" == System.getenv("TERM")
private[this] val hasConsole = Option(java.lang.System.console).isDefined
private[this] def useColorDefault: Boolean = {
// This approximates that both stdin and stdio are connected,
// so by default color will be turned off for pipes and redirects.
props.map(_.color).orElse(isColorEnabledProp).getOrElse(hasConsole)
props.map(_.color).orElse(isColorEnabledProp).getOrElse(hasConsole && !isDumbTerminal)
}
private[this] lazy val isColorEnabledProp: Option[Boolean] =
sys.props.get("sbt.color").orElse(sys.props.get("sbt.colour")).flatMap(parseLogOption)
@ -720,8 +721,7 @@ object Terminal {
private[this] def newConsoleTerminal(): Terminal = {
val system = JLine3.system
val in = if (System.console == null) nullWriteableInputStream else nonBlockingIn(system)
new ConsoleTerminal(in, originalOut, system)
new ConsoleTerminal(nonBlockingIn(system), originalOut, system)
}
private[sbt] def reset(): Unit = {
@ -743,6 +743,7 @@ object Terminal {
case "jline.WindowsTerminal" => "windows"
case "jline.AnsiWindowsTerminal" => "windows"
case "jline.UnsupportedTerminal" => "none"
case null if isDumbTerminal => "none"
case x => x
}
if (newValue != null) {
@ -784,7 +785,7 @@ object Terminal {
val size = system.getSize
(size.getColumns, size.getRows)
}
override lazy val isAnsiSupported: Boolean = formatEnabledInEnv && !isCI
override lazy val isAnsiSupported: Boolean = !isDumbTerminal && formatEnabledInEnv && !isCI
override private[sbt] def progressState: ProgressState = consoleProgressState.get
override def isEchoEnabled: Boolean =
try system.echo()
@ -811,9 +812,7 @@ object Terminal {
override private[sbt] def setSize(width: Int, height: Int): Unit =
system.setSize(new org.jline.terminal.Size(width, height))
override def inputStream: InputStream = {
if (hasConsole) in else BlockingInputStream
}
override def inputStream: InputStream = in
override private[sbt] def enterRawMode(): Unit =
if (rawMode.compareAndSet(false, true) && hasConsole) {
@ -940,8 +939,6 @@ object Terminal {
catch { case _: InterruptedException => }
-1
}
private lazy val nullWriteableInputStream =
new WriteableInputStream(nullInputStream, "null-writeable-input-stream")
private[sbt] class DefaultTerminal extends Terminal {
override def close(): Unit = {}
override private[sbt] def progressState: ProgressState = new ProgressState(1)

View File

@ -25,7 +25,6 @@ private[sbt] final class ConsoleChannel(
override val userThread: UserThread = new UserThread(this)
private[sbt] def terminal = Terminal.console
if (System.console == null) terminal.setPrompt(Prompt.NoPrompt)
}
private[sbt] object ConsoleChannel {
private[sbt] def defaultName = "console0"

View File

@ -541,10 +541,13 @@ object Defaults extends BuildCommon {
scalaSource := sourceDirectory.value / "scala",
javaSource := sourceDirectory.value / "java",
unmanagedSourceDirectories := {
val isDotty = ScalaInstance.isDotty(scalaVersion.value)
val epochVersion = if (isDotty) "3" else "2"
makeCrossSources(
scalaSource.value,
javaSource.value,
scalaBinaryVersion.value,
epochVersion,
crossPaths.value
) ++
makePluginCrossSources(
@ -671,6 +674,24 @@ object Defaults extends BuildCommon {
)
)
def makeCrossSources(
scalaSrcDir: File,
javaSrcDir: File,
sv: String,
epochVersion: String,
cross: Boolean
): Seq[File] = {
if (cross)
Seq(
scalaSrcDir,
scalaSrcDir.getParentFile / s"${scalaSrcDir.name}-$sv",
scalaSrcDir.getParentFile / s"${scalaSrcDir.name}-$epochVersion",
javaSrcDir,
)
else
Seq(scalaSrcDir, javaSrcDir)
}
def makeCrossSources(
scalaSrcDir: File,
javaSrcDir: File,

View File

@ -37,17 +37,10 @@ object LMCoursier {
private[this] val credentialRegistry: ConcurrentHashMap[(String, String), IvyCredentials] =
new ConcurrentHashMap
private[this] lazy val checkLegacyCache: Unit = {
// This warns if ~/.coursier/cache is found.
// Temporary, remove when updating coursier to 2.0.0 final.
lmcoursier.CoursierConfiguration.checkLegacyCache()
}
def defaultCacheLocation: File =
sys.props.get("sbt.coursier.home") match {
case Some(home) => new File(home).getAbsoluteFile / "cache"
case _ =>
checkLegacyCache
CoursierDependencyResolution.defaultCacheLocation
}

View File

@ -17,7 +17,7 @@ private[sbt] object Banner {
| - sbtn: a native thin client for sbt
| - VirtualFile + RemoteCache: caches build artifacts across different machines
| - ThisBuild / versionScheme to take the guessing out of eviction warning
|See http://eed3si9n.com/sbt-1.4.0-beta for full release notes.
|See http://eed3si9n.com/sbt-1.4.0 for full release notes.
|Hide the banner for this release by running `skipBanner`.
|""".stripMargin.linesIterator.mkString("\n"))
case "1.3.0" =>

View File

@ -577,11 +577,22 @@ object BuildServerProtocol {
}
private def internalDependencyConfigurationsSetting = Def.settingDyn {
val directDependencies = Keys.internalDependencyConfigurations.value.map {
case (project, rawConfigs) =>
val configs = rawConfigs.flatMap(_.split(",")).map(name => ConfigKey(name.trim))
(project, configs)
}
val allScopes = bspWorkspace.value.map { case (_, scope) => scope }.toSet
val directDependencies = Keys.internalDependencyConfigurations.value
.map {
case (project, rawConfigs) =>
val configs = rawConfigs
.flatMap(_.split(","))
.map(name => ConfigKey(name.trim))
.filter { config =>
val scope = Scope.Global.in(project, config)
allScopes.contains(scope)
}
(project, configs)
}
.filter {
case (_, configs) => configs.nonEmpty
}
val ref = Keys.thisProjectRef.value
val thisConfig = Keys.configuration.value
val transitiveDependencies = for {
@ -589,7 +600,8 @@ object BuildServerProtocol {
config <- configs if dep != ref || config.name != thisConfig.name
} yield Keys.bspInternalDependencyConfigurations.in(dep, config)
Def.setting {
val allDependencies = directDependencies ++ transitiveDependencies.join.value.flatten
val allDependencies = directDependencies ++
transitiveDependencies.join.value.flatten
allDependencies
.groupBy(_._1)
.mapValues { deps =>

View File

@ -24,13 +24,12 @@ trait MiniDependencyTreeKeys {
val toFile = inputKey[File]("Writes the task value to the given file")
// internal
private[sbt] val ignoreMissingUpdate =
TaskKey[UpdateReport]("dependencyUpdate", "sbt-dependency-graph version of update")
private[sbt] val moduleGraphStore =
TaskKey[ModuleGraph]("module-graph-store", "The stored module-graph from the last run")
val whatDependsOn =
InputKey[String]("what-depends-on", "Shows information about what depends on the given module")
private[sbt] val crossProjectId = SettingKey[ModuleID]("dependency-graph-cross-project-id")
private[sbt] val dependencyTreeIgnoreMissingUpdate =
taskKey[UpdateReport]("update used for dependencyTree task")
private[sbt] val dependencyTreeModuleGraphStore =
taskKey[ModuleGraph]("The stored module-graph from the last run")
val whatDependsOn = inputKey[String]("Shows information about what depends on the given module")
private[sbt] val dependencyTreeCrossProjectId = settingKey[ModuleID]("")
}
object MiniDependencyTreeKeys extends MiniDependencyTreeKeys
@ -72,7 +71,9 @@ abstract class DependencyTreeKeys {
val dependencyBrowseTree = taskKey[URI](
"Opens an HTML page that can be used to view the dependency tree"
)
val dependencyTreeModuleGraph = taskKey[ModuleGraph]("The dependency graph for a project")
// 0 was added to avoid conflict with sbt-dependency-tree
private[sbt] val dependencyTreeModuleGraph0 =
taskKey[ModuleGraph]("The dependency graph for a project")
val dependencyList =
taskKey[Unit]("Prints a list of all dependencies to the console")

View File

@ -36,23 +36,25 @@ object DependencyTreeSettings {
// disable the cached resolution engine (exposing a scoped `ivyModule` used directly by `updateTask`), as it
// generates artificial module descriptors which are internal to sbt, making it hard to reconstruct the
// dependency tree
ignoreMissingUpdate / updateOptions := updateOptions.value.withCachedResolution(false),
ignoreMissingUpdate / ivyConfiguration := {
// inTask will make sure the new definition will pick up `updateOptions in ignoreMissingUpdate`
inTask(ignoreMissingUpdate, Classpaths.mkIvyConfiguration).value
dependencyTreeIgnoreMissingUpdate / updateOptions := updateOptions.value
.withCachedResolution(false),
dependencyTreeIgnoreMissingUpdate / ivyConfiguration := {
// inTask will make sure the new definition will pick up `updateOptions in dependencyTreeIgnoreMissingUpdate`
inTask(dependencyTreeIgnoreMissingUpdate, Classpaths.mkIvyConfiguration).value
},
ignoreMissingUpdate / ivyModule := {
dependencyTreeIgnoreMissingUpdate / ivyModule := {
// concatenating & inlining ivySbt & ivyModule default task implementations, as `SbtAccess.inTask` does
// NOT correctly force the scope when applied to `TaskKey.toTask` instances (as opposed to raw
// implementations like `Classpaths.mkIvyConfiguration` or `Classpaths.updateTask`)
val is = new IvySbt((ivyConfiguration in ignoreMissingUpdate).value)
val is = new IvySbt((ivyConfiguration in dependencyTreeIgnoreMissingUpdate).value)
new is.Module(moduleSettings.value)
},
// don't fail on missing dependencies
ignoreMissingUpdate / updateConfiguration := updateConfiguration.value.withMissingOk(true),
ignoreMissingUpdate := {
dependencyTreeIgnoreMissingUpdate / updateConfiguration := updateConfiguration.value
.withMissingOk(true),
dependencyTreeIgnoreMissingUpdate := {
// inTask will make sure the new definition will pick up `ivyModule/updateConfiguration in ignoreMissingUpdate`
inTask(ignoreMissingUpdate, Classpaths.updateTask).value
inTask(dependencyTreeIgnoreMissingUpdate, Classpaths.updateTask).value
},
)
@ -62,19 +64,22 @@ object DependencyTreeSettings {
*/
lazy val baseBasicReportingSettings: Seq[Def.Setting[_]] =
Seq(
crossProjectId := CrossVersion(scalaVersion.value, scalaBinaryVersion.value)(
dependencyTreeCrossProjectId := CrossVersion(scalaVersion.value, scalaBinaryVersion.value)(
projectID.value
),
dependencyTreeModuleGraph := {
dependencyTreeModuleGraph0 := {
val sv = scalaVersion.value
val g = ignoreMissingUpdate.value
val g = dependencyTreeIgnoreMissingUpdate.value
.configuration(configuration.value)
.map(report => SbtUpdateReport.fromConfigurationReport(report, crossProjectId.value))
.map(
report =>
SbtUpdateReport.fromConfigurationReport(report, dependencyTreeCrossProjectId.value)
)
.getOrElse(ModuleGraph.empty)
if (dependencyTreeIncludeScalaLibrary.value) g
else GraphTransformations.ignoreScalaLibrary(sv, g)
},
moduleGraphStore := (dependencyTreeModuleGraph storeAs moduleGraphStore triggeredBy dependencyTreeModuleGraph).value,
dependencyTreeModuleGraphStore := (dependencyTreeModuleGraph0 storeAs dependencyTreeModuleGraphStore triggeredBy dependencyTreeModuleGraph0).value,
) ++ renderingTaskSettings(dependencyTree, rendering.AsciiTree.asciiTree _)
/**
@ -95,7 +100,7 @@ object DependencyTreeSettings {
target.value / "dependencies-%s.dot".format(config.toString)
},
dependencyDot / asString := rendering.DOT.dotGraph(
dependencyTreeModuleGraph.value,
dependencyTreeModuleGraph0.value,
dependencyDotHeader.value,
dependencyDotNodeLabel.value,
rendering.DOT.AngleBrackets
@ -118,7 +123,7 @@ object DependencyTreeSettings {
dependencyGraphML := dependencyGraphMLTask.value,
whatDependsOn := {
val ArtifactPattern(org, name, versionFilter) = artifactPatternParser.parsed
val graph = dependencyTreeModuleGraph.value
val graph = dependencyTreeModuleGraph0.value
val modules =
versionFilter match {
case Some(version) => GraphModuleId(org, name, version) :: Nil
@ -153,7 +158,7 @@ object DependencyTreeSettings {
val str = (key / asString).value
s.log.info(str)
},
key / asString := renderer(dependencyTreeModuleGraph.value),
key / asString := renderer(dependencyTreeModuleGraph0.value),
key / toFile := {
val (targetFile, force) = targetFileAndForceParser.parsed
writeToFile(key.key.label, (asString in key).value, targetFile, force, streams.value)
@ -163,7 +168,7 @@ object DependencyTreeSettings {
def dependencyGraphMLTask =
Def.task {
val resultFile = dependencyGraphMLFile.value
val graph = dependencyTreeModuleGraph.value
val graph = dependencyTreeModuleGraph0.value
rendering.GraphML.saveAsGraphML(graph, resultFile.getAbsolutePath)
streams.value.log.info("Wrote dependency graph to '%s'" format resultFile)
resultFile
@ -171,7 +176,7 @@ object DependencyTreeSettings {
def browseGraphHTMLTask =
Def.task {
val graph = dependencyTreeModuleGraph.value
val graph = dependencyTreeModuleGraph0.value
val dotGraph = rendering.DOT.dotGraph(
graph,
dependencyDotHeader.value,
@ -185,7 +190,7 @@ object DependencyTreeSettings {
def browseTreeHTMLTask =
Def.task {
val graph = dependencyTreeModuleGraph.value
val graph = dependencyTreeModuleGraph0.value
val renderedTree = TreeView.createJson(graph)
val link = TreeView.createLink(renderedTree, target.value)
streams.value.log.info(s"HTML tree written to $link")
@ -234,7 +239,7 @@ object DependencyTreeSettings {
import sbt.internal.util.complete.DefaultParsers._
val artifactPatternParser: Def.Initialize[State => Parser[ArtifactPattern]] =
Keys.resolvedScoped { ctx => (state: State) =>
val graph = Defaults.loadFromContext(moduleGraphStore, ctx, state) getOrElse ModuleGraph(
val graph = Defaults.loadFromContext(dependencyTreeModuleGraphStore, ctx, state) getOrElse ModuleGraph(
Nil,
Nil
)
@ -255,7 +260,7 @@ object DependencyTreeSettings {
}
.reduceOption(_ | _)
.getOrElse {
// If the moduleGraphStore couldn't be loaded because no dependency tree command was run before, we should still provide a parser for the command.
// If the dependencyTreeModuleGraphStore couldn't be loaded because no dependency tree command was run before, we should still provide a parser for the command.
((Space ~> token(StringBasic, "<organization>")) ~ (Space ~> token(
StringBasic,
"<module>"

View File

@ -11,10 +11,10 @@ object Dependencies {
def nightlyVersion = sys.props.get("sbt.build.version")
// sbt modules
private val ioVersion = nightlyVersion.getOrElse("1.4.0-M8")
private val ioVersion = nightlyVersion.getOrElse("1.4.0")
private val lmVersion =
sys.props.get("sbt.build.lm.version").orElse(nightlyVersion).getOrElse("1.4.0-M3")
val zincVersion = nightlyVersion.getOrElse("1.4.0-M13")
sys.props.get("sbt.build.lm.version").orElse(nightlyVersion).getOrElse("1.4.0")
val zincVersion = nightlyVersion.getOrElse("1.4.0")
private val sbtIO = "org.scala-sbt" %% "io" % ioVersion
@ -76,7 +76,7 @@ object Dependencies {
def addSbtZincCompile = addSbtModule(sbtZincPath, "zincCompileJVM2_12", zincCompile)
def addSbtZincCompileCore = addSbtModule(sbtZincPath, "zincCompileCoreJVM2_12", zincCompileCore)
val lmCoursierShaded = "io.get-coursier" %% "lm-coursier-shaded" % "2.0.0-RC6-9"
val lmCoursierShaded = "io.get-coursier" %% "lm-coursier-shaded" % "2.0.0"
def sjsonNew(n: String) =
Def.setting("com.eed3si9n" %% n % "0.9.0") // contrabandSjsonNewVersion.value

View File

@ -1 +1 @@
sbt.version=1.4.0-RC2
sbt.version=1.4.0

View File

@ -1,3 +1,5 @@
ThisBuild / useCoursier := false
scalacOptions ++= Seq("-feature", "-language:postfixOps", "-Ywarn-unused:_,-imports")
addSbtPlugin("com.dwijnand" % "sbt-dynver" % "4.0.0")

View File

@ -1,3 +1,3 @@
# to initialize parser with deps
> Compile/dependencyTreeModuleGraph
> Compile/dependencyTreeModuleGraph0
> check

View File

@ -0,0 +1,49 @@
// Custom configurations
lazy val Common = config("common").describedAs("Dependencies required in all configurations.")
lazy val Scalate = config("scalate").extend(Common).describedAs("Dependencies for using Scalate utilities.")
lazy val Saxon = config("saxon").extend(Common).describedAs("Dependencies for using Saxon utilities.")
// Define a customized compile configuration that includes
// dependencies defined in our other custom configurations
lazy val CustomCompile = config("compile").extend(Saxon, Common, Scalate)
// factor out common settings
ThisBuild / organization := "com.example"
ThisBuild / scalaVersion := "2.10.6"
ThisBuild / version := "0.1.0-SNAPSHOT"
// An example project that only uses the Scalate utilities.
lazy val a = (project in file("a"))
.dependsOn(utils % "compile->scalate")
// An example project that uses the Scalate and Saxon utilities.
// For the configurations defined here, this is equivalent to doing dependsOn(utils),
// but if there were more configurations, it would select only the Scalate and Saxon
// dependencies.
lazy val b = (project in file("b"))
.dependsOn(utils % "compile->scalate,saxon")
// Defines the utilities project
lazy val utils = (project in file("utils"))
.settings(
inConfig(Common)(Defaults.configSettings), // Add the src/common/scala/ compilation configuration.
addArtifact(Common / packageBin / artifact, Common / packageBin), // Publish the common artifact
// We want our Common sources to have access to all of the dependencies on the classpaths
// for compile and test, but when depended on, it should only require dependencies in 'common'
Common / classpathConfiguration := CustomCompile,
// Modify the default Ivy configurations.
// 'overrideConfigs' ensures that Compile is replaced by CustomCompile
ivyConfigurations := overrideConfigs(Scalate, Saxon, Common, CustomCompile)(ivyConfigurations.value),
// Put all dependencies without an explicit configuration into Common (optional)
defaultConfiguration := Some(Common),
// Declare dependencies in the appropriate configurations
libraryDependencies ++= Seq(
"org.fusesource.scalate" % "scalate-core" % "1.5.0" % Scalate,
"org.squeryl" %% "squeryl" % "0.9.5-6" % Scalate,
"net.sf.saxon" % "saxon" % "8.7" % Saxon
)
)

View File

@ -0,0 +1 @@
> name