diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f4f15d4dc..38263530f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,9 +40,9 @@ jobs: env: JAVA_OPTS: -Xms800M -Xmx2G -Xss6M -XX:ReservedCodeCacheSize=128M -server -Dsbt.io.virtual=false -Dfile.encoding=UTF-8 JVM_OPTS: -Xms800M -Xmx2G -Xss6M -XX:ReservedCodeCacheSize=128M -server -Dsbt.io.virtual=false -Dfile.encoding=UTF-8 - SCALA_212: 2.12.13 - SCALA_213: 2.13.3 - UTIL_TESTS: utilCache/test;utilControl/test;utilInterface/test;utilLogging/test;utilPosition/test;utilRelation/test;utilScripted/test;utilTracking/test + SCALA_212: 2.12.14 + SCALA_213: 2.13.6 + UTIL_TESTS: "utilCache/test utilControl/test utilInterface/test utilLogging/test utilPosition/test utilRelation/test utilScripted/test utilTracking/test" SBT_LOCAL: false TEST_SBT_VER: 1.5.0 SBT_ETC_FILE: $HOME/etc/sbt/sbtopts @@ -70,7 +70,7 @@ jobs: ref: develop path: zinc - name: Setup - uses: olafurpg/setup-scala@v10 + uses: olafurpg/setup-scala@v12 with: java-version: "adopt@1.${{ matrix.java }}" - name: Set up Python 3.7 @@ -80,7 +80,7 @@ jobs: - name: Coursier cache uses: coursier/cache-action@v6 - name: Cache sbt - uses: actions/cache@v2.1.5 + uses: actions/cache@v2.1.6 with: path: ~/.sbt key: ${{ runner.os }}-sbt-cache-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} @@ -90,7 +90,23 @@ jobs: rm -rf "$HOME/.sbt/scripted/" || true case ${{ matrix.jobtype }} in 1) - ./sbt -v "mimaReportBinaryIssues ; javafmtCheck ; Test / javafmtCheck; scalafmtCheckAll ; scalafmtSbtCheck; serverTestProj/scalafmtCheckAll; headerCheck ;test:headerCheck ;whitesourceOnPush ;test:compile; publishLocal; test; serverTestProj/test; doc; $UTIL_TESTS; ++$SCALA_213; $UTIL_TESTS" + ./sbt -v --client mimaReportBinaryIssues + ./sbt -v --client javafmtCheck + ./sbt -v --client "Test/javafmtCheck" + ./sbt -v --client scalafmtCheckAll + ./sbt -v --client scalafmtSbtCheck + ./sbt -v --client serverTestProj/scalafmtCheckAll + ./sbt -v --client headerCheck + ./sbt -v --client "Test/headerCheck" + ./sbt -v --client whitesourceOnPush + ./sbt -v --client "Test/compile" + ./sbt -v --client publishLocal + ./sbt -v --client test + ./sbt -v --client "serverTestProj/test" + ./sbt -v --client doc + ./sbt -v --client "all $UTIL_TESTS" + ./sbt -v --client ++$SCALA_213 + ./sbt -v --client "all $UTIL_TESTS" ;; 2) ./sbt -v "scripted actions/* apiinfo/* compiler-project/* ivy-deps-management/* reporter/* tests/* watch/* classloader-cache/* package/*" @@ -112,7 +128,7 @@ jobs: cd ../ sbt -Dsbtlm.path=$HOME/work/sbt/sbt/librarymanagement -Dsbtzinc.path=$HOME/work/sbt/sbt/zinc -Dsbt.build.version=$BUILD_VERSION -Dsbt.build.fatal=false "+lowerUtils/publishLocal; {librarymanagement}/publishLocal; {zinc}/publishLocal; upperModules/publishLocal" rm -r $(find $HOME/.sbt/boot -name "*-SNAPSHOT") || true - sbt -v -Dsbt.version=$BUILD_VERSION "++$SCALA_213; $UTIL_TESTS; ++$SCALA_212; $UTIL_TESTS; scripted actions/* source-dependencies/*1of3 dependency-management/*1of4 java/*" + sbt -v -Dsbt.version=$BUILD_VERSION "++$SCALA_213; all $UTIL_TESTS; ++$SCALA_212; all $UTIL_TESTS; scripted actions/* source-dependencies/*1of3 dependency-management/*1of4 java/*" ;; 7) # test launcher script diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 7adaddb2a..70c344639 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -36,7 +36,7 @@ jobs: ref: develop path: zinc - name: Setup - uses: olafurpg/setup-scala@v10 + uses: olafurpg/setup-scala@v12 with: java-version: "adopt@1.${{ matrix.java }}" - name: Coursier cache diff --git a/DEVELOPING.md b/DEVELOPING.md index 691720ea2..020f81992 100644 --- a/DEVELOPING.md +++ b/DEVELOPING.md @@ -1,6 +1,10 @@ Developer guide =============== +### Getting started + +Create a [fork](https://docs.github.com/en/github/getting-started-with-github/fork-a-repo) of the repository and [clone](https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/cloning-a-repository) it to create a local copy. + ### Branch to work against sbt uses two branches for development: @@ -8,10 +12,13 @@ sbt uses two branches for development: - Development branch: `develop` (this is also called "master") - Stable branch: `1.$MINOR.x`, where `$MINOR` is current minor version (e.g. `1.1.x` during 1.1.x series) +The `develop` branch represents the next major version of sbt. Only new features are pushed to the `develop` branch. This is the branch that you will branch off of to make your changes. +The `stable` branch represents the current stable sbt release. Only bug fixes are back-ported to the stable branch. ### Instruction to build just sbt -If the change you are making is contained in sbt/sbt, you could publishLocal on sbt/sbt: +Sbt has a number of sub-modules. If the change you are making is just contained in sbt/sbt (not one of the sub-modules), +you can use the `publishLocal` command to publish the sbt project to your local machine. This is helpful for testing your changes. ``` $ sbt @@ -20,6 +27,9 @@ sbt:sbtRoot> publishLocal ### Instruction to build all modules from source +When working on a change that requires changing one or more sub modules, the source code for these modules can be pulled in by running the following script +(instead of building them from Maven for example and not being able to change the source code for these sub-modules). + 1. Install the current stable binary release of sbt (see [Setup]), which will be used to build sbt from source. 2. Get the source code. @@ -42,7 +52,7 @@ sbt:sbtRoot> publishLocal ### Using the locally built sbt -The `publishLocal` above will build and publish version `1.$MINOR.$PATCH-SNAPSHOT` (e.g. 1.1.2-SNAPSHOT) to your local ivy repository. +The `publishLocal` command above will build and publish version `1.$MINOR.$PATCH-SNAPSHOT` (e.g. 1.1.2-SNAPSHOT) to your local ivy repository. To use the locally built sbt, set the version in `build.properties` file in your project to `1.$MINOR.$PATCH-SNAPSHOT` then launch `sbt` (this can be the `sbt` launcher installed in your machine). @@ -54,6 +64,8 @@ $ sbt ### Nightly builds +_Note: The following section may require an update._ + The latest development versions are available as nightly builds on sbt-maven-snapshots () repo, which is a redirect proxy whose underlying repository is subject to change it could be Bintray, Linux box, etc. To use a nightly build: @@ -75,9 +87,16 @@ If you're overriding the repositories via `~/.sbt/repositories`, make sure that ### Clearing out boot and local cache -When you run a locally built sbt, the JAR artifacts will be now cached under `$HOME/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.$MINOR.$PATCH-SNAPSHOT` directory. To clear this out run: `reboot dev` command from sbt's session of your test application. +sbt consists of lots of JAR files. When running sbt locally, these JAR artifacts are cached in the `boot` directory under `$HOME/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.$MINOR.$PATCH-SNAPSHOT` directory. -One drawback of `-SNAPSHOT` version is that it's slow to resolve as it tries to hit all the resolvers. You can workaround that by using a version name like `1.$MINOR.$PATCH-LOCAL1`. A non-SNAPSHOT artifacts will now be cached under `$HOME/.ivy/cache/` directory, so you need to clear that out using [sbt-dirty-money](https://github.com/sbt/sbt-dirty-money)'s `cleanCache` task. +In order to see a change you've made to sbt's source code, this cache should be cleared. To clear this out run: `reboot dev` command from sbt's session of your test application. + +By default sbt uses a snapshot version (this is a scala convention for quick local changes- it tells users that this version could change). +One drawback of `-SNAPSHOT` version is that it's slow to resolve as it tries to hit all the resolvers. +This is important when testing perfomance, so that the slowness of the resolution does not impact sbt. + +You can workaround that by using a version name like `1.$MINOR.$PATCH-LOCAL1`. +A non-SNAPSHOT artifacts will now be cached under `$HOME/.ivy/cache/` directory, so you need to clear that out using [sbt-dirty-money](https://github.com/sbt/sbt-dirty-money)'s `cleanCache` task. ### Running sbt "from source" - `sbtOn` diff --git a/build.sbt b/build.sbt index 5bfb197a2..8ca6d0ac6 100644 --- a/build.sbt +++ b/build.sbt @@ -10,7 +10,7 @@ import scala.util.Try // ThisBuild settings take lower precedence, // but can be shared across the multi projects. ThisBuild / version := { - val v = "1.5.2-SNAPSHOT" + val v = "1.5.5-SNAPSHOT" nightlyVersion.getOrElse(v) } ThisBuild / version2_13 := "2.0.0-SNAPSHOT" @@ -45,7 +45,7 @@ ThisBuild / scmInfo := Some( ThisBuild / resolvers += Resolver.mavenLocal Global / semanticdbEnabled := !(Global / insideCI).value -Global / semanticdbVersion := "4.4.10" +Global / semanticdbVersion := "4.4.20" val excludeLint = SettingKey[Set[Def.KeyedInitialize[_]]]("excludeLintKeys") Global / excludeLint := (Global / excludeLint).?.value.getOrElse(Set.empty) Global / excludeLint += componentID @@ -73,21 +73,23 @@ def commonBaseSettings: Seq[Setting[_]] = Def.settings( )(Resolver.ivyStylePatterns), testFrameworks += TestFramework("hedgehog.sbt.Framework"), testFrameworks += TestFramework("verify.runner.Framework"), - concurrentRestrictions in Global += Util.testExclusiveRestriction, - testOptions in Test += Tests.Argument(TestFrameworks.ScalaCheck, "-w", "1"), - testOptions in Test += Tests.Argument(TestFrameworks.ScalaCheck, "-verbosity", "2"), - javacOptions in compile ++= Seq("-Xlint", "-Xlint:-serial"), + Global / concurrentRestrictions += Util.testExclusiveRestriction, + Test / testOptions += Tests.Argument(TestFrameworks.ScalaCheck, "-w", "1"), + Test / testOptions += Tests.Argument(TestFrameworks.ScalaCheck, "-verbosity", "2"), + compile / javacOptions ++= Seq("-Xlint", "-Xlint:-serial"), + /* Compile / doc / scalacOptions ++= { import scala.sys.process._ val devnull = ProcessLogger(_ => ()) val tagOrSha = ("git describe --exact-match" #|| "git rev-parse HEAD").lineStream(devnull).head Seq( "-sourcepath", - (baseDirectory in LocalRootProject).value.getAbsolutePath, + (LocalRootProject / baseDirectory).value.getAbsolutePath, "-doc-source-url", s"https://github.com/sbt/sbt/tree/$tagOrSha€{FILE_PATH}.scala" ) }, + */ Compile / javafmtOnCompile := Def .taskDyn(if ((scalafmtOnCompile).value) Compile / javafmt else Def.task(())) .value, @@ -99,8 +101,8 @@ def commonBaseSettings: Seq[Setting[_]] = Def.settings( Test / unmanagedSources / inputFileStamps := (Test / unmanagedSources / inputFileStamps).dependsOn(Test / javafmtOnCompile).value, crossScalaVersions := List(scala212, scala213), - publishArtifact in Test := false, - fork in run := true, + Test / publishArtifact := false, + run / fork := true, ) def commonSettings: Seq[Setting[_]] = commonBaseSettings :+ @@ -118,7 +120,12 @@ def baseSettings: Seq[Setting[_]] = def testedBaseSettings: Seq[Setting[_]] = baseSettings ++ testDependencies -val sbt13Plus = Seq("1.3.0") +val sbt13Plus = + Seq( + "1.3.0", + "1.4.0", + "1.5.0", + ) val sbt10Plus = Seq( "1.0.0", @@ -191,8 +198,8 @@ lazy val sbtRoot: Project = (project in file(".")) Transform.conscriptSettings(bundledLauncherProj), publish := {}, publishLocal := {}, - skip in publish := true, - commands in Global += Command + publish / skip := true, + Global / commands += Command .single("sbtOn")((state, dir) => s"sbtProj/test:runMain sbt.RunFromSourceMain $dir" :: state), mimaSettings, mimaPreviousArtifacts := Set.empty, @@ -232,7 +239,7 @@ lazy val bundledLauncherProj = description := "sbt application launcher", autoScalaLibrary := false, crossPaths := false, - packageBin in Compile := sbtLaunchJar.value, + Compile / packageBin := sbtLaunchJar.value, mimaSettings, mimaPreviousArtifacts := Set() ) @@ -369,11 +376,11 @@ lazy val utilLogging = (project in file("internal") / "util-logging") case v if v.startsWith("2.12.") => List("-Ywarn-unused:-locals,-explicits,-privates") case _ => List() }), - sourceManaged in (Compile, generateContrabands) := baseDirectory.value / "src" / "main" / "contraband-scala", - managedSourceDirectories in Compile += + Compile / generateContrabands / sourceManaged := baseDirectory.value / "src" / "main" / "contraband-scala", + Compile / managedSourceDirectories += baseDirectory.value / "src" / "main" / "contraband-scala", - contrabandFormatsForType in generateContrabands in Compile := { tpe => - val old = (contrabandFormatsForType in generateContrabands in Compile).value + Compile / generateContrabands / contrabandFormatsForType := { tpe => + val old = (Compile / generateContrabands / contrabandFormatsForType).value val name = tpe.removeTypeParameters.name if (name == "Throwable") Nil else old(tpe) @@ -407,6 +414,7 @@ lazy val utilLogging = (project in file("internal") / "util-logging") exclude[IncompatibleSignatureProblem]("sbt.internal.util.MainAppender*"), exclude[MissingTypesProblem]("sbt.internal.util.ConsoleAppender"), exclude[MissingTypesProblem]("sbt.internal.util.BufferedAppender"), + exclude[MissingClassProblem]("sbt.internal.util.Terminal$BlockingInputStream$"), ), ) .configure(addSbtIO) @@ -475,10 +483,10 @@ lazy val testingProj = (project in file("testing")) sjsonNewScalaJson.value ), Compile / scalacOptions += "-Ywarn-unused:-locals,-explicits,-privates", - managedSourceDirectories in Compile += + Compile / managedSourceDirectories += baseDirectory.value / "src" / "main" / "contraband-scala", - sourceManaged in (Compile, generateContrabands) := baseDirectory.value / "src" / "main" / "contraband-scala", - contrabandFormatsForType in generateContrabands in Compile := ContrabandConfig.getFormats, + Compile / generateContrabands / sourceManaged := baseDirectory.value / "src" / "main" / "contraband-scala", + Compile / generateContrabands / contrabandFormatsForType := ContrabandConfig.getFormats, mimaSettings, mimaBinaryIssueFilters ++= Seq( // private[sbt] @@ -559,6 +567,7 @@ lazy val stdTaskProj = (project in file("tasks-standard")) mimaBinaryIssueFilters ++= Seq( // unused private[sbt] exclude[DirectMissingMethodProblem]("sbt.Task.mapTask"), + exclude[NewMixinForwarderProblem]("sbt.std.TaskExtra.joinAnyTasks"), ), ) .configure(addSbtIO) @@ -571,9 +580,9 @@ lazy val runProj = (project in file("run")) testedBaseSettings, name := "Run", Compile / scalacOptions += "-Ywarn-unused:-locals,-explicits,-privates", - managedSourceDirectories in Compile += + Compile / managedSourceDirectories += baseDirectory.value / "src" / "main" / "contraband-scala", - sourceManaged in (Compile, generateContrabands) := baseDirectory.value / "src" / "main" / "contraband-scala", + Compile / generateContrabands / sourceManaged := baseDirectory.value / "src" / "main" / "contraband-scala", mimaSettings, mimaBinaryIssueFilters ++= Seq( // copy method was never meant to be public @@ -668,6 +677,7 @@ lazy val actionsProj = (project in file("main-actions")) exclude[DirectMissingMethodProblem]("sbt.Doc.generate"), exclude[DirectMissingMethodProblem]("sbt.compiler.Eval.filesModifiedBytes"), exclude[DirectMissingMethodProblem]("sbt.compiler.Eval.fileModifiedBytes"), + exclude[DirectMissingMethodProblem]("sbt.Doc.$init$"), ), ) .configure( @@ -687,10 +697,10 @@ lazy val protocolProj = (project in file("protocol")) name := "Protocol", libraryDependencies ++= Seq(sjsonNewScalaJson.value, ipcSocket), Compile / scalacOptions += "-Ywarn-unused:-locals,-explicits,-privates", - managedSourceDirectories in Compile += + Compile / managedSourceDirectories += baseDirectory.value / "src" / "main" / "contraband-scala", - sourceManaged in (Compile, generateContrabands) := baseDirectory.value / "src" / "main" / "contraband-scala", - contrabandFormatsForType in generateContrabands in Compile := ContrabandConfig.getFormats, + Compile / generateContrabands / sourceManaged := baseDirectory.value / "src" / "main" / "contraband-scala", + Compile / generateContrabands / contrabandFormatsForType := ContrabandConfig.getFormats, mimaSettings, mimaBinaryIssueFilters ++= Seq( // copy method was never meant to be public @@ -729,10 +739,10 @@ lazy val commandProj = (project in file("main-command")) name := "Command", libraryDependencies ++= Seq(launcherInterface, sjsonNewScalaJson.value, templateResolverApi), Compile / scalacOptions += "-Ywarn-unused:-locals,-explicits,-privates", - managedSourceDirectories in Compile += + Compile / managedSourceDirectories += baseDirectory.value / "src" / "main" / "contraband-scala", - sourceManaged in (Compile, generateContrabands) := baseDirectory.value / "src" / "main" / "contraband-scala", - contrabandFormatsForType in generateContrabands in Compile := ContrabandConfig.getFormats, + Compile / generateContrabands / sourceManaged := baseDirectory.value / "src" / "main" / "contraband-scala", + Compile / generateContrabands / contrabandFormatsForType := ContrabandConfig.getFormats, mimaSettings, mimaBinaryIssueFilters ++= Vector( exclude[DirectMissingMethodProblem]("sbt.Exit.apply"), @@ -766,8 +776,8 @@ lazy val commandProj = (project in file("main-command")) exclude[MissingTypesProblem]("sbt.internal.server.ServerConnection*"), exclude[IncompatibleSignatureProblem]("sbt.internal.server.ServerConnection.*") ), - unmanagedSources in (Compile, headerCreate) := { - val old = (unmanagedSources in (Compile, headerCreate)).value + Compile / headerCreate / unmanagedSources := { + val old = (Compile / headerCreate / unmanagedSources).value old filterNot { x => (x.getName startsWith "NG") || (x.getName == "ReferenceCountedFileDescriptor.java") } @@ -807,7 +817,7 @@ lazy val mainSettingsProj = (project in file("main-settings")) .settings( testedBaseSettings, name := "Main Settings", - testOptions in Test ++= { + Test / testOptions ++= { val cp = (Test / fullClasspathAsJars).value.map(_.data).mkString(java.io.File.pathSeparator) val framework = TestFrameworks.ScalaTest Tests.Argument(framework, s"-Dsbt.server.classpath=$cp") :: @@ -861,7 +871,7 @@ lazy val zincLmIntegrationProj = (project in file("zinc-lm-integration")) .settings( name := "Zinc LM Integration", testedBaseSettings, - testOptions in Test += + Test / testOptions += Tests.Argument(TestFrameworks.ScalaTest, s"-Dsbt.zinc.version=$zincVersion"), mimaSettingsSince(sbt13Plus), mimaBinaryIssueFilters ++= Seq( @@ -903,10 +913,10 @@ lazy val mainProj = (project in file("main")) case v if v.startsWith("2.12.") => List() case _ => List(scalaPar) }), - managedSourceDirectories in Compile += + Compile / managedSourceDirectories += baseDirectory.value / "src" / "main" / "contraband-scala", - sourceManaged in (Compile, generateContrabands) := baseDirectory.value / "src" / "main" / "contraband-scala", - testOptions in Test += Tests + Compile / generateContrabands / sourceManaged := baseDirectory.value / "src" / "main" / "contraband-scala", + Test / testOptions += Tests .Argument(TestFrameworks.ScalaCheck, "-minSuccessfulTests", "1000"), SettingKey[Boolean]("usePipelining") := false, mimaSettings, @@ -1025,6 +1035,10 @@ lazy val mainProj = (project in file("main")) exclude[IncompatibleSignatureProblem]("sbt.internal.Act.taskAxis"), // private[sbt] method, used to call the correct sourcePositionMapper exclude[DirectMissingMethodProblem]("sbt.Defaults.foldMappers"), + exclude[DirectMissingMethodProblem]("sbt.Defaults.toAbsoluteSourceMapper"), + exclude[DirectMissingMethodProblem]("sbt.Defaults.earlyArtifactPathSetting"), + exclude[MissingClassProblem]("sbt.internal.server.BuildServerReporter$"), + exclude[IncompatibleTemplateDefProblem]("sbt.internal.server.BuildServerReporter"), ) ) .configure( @@ -1059,7 +1073,7 @@ lazy val sbtProj = (project in file("sbt-app")) Test / run / connectInput := true, Test / run / outputStrategy := Some(StdoutOutput), Test / run / fork := true, - testOptions in Test ++= { + Test / testOptions ++= { val cp = (Test / fullClasspathAsJars).value.map(_.data).mkString(java.io.File.pathSeparator) val framework = TestFrameworks.ScalaTest Tests.Argument(framework, s"-Dsbt.server.classpath=$cp") :: @@ -1302,6 +1316,8 @@ lazy val sbtIgnoredProblems = { exclude[ReversedMissingMethodProblem]("sbt.Import.sbt$Import$_setter_$SemanticSelector_="), // Dropped in favour of plain scala.Function, and its compose method exclude[DirectMissingMethodProblem]("sbt.package.toFn1"), + exclude[NewMixinForwarderProblem]("sbt.IOSyntax1.singleFileFinder"), + exclude[DirectMissingMethodProblem]("sbt.IOSyntax1.$init$"), ) } @@ -1320,8 +1336,8 @@ lazy val vscodePlugin = (project in file("vscode-sbt-scala")) bspEnabled := false, crossPaths := false, crossScalaVersions := Seq(baseScalaVersion), - skip in publish := true, - compile in Compile := { + publish / skip := true, + Compile / compile := { val _ = update.value runNpm("run compile", baseDirectory.value, streams.value.log) sbt.internal.inc.Analysis.empty @@ -1355,7 +1371,7 @@ def scriptedTask(launch: Boolean): Def.Initialize[InputTask[Unit]] = Def.inputTa val _ = publishLocalBinAll.value val launchJar = s"-Dsbt.launch.jar=${(bundledLauncherProj / Compile / packageBin).value}" Scripted.doScripted( - (scalaInstance in scriptedSbtReduxProj).value, + (scriptedSbtReduxProj / scalaInstance).value, scriptedSource.value, scriptedBufferLog.value, Def.setting(Scripted.scriptedParser(scriptedSource.value)).parsed, @@ -1421,9 +1437,9 @@ def otherRootSettings = Seq( scripted := scriptedTask(false).evaluated, scriptedUnpublished := scriptedTask(false).evaluated, - scriptedSource := (sourceDirectory in sbtProj).value / "sbt-test", - watchTriggers in scripted += scriptedSource.value.toGlob / **, - watchTriggers in scriptedUnpublished := (watchTriggers in scripted).value, + scriptedSource := (sbtProj / sourceDirectory).value / "sbt-test", + scripted / watchTriggers += scriptedSource.value.toGlob / **, + scriptedUnpublished / watchTriggers := (scripted / watchTriggers).value, scriptedLaunchOpts := List("-Xmx1500M", "-Xms512M", "-server") ::: (sys.props.get("sbt.ivy.home") match { case Some(home) => List(s"-Dsbt.ivy.home=$home") @@ -1447,7 +1463,7 @@ def otherRootSettings = }), scripted := scriptedTask(true).evaluated, scriptedUnpublished := scriptedTask(true).evaluated, - scriptedSource := (sourceDirectory in sbtProj).value / "repo-override-test" + scriptedSource := (sbtProj / sourceDirectory).value / "repo-override-test" ) ) @@ -1501,8 +1517,8 @@ def customCommands: Seq[Setting[_]] = Seq( (lmOpt map { case ProjectRef(build, _) => "{" + build.toString + "}/publishLocal" }).toList ::: (zincOpt map { case ProjectRef(build, _) => - val zincSv = get(scalaVersion in ProjectRef(build, "zinc")) - val csv = get(crossScalaVersions in ProjectRef(build, "compilerBridge")).toList + val zincSv = get((ProjectRef(build, "zinc") / scalaVersion)) + val csv = get((ProjectRef(build, "compilerBridge") / crossScalaVersions)).toList (csv flatMap { bridgeSv => s"++$bridgeSv" :: ("{" + build.toString + "}compilerBridge/publishLocal") :: Nil }) ::: diff --git a/launcher-package/build.sbt b/launcher-package/build.sbt index 4896e19bd..fd12e98cb 100755 --- a/launcher-package/build.sbt +++ b/launcher-package/build.sbt @@ -26,7 +26,7 @@ lazy val sbtVersionToRelease = sys.props.getOrElse("sbt.build.version", sys.env. })) lazy val scala210 = "2.10.7" -lazy val scala212 = "2.12.10" +lazy val scala212 = "2.12.14" lazy val scala210Jline = "org.scala-lang" % "jline" % scala210 lazy val jansi = { if (sbtVersionToRelease startsWith "1.") "org.fusesource.jansi" % "jansi" % "1.12" @@ -34,7 +34,7 @@ lazy val jansi = { } lazy val scala212Compiler = "org.scala-lang" % "scala-compiler" % scala212 lazy val scala212Jline = "jline" % "jline" % "2.14.6" -// use the scala-xml version used by the compiler not the latest: https://github.com/scala/scala/blob/v2.12.10/versions.properties#L22 +// use the scala-xml version used by the compiler not the latest: https://github.com/scala/scala/blob/v2.12.14/versions.properties#L21 lazy val scala212Xml = "org.scala-lang.modules" % "scala-xml_2.12" % "1.0.6" lazy val sbtActual = "org.scala-sbt" % "sbt" % sbtVersionToRelease @@ -118,6 +118,7 @@ val root = (project in file(".")). // TODO - GPG Trust validation. file }, + // update sbt.sh at root sbtnVersion := "1.4.7", sbtnJarsBaseUrl := "https://github.com/sbt/sbtn-dist/releases/download", sbtnJarsMappings := { diff --git a/main-command/src/main/scala/sbt/BasicCommandStrings.scala b/main-command/src/main/scala/sbt/BasicCommandStrings.scala index d7a310929..f70e350d6 100644 --- a/main-command/src/main/scala/sbt/BasicCommandStrings.scala +++ b/main-command/src/main/scala/sbt/BasicCommandStrings.scala @@ -210,6 +210,7 @@ $AliasCommand name= def Client: String = "client" def ClientDetailed: String = "Provides an interactive prompt from which commands can be run on a server." + def JavaClient: String = "--java-client" def DashClient: String = "-client" def DashDashClient: String = "--client" def DashDashDetachStdio: String = "--detach-stdio" diff --git a/main/src/main/java/sbt/internal/MetaBuildLoader.java b/main/src/main/java/sbt/internal/MetaBuildLoader.java index dd4c9a4b7..05cef0f02 100644 --- a/main/src/main/java/sbt/internal/MetaBuildLoader.java +++ b/main/src/main/java/sbt/internal/MetaBuildLoader.java @@ -67,15 +67,21 @@ public final class MetaBuildLoader extends URLClassLoader { final String jlineJars = "jline-?[0-9.]+-sbt-.*|jline-terminal(-(jna|jansi))?-[0-9.]+"; final String testInterfaceJars = "test-interface(-.*)?"; final String compilerInterfaceJars = "compiler-interface(-.*)?"; + final String utilInterfaceJars = "util-interface(-.*)?"; final String jansiJars = "jansi-[0-9.]+"; final String jnaJars = "jna-(platform-)?[0-9.]+"; final String fullPattern = String.format( - "^(%s|%s|%s|%s|%s)\\.jar", - jlineJars, testInterfaceJars, compilerInterfaceJars, jansiJars, jnaJars); + "^(%s|%s|%s|%s|%s|%s)\\.jar", + jlineJars, + testInterfaceJars, + compilerInterfaceJars, + utilInterfaceJars, + jansiJars, + jnaJars); final Pattern pattern = Pattern.compile(fullPattern); final File[] cp = appProvider.mainClasspath(); - final URL[] interfaceURLs = new URL[2]; + final URL[] interfaceURLs = new URL[3]; final URL[] jlineURLs = new URL[7]; final File[] extra = appProvider.id().classpathExtra() == null ? new File[0] : appProvider.id().classpathExtra(); @@ -86,7 +92,9 @@ public final class MetaBuildLoader extends URLClassLoader { int jlineIndex = 0; for (final File file : cp) { final String name = file.getName(); - if ((name.contains("test-interface") || name.contains("compiler-interface")) + if ((name.contains("test-interface") + || name.contains("compiler-interface") + || name.contains("util-interface")) && pattern.matcher(name).find()) { interfaceURLs[interfaceIndex] = file.toURI().toURL(); interfaceIndex += 1; diff --git a/main/src/main/java/sbt/internal/SbtInterfaceLoader.java b/main/src/main/java/sbt/internal/SbtInterfaceLoader.java index 27199529a..7d8d75450 100644 --- a/main/src/main/java/sbt/internal/SbtInterfaceLoader.java +++ b/main/src/main/java/sbt/internal/SbtInterfaceLoader.java @@ -18,7 +18,13 @@ class SbtInterfaceLoader extends URLClassLoader { @Override public String toString() { - return "SbtInterfaceClassLoader(" + getURLs()[0] + ")"; + final StringBuilder builder = new StringBuilder(); + URL[] urls = getURLs(); + for (int i = 0; i < urls.length; ++i) { + builder.append(urls[i].toString()); + if (i < urls.length - 2) builder.append(", "); + } + return "SbtInterfaceClassLoader(" + builder + ")"; } static { diff --git a/main/src/main/scala/sbt/Defaults.scala b/main/src/main/scala/sbt/Defaults.scala index 95cbb0a4a..f4f96f1f5 100644 --- a/main/src/main/scala/sbt/Defaults.scala +++ b/main/src/main/scala/sbt/Defaults.scala @@ -35,7 +35,7 @@ import sbt.Scope.{ GlobalScope, ThisScope, fillTaskAxis } import sbt.coursierint._ import sbt.internal.CommandStrings.ExportStream import sbt.internal._ -import sbt.internal.classpath.{ AlternativeZincUtil, ClassLoaderCache } +import sbt.internal.classpath.AlternativeZincUtil import sbt.internal.inc.JavaInterfaceUtil._ import sbt.internal.inc.classpath.{ ClasspathFilter, ClasspathUtil } import sbt.internal.inc.{ CompileOutput, MappedFileConverter, Stamps, ZincLmUtil, ZincUtil } @@ -745,7 +745,7 @@ object Defaults extends BuildCommon { scalaSrcDir.getParentFile / s"${scalaSrcDir.name}-$sv", scalaSrcDir.getParentFile / s"${scalaSrcDir.name}-$epochVersion", javaSrcDir, - ) + ).distinct else Seq(scalaSrcDir, javaSrcDir) } @@ -959,6 +959,13 @@ object Defaults extends BuildCommon { Vector("-Ypickle-java", "-Ypickle-write", converter.toPath(earlyOutput.value).toString) ++ old else old }, + scalacOptions := { + val old = scalacOptions.value + if (sbtPlugin.value && VersionNumber(scalaVersion.value) + .matchesSemVer(SemanticSelector("=2.12 >=2.12.13"))) + old ++ Seq("-Wconf:cat=unused-nowarn:s") + else old + }, persistJarClasspath :== true, classpathEntryDefinesClassVF := { (if (persistJarClasspath.value) classpathDefinesClassCache.value @@ -975,12 +982,17 @@ object Defaults extends BuildCommon { selectMainClass := mainClass.value orElse askForMainClass(discoveredMainClasses.value), run / mainClass := (run / selectMainClass).value, mainClass := { - val logWarning = state.value.currentCommand - .flatMap(_.commandLine.split(" ").headOption.map(_.trim)) - .fold(true) { - case "run" | "runMain" => false - case _ => true - } + val logWarning = state.value.currentCommand.forall(!_.commandLine.split(" ").exists { + case "run" | "runMain" => true + case r => + r.split("/") match { + case Array(parts @ _*) => + parts.lastOption match { + case Some("run" | "runMain") => true + case _ => false + } + } + }) pickMainClassOrWarn(discoveredMainClasses.value, streams.value.log, logWarning) }, runMain := foregroundRunMainTask.evaluated, @@ -1077,13 +1089,12 @@ object Defaults extends BuildCommon { val libraryJars = allJars.filter(_.getName == "scala-library.jar") allJars.filter(_.getName == "scala-compiler.jar") match { case Array(compilerJar) if libraryJars.nonEmpty => - val cache = state.value.extendedClassLoaderCache - mkScalaInstance( + makeScalaInstance( version, libraryJars, allJars, Seq.empty, - cache, + state.value, scalaInstanceTopLoader.value ) case _ => ScalaInstance(version, scalaProvider) @@ -1135,21 +1146,21 @@ object Defaults extends BuildCommon { .flatMap(_.artifacts.map(_._2)) val libraryJars = ScalaArtifacts.libraryIds(sv).map(file) - mkScalaInstance( + makeScalaInstance( sv, libraryJars, allCompilerJars, allDocJars, - state.value.extendedClassLoaderCache, + state.value, scalaInstanceTopLoader.value, ) } - private[this] def mkScalaInstance( + def makeScalaInstance( version: String, libraryJars: Array[File], allCompilerJars: Seq[File], allDocJars: Seq[File], - classLoaderCache: ClassLoaderCache, + state: State, topLoader: ClassLoader, ): ScalaInstance = { // Scala 2.10 shades jline in the console so we need to make sure that it loads a compatible @@ -1162,6 +1173,7 @@ object Defaults extends BuildCommon { } else topLoader + val classLoaderCache = state.extendedClassLoaderCache val compilerJars = allCompilerJars.filterNot(libraryJars.contains).distinct.toArray val docJars = allDocJars .filterNot(jar => libraryJars.contains(jar) || compilerJars.contains(jar)) @@ -1170,12 +1182,7 @@ object Defaults extends BuildCommon { val allJars = libraryJars ++ compilerJars ++ docJars val libraryLoader = classLoaderCache(libraryJars.toList, jansiExclusionLoader) - val compilerLoader = classLoaderCache( - // It should be `compilerJars` but it would break on `3.0.0-M2` because of - // https://github.com/lampepfl/dotty/blob/d932af954ef187d7bdb87500d49ed0ff530bd1e7/sbt-bridge/src/xsbt/CompilerClassLoader.java#L108-L117 - allCompilerJars.toList, - libraryLoader - ) + val compilerLoader = classLoaderCache(compilerJars.toList, libraryLoader) val fullLoader = if (docJars.isEmpty) compilerLoader else classLoaderCache(docJars.distinct.toList, compilerLoader) @@ -1196,12 +1203,12 @@ object Defaults extends BuildCommon { case a: AutoCloseable => a.close() case _ => } - mkScalaInstance( + makeScalaInstance( dummy.version, dummy.libraryJars, dummy.compilerJars, dummy.allJars, - state.value.extendedClassLoaderCache, + state.value, scalaInstanceTopLoader.value, ) } @@ -2107,7 +2114,11 @@ object Defaults extends BuildCommon { val projectName = name.value if (ScalaArtifacts.isScala3(sv)) { val project = if (config == Compile) projectName else s"$projectName-$config" - Seq("-project", project) + if (scalaVersion.value.startsWith("3.0.0")) { + Seq("-project", project) + } else { + compileOptions ++ Seq("-project", project) + } } else compileOptions }, (TaskZero / key) := { diff --git a/main/src/main/scala/sbt/Main.scala b/main/src/main/scala/sbt/Main.scala index 2064fa514..45ff32133 100644 --- a/main/src/main/scala/sbt/Main.scala +++ b/main/src/main/scala/sbt/Main.scala @@ -15,7 +15,7 @@ import java.util.Properties import java.util.concurrent.ForkJoinPool import java.util.concurrent.atomic.AtomicBoolean -import sbt.BasicCommandStrings.{ Shell, Shutdown, TemplateCommand } +import sbt.BasicCommandStrings.{ JavaClient, Shell, Shutdown, TemplateCommand } import sbt.Project.LoadAction import sbt.compiler.EvalImports import sbt.internal.Aggregation.AnyKeys @@ -23,22 +23,22 @@ import sbt.internal.CommandStrings.BootCommand import sbt.internal._ import sbt.internal.client.BspClient import sbt.internal.inc.ScalaInstance +import sbt.internal.io.Retry import sbt.internal.nio.{ CheckBuildSources, FileTreeRepository } import sbt.internal.server.{ BuildServerProtocol, NetworkChannel } import sbt.internal.util.Types.{ const, idFun } -import sbt.internal.util.{ Terminal => ITerminal, _ } import sbt.internal.util.complete.{ Parser, SizeParser } +import sbt.internal.util.{ Terminal => ITerminal, _ } import sbt.io._ import sbt.io.syntax._ import sbt.util.{ Level, Logger, Show } +import xsbti.AppProvider import xsbti.compile.CompilerCache import scala.annotation.{ nowarn, tailrec } import scala.concurrent.ExecutionContext import scala.concurrent.duration.Duration import scala.util.control.NonFatal -import sbt.internal.io.Retry -import xsbti.AppProvider /** This class is the entry point for sbt. */ final class xMain extends xsbti.AppMain { @@ -58,7 +58,7 @@ private[sbt] object xMain { } private[sbt] def run(configuration: xsbti.AppConfiguration): xsbti.MainResult = { try { - import BasicCommandStrings.{ DashClient, DashDashClient, DashDashServer, runEarly } + import BasicCommandStrings.{ DashDashClient, DashDashServer, runEarly } import BasicCommands.early import BuiltinCommands.defaults import sbt.internal.CommandStrings.{ BootCommand, DefaultsCommand, InitCommand } @@ -69,24 +69,56 @@ private[sbt] object xMain { val userCommands = configuration.arguments .map(_.trim) .filterNot(_ == DashDashServer) - val isClient: String => Boolean = cmd => (cmd == DashClient) || (cmd == DashDashClient) + val isClient: String => Boolean = cmd => (cmd == JavaClient) || (cmd == DashDashClient) val isBsp: String => Boolean = cmd => (cmd == "-bsp") || (cmd == "--bsp") - val isServer = !userCommands.exists(c => isBsp(c) || isClient(c)) - val bootServerSocket = if (isServer) getSocketOrExit(configuration) match { + val isNew: String => Boolean = cmd => (cmd == "new") + lazy val isServer = !userCommands.exists(c => isBsp(c) || isClient(c)) + // keep this lazy to prevent project directory created prematurely + lazy val bootServerSocket = if (isServer) getSocketOrExit(configuration) match { case (_, Some(e)) => return e case (s, _) => s } else None - if (userCommands.exists(isBsp)) { - BspClient.run(dealiasBaseDirectory(configuration)) - } else { - bootServerSocket.foreach(l => ITerminal.setBootStreams(l.inputStream, l.outputStream)) - val detachStdio = userCommands.exists(_ == BasicCommandStrings.DashDashDetachStdio) - ITerminal.withStreams(true, isSubProcess = detachStdio) { - if (clientModByEnv || userCommands.exists(isClient)) { + lazy val detachStdio = userCommands.exists(_ == BasicCommandStrings.DashDashDetachStdio) + def withStreams[A](f: => A): A = + try { + bootServerSocket.foreach(l => ITerminal.setBootStreams(l.inputStream, l.outputStream)) + ITerminal.withStreams(true, isSubProcess = detachStdio) { + f + } + } finally { + if (ITerminal.isAnsiSupported) { + // Clear any stray progress lines + System.out.print(ConsoleAppender.ClearScreenAfterCursor) + System.out.flush() + } + } + + userCommands match { + case cmds if cmds.exists(isBsp) => + BspClient.run(dealiasBaseDirectory(configuration)) + case cmds if cmds.exists(isNew) => + IO.withTemporaryDirectory { tempDir => + val rebasedConfig = new xsbti.AppConfiguration { + override def arguments: Array[String] = configuration.arguments() + override val baseDirectory: File = tempDir / "new" + override def provider: AppProvider = configuration.provider() + } + val state = StandardMain + .initialState( + rebasedConfig, + Seq(defaults, early), + runEarly(DefaultsCommand) :: runEarly(InitCommand) :: BootCommand :: Nil + ) + StandardMain.runManaged(state) + } + case _ if clientModByEnv || userCommands.exists(isClient) => + withStreams { val args = userCommands.toList.filterNot(isClient) Exit(NetworkClient.run(dealiasBaseDirectory(configuration), args)) - } else { + } + case _ => + withStreams { val state0 = StandardMain .initialState( dealiasBaseDirectory(configuration), @@ -101,15 +133,9 @@ private[sbt] object xMain { try StandardMain.runManaged(state) finally bootServerSocket.foreach(_.close()) } - } } } finally { - // Clear any stray progress lines ShutdownHooks.close() - if (ITerminal.isAnsiSupported) { - System.out.print(ConsoleAppender.ClearScreenAfterCursor) - System.out.flush() - } } } diff --git a/main/src/main/scala/sbt/PluginCross.scala b/main/src/main/scala/sbt/PluginCross.scala index 679a344dc..39dc0a071 100644 --- a/main/src/main/scala/sbt/PluginCross.scala +++ b/main/src/main/scala/sbt/PluginCross.scala @@ -99,7 +99,7 @@ private[sbt] object PluginCross { VersionNumber(sv) match { case VersionNumber(Seq(0, 12, _*), _, _) => "2.9.2" case VersionNumber(Seq(0, 13, _*), _, _) => "2.10.7" - case VersionNumber(Seq(1, 0, _*), _, _) => "2.12.13" + case VersionNumber(Seq(1, 0, _*), _, _) => "2.12.14" case _ => sys.error(s"Unsupported sbt binary version: $sv") } } diff --git a/main/src/main/scala/sbt/TemplateCommandUtil.scala b/main/src/main/scala/sbt/TemplateCommandUtil.scala index 34b1181ef..6c8831bbe 100644 --- a/main/src/main/scala/sbt/TemplateCommandUtil.scala +++ b/main/src/main/scala/sbt/TemplateCommandUtil.scala @@ -33,30 +33,19 @@ private[sbt] object TemplateCommandUtil { private def runTemplate(s0: State, inputArg: Seq[String]): State = { import BuildPaths._ - val extracted0 = (Project extract s0) val globalBase = getGlobalBase(s0) - val stagingDirectory = getStagingDirectory(s0, globalBase).getCanonicalFile - val templateStage = stagingDirectory / "new" - // This moves the target directory to a staging directory - // https://github.com/sbt/sbt/issues/2835 - val state = extracted0.appendWithSession( - Seq( - Keys.target := templateStage - ), - s0 - ) - val infos = (state get templateResolverInfos getOrElse Nil).toList - val log = state.globalLogging.full - val extracted = (Project extract state) - val (s2, ivyConf) = extracted.runTask(Keys.ivyConfiguration, state) + val infos = (s0 get templateResolverInfos getOrElse Nil).toList + val log = s0.globalLogging.full + val extracted = (Project extract s0) + val (s1, ivyConf) = extracted.runTask(Keys.ivyConfiguration, s0) val scalaModuleInfo = extracted.get(Keys.updateSbtClassifiers / Keys.scalaModuleInfo) val arguments = inputArg.toList ++ - (state.remainingCommands match { + (s0.remainingCommands match { case exec :: Nil if exec.commandLine == "shell" => Nil case xs => xs map (_.commandLine) }) - run(infos, arguments, state.configuration, ivyConf, globalBase, scalaModuleInfo, log) - TerminateAction :: s2.copy(remainingCommands = Nil) + run(infos, arguments, s0.configuration, ivyConf, globalBase, scalaModuleInfo, log) + TerminateAction :: s1.copy(remainingCommands = Nil) } private def run( diff --git a/main/src/main/scala/sbt/internal/RemoteCache.scala b/main/src/main/scala/sbt/internal/RemoteCache.scala index f116f5eb4..fe113a4d8 100644 --- a/main/src/main/scala/sbt/internal/RemoteCache.scala +++ b/main/src/main/scala/sbt/internal/RemoteCache.scala @@ -187,7 +187,8 @@ object RemoteCache { val artp = artifactPath.value val af = compileAnalysisFile.value IO.copyFile(original, artp) - if (af.exists) { + // skip zip manipulation if the artp is a blank file + if (af.exists && artp.length() > 0) { JarUtils.includeInJar(artp, Vector(af -> s"META-INF/inc_compile.zip")) } val rf = getResourceFilePaths.value diff --git a/main/src/main/scala/sbt/internal/server/BuildServerProtocol.scala b/main/src/main/scala/sbt/internal/server/BuildServerProtocol.scala index 52aef4e4f..9a4acba8d 100644 --- a/main/src/main/scala/sbt/internal/server/BuildServerProtocol.scala +++ b/main/src/main/scala/sbt/internal/server/BuildServerProtocol.scala @@ -11,7 +11,6 @@ package server import java.net.URI -import sbt.BasicCommandStrings.Shutdown import sbt.BuildSyntax._ import sbt.Def._ import sbt.Keys._ @@ -239,7 +238,7 @@ object BuildServerProtocol { ServerHandler { callback => ServerIntent( onRequest = { - case r: JsonRpcRequestMessage if r.method == "build/initialize" => + case r if r.method == "build/initialize" => val params = Converter.fromJson[InitializeBuildParams](json(r)).get checkMetalsCompatibility(semanticdbEnabled, semanticdbVersion, params, callback.log) @@ -252,19 +251,16 @@ object BuildServerProtocol { ) callback.jsonRpcRespond(response, Some(r.id)); () - case r: JsonRpcRequestMessage if r.method == "workspace/buildTargets" => + case r if r.method == "workspace/buildTargets" => val _ = callback.appendExec(Keys.bspWorkspaceBuildTargets.key.toString, Some(r.id)) - case r: JsonRpcRequestMessage if r.method == "workspace/reload" => + case r if r.method == "workspace/reload" => val _ = callback.appendExec(s"$bspReload ${r.id}", Some(r.id)) - case r: JsonRpcRequestMessage if r.method == "build/shutdown" => + case r if r.method == "build/shutdown" => callback.jsonRpcRespond(JNull, Some(r.id)) - case r: JsonRpcRequestMessage if r.method == "build/exit" => - val _ = callback.appendExec(Shutdown, Some(r.id)) - - case r: JsonRpcRequestMessage if r.method == "buildTarget/sources" => + case r if r.method == "buildTarget/sources" => val param = Converter.fromJson[SourcesParams](json(r)).get val targets = param.targets.map(_.uri).mkString(" ") val command = Keys.bspBuildTargetSources.key @@ -306,26 +302,29 @@ object BuildServerProtocol { Some(r.id) ) - case r: JsonRpcRequestMessage if r.method == "buildTarget/scalacOptions" => + case r if r.method == "buildTarget/scalacOptions" => val param = Converter.fromJson[ScalacOptionsParams](json(r)).get val targets = param.targets.map(_.uri).mkString(" ") val command = Keys.bspBuildTargetScalacOptions.key val _ = callback.appendExec(s"$command $targets", Some(r.id)) - case r: JsonRpcRequestMessage if r.method == "buildTarget/scalaTestClasses" => + case r if r.method == "buildTarget/scalaTestClasses" => val param = Converter.fromJson[ScalaTestClassesParams](json(r)).get val targets = param.targets.map(_.uri).mkString(" ") val command = Keys.bspScalaTestClasses.key val _ = callback.appendExec(s"$command $targets", Some(r.id)) - case r: JsonRpcRequestMessage if r.method == "buildTarget/scalaMainClasses" => + case r if r.method == "buildTarget/scalaMainClasses" => val param = Converter.fromJson[ScalaMainClassesParams](json(r)).get val targets = param.targets.map(_.uri).mkString(" ") val command = Keys.bspScalaMainClasses.key val _ = callback.appendExec(s"$command $targets", Some(r.id)) }, onResponse = PartialFunction.empty, - onNotification = PartialFunction.empty, + onNotification = { + case r if r.method == "build/exit" => + val _ = callback.appendExec(BasicCommandStrings.TerminateAction, None) + }, ) } } diff --git a/main/src/main/scala/sbt/plugins/SbtPlugin.scala b/main/src/main/scala/sbt/plugins/SbtPlugin.scala index 5bebadc1d..3572972f7 100644 --- a/main/src/main/scala/sbt/plugins/SbtPlugin.scala +++ b/main/src/main/scala/sbt/plugins/SbtPlugin.scala @@ -8,24 +8,13 @@ package sbt package plugins -import Keys._ -import Def.Setting -import sbt.SlashSyntax0._ -import sbt.librarymanagement.Configurations.Compile -import sbt.librarymanagement.{ SemanticSelector, VersionNumber } +import sbt.Def.Setting +import sbt.Keys._ object SbtPlugin extends AutoPlugin { override def requires = ScriptedPlugin override lazy val projectSettings: Seq[Setting[_]] = Seq( - sbtPlugin := true, - Compile / scalacOptions ++= { - // silence unused @nowarns in 2.12 because of https://github.com/sbt/sbt/issues/6398 - // the option is only available since 2.12.13 - if (VersionNumber(scalaVersion.value).matchesSemVer(SemanticSelector("=2.12 >=2.12.13"))) - Some("-Wconf:cat=unused-nowarn:s") - else - None - } + sbtPlugin := true ) } diff --git a/main/src/main/scala/sbt/plugins/SemanticdbPlugin.scala b/main/src/main/scala/sbt/plugins/SemanticdbPlugin.scala index ee0df6f42..a10f49725 100644 --- a/main/src/main/scala/sbt/plugins/SemanticdbPlugin.scala +++ b/main/src/main/scala/sbt/plugins/SemanticdbPlugin.scala @@ -26,7 +26,7 @@ object SemanticdbPlugin extends AutoPlugin { semanticdbEnabled := SysProp.semanticdb, semanticdbIncludeInJar := false, semanticdbOptions := List(), - semanticdbVersion := "4.4.10" + semanticdbVersion := "4.4.20" ) override lazy val projectSettings: Seq[Def.Setting[_]] = Seq( diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 9e5450767..76ed2003e 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -4,29 +4,29 @@ import sbt.contraband.ContrabandPlugin.autoImport._ object Dependencies { // WARNING: Please Scala update versions in PluginCross.scala too - val scala212 = "2.12.13" - val scala213 = "2.13.5" + val scala212 = "2.12.14" + val scala213 = "2.13.6" val checkPluginCross = settingKey[Unit]("Make sure scalaVersion match up") val baseScalaVersion = scala212 def nightlyVersion: Option[String] = sys.env.get("BUILD_VERSION") orElse sys.props.get("sbt.build.version") // sbt modules - private val ioVersion = nightlyVersion.getOrElse("1.5.0") + private val ioVersion = nightlyVersion.getOrElse("1.5.1") private val lmVersion = - sys.props.get("sbt.build.lm.version").orElse(nightlyVersion).getOrElse("1.5.0") - val zincVersion = nightlyVersion.getOrElse("1.5.1") + sys.props.get("sbt.build.lm.version").orElse(nightlyVersion).getOrElse("1.5.2") + val zincVersion = nightlyVersion.getOrElse("1.5.5") private val sbtIO = "org.scala-sbt" %% "io" % ioVersion private val libraryManagementCore = "org.scala-sbt" %% "librarymanagement-core" % lmVersion private val libraryManagementIvy = "org.scala-sbt" %% "librarymanagement-ivy" % lmVersion - val launcherVersion = "1.3.1" + val launcherVersion = "1.3.2" val launcherInterface = "org.scala-sbt" % "launcher-interface" % launcherVersion val rawLauncher = "org.scala-sbt" % "launcher" % launcherVersion val testInterface = "org.scala-sbt" % "test-interface" % "1.0" - val ipcSocket = "org.scala-sbt.ipcsocket" % "ipcsocket" % "1.3.0" + val ipcSocket = "org.scala-sbt.ipcsocket" % "ipcsocket" % "1.3.1" private val compilerInterface = "org.scala-sbt" % "compiler-interface" % zincVersion private val compilerClasspath = "org.scala-sbt" %% "zinc-classpath" % zincVersion @@ -116,5 +116,5 @@ object Dependencies { val hedgehog = "qa.hedgehog" %% "hedgehog-sbt" % "0.6.1" val disruptor = "com.lmax" % "disruptor" % "3.4.2" - val kindProjector = ("org.typelevel" % "kind-projector" % "0.11.3").cross(CrossVersion.full) + val kindProjector = ("org.typelevel" % "kind-projector" % "0.13.0").cross(CrossVersion.full) } diff --git a/project/HouseRulesPlugin.scala b/project/HouseRulesPlugin.scala index 42d1c2e6d..4a0b9fa1e 100644 --- a/project/HouseRulesPlugin.scala +++ b/project/HouseRulesPlugin.scala @@ -30,7 +30,7 @@ object HouseRulesPlugin extends AutoPlugin { scalacOptions += "-Ywarn-value-discard", scalacOptions ++= "-Ywarn-unused-import".ifScala(v => 11 <= v && v <= 12).value.toList ) ++ Seq(Compile, Test).flatMap( - c => scalacOptions in (c, console) --= Seq("-Ywarn-unused-import", "-Xlint") + c => (c / console / scalacOptions) --= Seq("-Ywarn-unused-import", "-Xlint") ) private def scalaPartV = Def setting (CrossVersion partialVersion scalaVersion.value) diff --git a/project/PublishBinPlugin.scala b/project/PublishBinPlugin.scala index 804f6461a..5e5397c4b 100644 --- a/project/PublishBinPlugin.scala +++ b/project/PublishBinPlugin.scala @@ -27,8 +27,8 @@ object PublishBinPlugin extends AutoPlugin { Classpaths.deliverPattern(crossTarget.value), if (isSnapshot.value) "integration" else "release", ivyConfigurations.value.map(c => ConfigRef(c.name)).toVector, - (packagedArtifacts in publishLocalBin).value.toVector, - (checksums in publishLocalBin).value.toVector, + (publishLocalBin / packagedArtifacts).value.toVector, + (publishLocalBin / checksums).value.toVector, logging = ivyLoggingLevel.value, overwrite = isSnapshot.value ), @@ -59,9 +59,9 @@ object PublishBinPlugin extends AutoPlugin { dummyFile }, dummyDoc / packagedArtifact := (Compile / packageDoc / artifact).value -> dummyDoc.value, - packagedArtifacts in publishLocalBin := + publishLocalBin / packagedArtifacts := Classpaths - .packaged(Seq(packageBin in Compile, packageSrc in Compile, makePom, dummyDoc)) + .packaged(Seq(Compile / packageBin, Compile / packageSrc, makePom, dummyDoc)) .value ) } diff --git a/project/SbtLauncherPlugin.scala b/project/SbtLauncherPlugin.scala index 0c24d2de5..65f9f2e67 100644 --- a/project/SbtLauncherPlugin.scala +++ b/project/SbtLauncherPlugin.scala @@ -26,7 +26,7 @@ object SbtLauncherPlugin extends AutoPlugin { } }, sbtLaunchJar := { - val propFiles = (resources in Compile).value + val propFiles = (Compile / resources).value val propFileLocations = for (file <- propFiles; if file.getName != "resources") yield { if (file.getName == "sbt.boot.properties") "sbt/sbt.boot.properties" -> file diff --git a/project/Util.scala b/project/Util.scala index 8618f206d..cf8b75cc8 100644 --- a/project/Util.scala +++ b/project/Util.scala @@ -22,7 +22,7 @@ object Util { lazy val javaOnlySettings: Seq[Setting[_]] = Seq( // crossPaths := false, // compileOrder := CompileOrder.JavaThenScala, - unmanagedSourceDirectories in Compile := Seq((javaSource in Compile).value) + Compile / unmanagedSourceDirectories := Seq((Compile / javaSource).value) ) lazy val baseScalacOptions = Seq( @@ -131,7 +131,7 @@ object Util { def excludePomArtifact(artifactId: String) = (artifactId startsWith "compiler-bridge") - val testExclusive = tags in test += ((ExclusiveTest, 1)) + val testExclusive = test / tags += (ExclusiveTest, 1) // TODO: replace with Tags.exclusive after 0.12.0 val testExclusiveRestriction = Tags.customLimit { (tags: Map[Tags.Tag, Int]) => @@ -184,9 +184,9 @@ object Licensed { def settings: Seq[Setting[_]] = Seq( notice := (baseDirectory.value / "NOTICE"), - unmanagedResources in Compile ++= notice.value +: extractLicenses.value, + Compile / unmanagedResources ++= notice.value +: extractLicenses.value, extractLicenses := extractLicenses0( - (baseDirectory in ThisBuild).value, + (ThisBuild / baseDirectory).value, notice.value, streams.value ) diff --git a/project/build.properties b/project/build.properties index dbae93bcf..9edb75b77 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.4.9 +sbt.version=1.5.4 diff --git a/project/plugins.sbt b/project/plugins.sbt index 6fd8635fe..245e11f02 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -9,5 +9,5 @@ addSbtPlugin("org.scala-sbt" % "sbt-contraband" % "0.5.1") addSbtPlugin("de.heikoseeberger" % "sbt-header" % "3.0.2") addSbtPlugin("com.lightbend" % "sbt-whitesource" % "0.1.14") addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.9") -addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.6.1") +addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.8.1") addSbtPlugin("com.swoval" % "sbt-java-format" % "0.3.1") diff --git a/protocol/src/main/scala/sbt/internal/bsp/BuildTargetTag.scala b/protocol/src/main/scala/sbt/internal/bsp/BuildTargetTag.scala index e522fb482..fa1773f27 100644 --- a/protocol/src/main/scala/sbt/internal/bsp/BuildTargetTag.scala +++ b/protocol/src/main/scala/sbt/internal/bsp/BuildTargetTag.scala @@ -18,6 +18,7 @@ object BuildTargetTag { def fromConfig(config: String): Vector[String] = config match { case "test" => Vector(test) + case "it" => Vector(integrationTest) case "compile" => Vector(library) case _ => Vector.empty } diff --git a/sbt b/sbt index 36b36af26..8adff2117 100755 --- a/sbt +++ b/sbt @@ -1,7 +1,7 @@ #!/usr/bin/env bash set +e -declare builtin_sbt_version="1.5.1" +declare builtin_sbt_version="1.5.4" declare -a residual_args declare -a java_args declare -a scalac_args @@ -22,6 +22,7 @@ declare sbt_debug= declare build_props_sbt_version= declare use_sbtn= declare sbtn_command="$SBTN_CMD" +declare sbtn_version="1.4.7" ### ------------------------------- ### ### Helper methods for BASH scripts ### @@ -126,7 +127,8 @@ acquire_sbt_jar () { launcher_sv="$builtin_sbt_version" fi fi - download_jar="$HOME/.cache/sbt/boot/sbt-launch/$launcher_sv/sbt-launch-$launcher_sv.jar" + local user_home && user_home=$(findProperty user.home) + download_jar="${user_home:-$HOME}/.cache/sbt/boot/sbt-launch/$launcher_sv/sbt-launch-$launcher_sv.jar" if [[ -f "$download_jar" ]]; then sbt_jar="$download_jar" else @@ -153,6 +155,42 @@ acquire_sbt_jar () { fi } +acquire_sbtn () { + local sbtn_v="$1" + local user_home && user_home=$(findProperty user.home) + local p="${user_home:-$HOME}/.cache/sbt/boot/sbtn/$sbtn_v" + local target="$p/sbtn" + local archive_target= + local url= + if [[ "$OSTYPE" == "linux-gnu"* ]]; then + archive_target="$p/sbtn-x86_64-pc-linux-${sbtn_v}.tar.gz" + url="https://github.com/sbt/sbtn-dist/releases/download/v${sbtn_v}/sbtn-x86_64-pc-linux-${sbtn_v}.tar.gz" + elif [[ "$OSTYPE" == "darwin"* ]]; then + archive_target="$p/sbtn-x86_64-apple-darwin-${sbtn_v}.tar.gz" + url="https://github.com/sbt/sbtn-dist/releases/download/v${sbtn_v}/sbtn-x86_64-apple-darwin-${sbtn_v}.tar.gz" + elif [[ "$OSTYPE" == "cygwin" ]] || [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "win32" ]]; then + target="$p/sbtn.exe" + archive_target="$p/sbtn-x86_64-pc-win32-${sbtn_v}.zip" + url="https://github.com/sbt/sbtn-dist/releases/download/v${sbtn_v}/sbtn-x86_64-pc-win32-${sbtn_v}.zip" + else + echoerr "sbtn is not supported on $OSTYPE" + exit 2 + fi + + if [[ -f "$target" ]]; then + sbtn_command="$target" + else + echoerr "downloading sbtn ${sbtn_v}" + download_url "$url" "$archive_target" + if [[ "$OSTYPE" == "linux-gnu"* ]] || [[ "$OSTYPE" == "darwin"* ]]; then + tar zxf "$archive_target" --directory "$p" + else + unzip "$archive_target" -d "$p" + fi + sbtn_command="$target" + fi +} + # execRunner should be called only once to give up control to java execRunner () { # print the arguments one to a line, quoting any containing spaces @@ -301,39 +339,49 @@ jdk_version() { echo "$result" } -# Extracts the preloaded directory from either -Dsbt.preloaded or -Dsbt.global.base -# properties by looking at: -# - _JAVA_OPTIONS environment variable, +# Find the first occurrence of the given property name and returns its value by looking at: +# - properties set by command-line options, +# - JAVA_OPTS environment variable, # - SBT_OPTS environment variable, -# - JAVA_OPTS environment variable and -# - properties set by command-line options -# in that order. The last one will be chosen such that `sbt.preloaded` is -# always preferred over `sbt.global.base`. -getPreloaded() { - local -a _java_options_array - local -a sbt_opts_array +# - _JAVA_OPTIONS environment variable and +# - JAVA_TOOL_OPTIONS environment variable +# in that order. +findProperty() { local -a java_opts_array - read -a _java_options_array <<< "$_JAVA_OPTIONS" - read -a sbt_opts_array <<< "$SBT_OPTS" + local -a sbt_opts_array + local -a _java_options_array + local -a java_tool_options_array read -a java_opts_array <<< "$JAVA_OPTS" + read -a sbt_opts_array <<< "$SBT_OPTS" + read -a _java_options_array <<< "$_JAVA_OPTIONS" + read -a java_tool_options_array <<< "$JAVA_TOOL_OPTIONS" local args_to_check=( - "${_java_options_array[@]}" - "${sbt_opts_array[@]}" + "${java_args[@]}" "${java_opts_array[@]}" - "${java_args[@]}") - local via_global_base="$HOME/.sbt/preloaded" - local via_explicit="" + "${sbt_opts_array[@]}" + "${_java_options_array[@]}" + "${java_tool_options_array[@]}") for opt in "${args_to_check[@]}"; do - if [[ "$opt" == -Dsbt.preloaded=* ]]; then - via_explicit="${opt#-Dsbt.preloaded=}" - elif [[ "$opt" == -Dsbt.global.base=* ]]; then - via_global_base="${opt#-Dsbt.global.base=}/preloaded" + if [[ "$opt" == -D$1=* ]]; then + echo "${opt#-D$1=}" + return fi done +} - echo "${via_explicit:-${via_global_base}}" +# Extracts the preloaded directory from either -Dsbt.preloaded, -Dsbt.global.base or -Duser.home +# in that order. +getPreloaded() { + local preloaded && preloaded=$(findProperty sbt.preloaded) + [ "$preloaded" ] && echo "$preloaded" && return + + local global_base && global_base=$(findProperty sbt.global.base) + [ "$global_base" ] && echo "$global_base/preloaded" && return + + local user_home && user_home=$(findProperty user.home) + echo "${user_home:-$HOME}/.sbt/preloaded" } syncPreloaded() { @@ -582,7 +630,7 @@ process_args () { --numeric-version) print_sbt_version=1 && shift ;; --script-version) print_sbt_script_version=1 && shift ;; -d|-debug|--debug) sbt_debug=1 && addSbt "-debug" && shift ;; - --client) use_sbtn=1 && shift ;; + -client|--client) use_sbtn=1 && shift ;; --server) use_sbtn=0 && shift ;; -mem|--mem) require_arg integer "$1" "$2" && addMemory "$2" && shift 2 ;; @@ -650,7 +698,7 @@ isRunNativeClient() { sbtBinaryV_1=$(echo "$sbtV" | sed 's/^\([0-9]*\)\.\([0-9]*\).*$/\1/') sbtBinaryV_2=$(echo "$sbtV" | sed 's/^\([0-9]*\)\.\([0-9]*\).*$/\2/') if (( $sbtBinaryV_1 >= 2 )) || ( (( $sbtBinaryV_1 >= 1 )) && (( $sbtBinaryV_2 >= 4 )) ); then - if [[ "$use_sbtn" == "1" ]] && [[ "$sbtn_command" != "" ]]; then + if [[ "$use_sbtn" == "1" ]]; then echo "true" else echo "false" @@ -662,6 +710,10 @@ isRunNativeClient() { runNativeClient() { vlog "[debug] running native client" + detectNativeClient + [[ -f "$sbtn_command" ]] || acquire_sbtn "$sbtn_version" || { + exit 1 + } for i in "${!original_args[@]}"; do if [[ "${original_args[i]}" = "--client" ]]; then unset 'original_args[i]' @@ -691,8 +743,6 @@ original_args=("$@") [[ -f "$build_props_file" ]] && loadPropFile "$build_props_file" -detectNativeClient - java_args=($JAVA_OPTS) sbt_options0=(${SBT_OPTS:-$default_sbt_opts}) if [[ "$SBT_NATIVE_CLIENT" == "true" ]]; then diff --git a/sbt-app/src/sbt-test/actions/cross-advanced/build.sbt b/sbt-app/src/sbt-test/actions/cross-advanced/build.sbt index 0076195d7..c4e16f6ef 100644 --- a/sbt-app/src/sbt-test/actions/cross-advanced/build.sbt +++ b/sbt-app/src/sbt-test/actions/cross-advanced/build.sbt @@ -10,19 +10,19 @@ lazy val root = (project in file(".")) lazy val foo = project .settings( - crossScalaVersions := Seq("2.12.13", "2.13.1"), + crossScalaVersions := Seq("2.12.14", "2.13.1"), libraryDependencies += "org.scalatest" %% "scalatest" % "3.1.0", check := { // This tests that +check will respect bar's crossScalaVersions and not switch val x = (LocalProject("bar") / scalaVersion).value - assert(x == "2.12.13", s"$x == 2.12.12") + assert(x == "2.12.14", s"$x == 2.12.12") (Compile / compile).value }, (Test / testOnly) := { // This tests that +testOnly will respect bar's crossScalaVersions and not switch val x = (LocalProject("bar") / scalaVersion).value - assert(x == "2.12.13", s"$x == 2.12.12") + assert(x == "2.12.14", s"$x == 2.12.12") val _ = (Test / testOnly).evaluated }, compile2 := { @@ -35,7 +35,7 @@ lazy val foo = project lazy val bar = project .settings( - crossScalaVersions := Seq("2.12.13"), + crossScalaVersions := Seq("2.12.14"), check := (Compile / compile).value, compile2 := (Compile / compile).value, ) @@ -46,14 +46,14 @@ lazy val baz = project check := { // This tests that +baz/check will respect bar's crossScalaVersions and not switch val x = (LocalProject("bar") / scalaVersion).value - assert(x == "2.12.13", s"$x == 2.12.13") + assert(x == "2.12.14", s"$x == 2.12.14") (Compile / compile).value }, ) lazy val client = project .settings( - crossScalaVersions := Seq("2.12.13", "2.13.1"), + crossScalaVersions := Seq("2.12.14", "2.13.1"), check := (Compile / compile).value, compile2 := (Compile / compile).value, ) diff --git a/sbt-app/src/sbt-test/actions/cross-advanced/test b/sbt-app/src/sbt-test/actions/cross-advanced/test index 9aabd48d6..6f606cd4a 100644 --- a/sbt-app/src/sbt-test/actions/cross-advanced/test +++ b/sbt-app/src/sbt-test/actions/cross-advanced/test @@ -17,7 +17,7 @@ ## test + with command or alias > clean ## for command cross building you do need crossScalaVerions on root -> set root/crossScalaVersions := Seq("2.12.13", "2.13.1") +> set root/crossScalaVersions := Seq("2.12.14", "2.13.1") > + build $ exists foo/target/scala-2.12 $ exists foo/target/scala-2.13 diff --git a/sbt-app/src/sbt-test/compiler-project/scala3-tasty-management/build.sbt b/sbt-app/src/sbt-test/compiler-project/scala3-tasty-management/build.sbt index 8796ff21b..538540498 100644 --- a/sbt-app/src/sbt-test/compiler-project/scala3-tasty-management/build.sbt +++ b/sbt-app/src/sbt-test/compiler-project/scala3-tasty-management/build.sbt @@ -1,6 +1,6 @@ import xsbti.compile.TastyFiles -ThisBuild / scalaVersion := "3.0.0-M2" +ThisBuild / scalaVersion := "3.0.0-M3" TaskKey[Unit]("check") := { assert((Compile / auxiliaryClassFiles).value == Seq(TastyFiles.instance)) diff --git a/sbt-app/src/sbt-test/compiler-project/scala3-tasty-management/test b/sbt-app/src/sbt-test/compiler-project/scala3-tasty-management/test index 52f74a532..e709a96dd 100644 --- a/sbt-app/src/sbt-test/compiler-project/scala3-tasty-management/test +++ b/sbt-app/src/sbt-test/compiler-project/scala3-tasty-management/test @@ -1,12 +1,12 @@ > check > compile -$ exists target/scala-3.0.0-M2/classes/A.tasty -$ exists target/scala-3.0.0-M2/classes/B.tasty +$ exists target/scala-3.0.0-M3/classes/A.tasty +$ exists target/scala-3.0.0-M3/classes/B.tasty $ delete src/main/scala/B.scala > compile -$ exists target/scala-3.0.0-M2/classes/A.tasty --$ exists target/scala-3.0.0-M2/classes/B.tasty +$ exists target/scala-3.0.0-M3/classes/A.tasty +-$ exists target/scala-3.0.0-M3/classes/B.tasty diff --git a/sbt-app/src/sbt-test/dependency-graph/whatDependsOn-without-previous-initialization/build.sbt b/sbt-app/src/sbt-test/dependency-graph/whatDependsOn-without-previous-initialization/build.sbt index 0586054cd..4826145e5 100644 --- a/sbt-app/src/sbt-test/dependency-graph/whatDependsOn-without-previous-initialization/build.sbt +++ b/sbt-app/src/sbt-test/dependency-graph/whatDependsOn-without-previous-initialization/build.sbt @@ -1,18 +1,11 @@ -ThisBuild / useCoursier := false - -version := "0.1.0-SNAPSHOT" - -organization := "default" +ThisBuild / version := "0.1.0-SNAPSHOT" +ThisBuild / scalaVersion := "2.13.5" name := "whatDependsOn" -scalaVersion := "2.9.1" - -resolvers += "typesafe maven" at "https://repo.typesafe.com/typesafe/maven-releases/" - libraryDependencies ++= Seq( - "com.codahale" % "jerkson_2.9.1" % "0.5.0", - "org.codehaus.jackson" % "jackson-mapper-asl" % "1.9.10" // as another version of asl + "co.fs2" %% "fs2-core" % "1.0.4", + "org.typelevel" %% "cats-effect" % "3.1.0" ) val check = TaskKey[Unit]("check") @@ -23,36 +16,36 @@ check := { require(sanitize(expected) == sanitize(output), s"Tree should have been [\n${sanitize(expected)}\n] but was [\n${sanitize(output)}\n]") val withVersion = - (whatDependsOn in Compile) - .toTask(" org.codehaus.jackson jackson-core-asl 1.9.11") + (Compile / whatDependsOn) + .toTask(" org.typelevel cats-core_2.13 2.6.0") .value - val expectedGraphWithVersion = - """org.codehaus.jackson:jackson-core-asl:1.9.11 - | +-com.codahale:jerkson_2.9.1:0.5.0 [S] - | | +-default:whatdependson_2.9.1:0.1.0-SNAPSHOT [S] - | | - | +-org.codehaus.jackson:jackson-mapper-asl:1.9.11 - | +-com.codahale:jerkson_2.9.1:0.5.0 [S] - | | +-default:whatdependson_2.9.1:0.1.0-SNAPSHOT [S] - | | - | +-default:whatdependson_2.9.1:0.1.0-SNAPSHOT [S] - | """.stripMargin + val expectedGraphWithVersion = { + """org.typelevel:cats-core_2.13:2.6.0 [S] + |+-org.typelevel:cats-effect-kernel_2.13:3.1.0 [S] + |+-org.typelevel:cats-effect-std_2.13:3.1.0 [S] + || +-org.typelevel:cats-effect_2.13:3.1.0 [S] + || +-whatdependson:whatdependson_2.13:0.1.0-SNAPSHOT [S] + || + |+-org.typelevel:cats-effect_2.13:3.1.0 [S] + |+-whatdependson:whatdependson_2.13:0.1.0-SNAPSHOT [S]""".stripMargin + } - checkOutput(withVersion, expectedGraphWithVersion) + checkOutput(withVersion.trim, expectedGraphWithVersion.trim) val withoutVersion = - (whatDependsOn in Compile) - .toTask(" org.codehaus.jackson jackson-mapper-asl") + (Compile / whatDependsOn) + .toTask(" org.typelevel cats-core_2.13") .value val expectedGraphWithoutVersion = - """org.codehaus.jackson:jackson-mapper-asl:1.9.11 - | +-com.codahale:jerkson_2.9.1:0.5.0 [S] - | | +-default:whatdependson_2.9.1:0.1.0-SNAPSHOT [S] - | | - | +-default:whatdependson_2.9.1:0.1.0-SNAPSHOT [S] - | - |org.codehaus.jackson:jackson-mapper-asl:1.9.10 (evicted by: 1.9.11) - | +-default:whatdependson_2.9.1:0.1.0-SNAPSHOT [S] - | """.stripMargin - checkOutput(withoutVersion, expectedGraphWithoutVersion) + """org.typelevel:cats-core_2.13:2.6.0 [S] + |+-org.typelevel:cats-effect-kernel_2.13:3.1.0 [S] + |+-org.typelevel:cats-effect-std_2.13:3.1.0 [S] + || +-org.typelevel:cats-effect_2.13:3.1.0 [S] + || +-whatdependson:whatdependson_2.13:0.1.0-SNAPSHOT [S] + || + |+-org.typelevel:cats-effect_2.13:3.1.0 [S] + |+-whatdependson:whatdependson_2.13:0.1.0-SNAPSHOT [S]""".stripMargin + + checkOutput(withoutVersion.trim, expectedGraphWithoutVersion.trim) + } diff --git a/sbt-app/src/sbt-test/dependency-graph/whatDependsOn-without-previous-initialization/disabled b/sbt-app/src/sbt-test/dependency-graph/whatDependsOn-without-previous-initialization/test similarity index 100% rename from sbt-app/src/sbt-test/dependency-graph/whatDependsOn-without-previous-initialization/disabled rename to sbt-app/src/sbt-test/dependency-graph/whatDependsOn-without-previous-initialization/test diff --git a/sbt-app/src/sbt-test/dependency-graph/whatDependsOn/build.sbt b/sbt-app/src/sbt-test/dependency-graph/whatDependsOn/build.sbt index 8b3a0d5e1..4826145e5 100644 --- a/sbt-app/src/sbt-test/dependency-graph/whatDependsOn/build.sbt +++ b/sbt-app/src/sbt-test/dependency-graph/whatDependsOn/build.sbt @@ -1,13 +1,11 @@ ThisBuild / version := "0.1.0-SNAPSHOT" -ThisBuild / scalaVersion := "2.9.1" +ThisBuild / scalaVersion := "2.13.5" name := "whatDependsOn" -resolvers += "typesafe maven" at "https://repo.typesafe.com/typesafe/maven-releases/" - libraryDependencies ++= Seq( - "com.codahale" % "jerkson_2.9.1" % "0.5.0", - "org.codehaus.jackson" % "jackson-mapper-asl" % "1.9.10" // as another version of asl + "co.fs2" %% "fs2-core" % "1.0.4", + "org.typelevel" %% "cats-effect" % "3.1.0" ) val check = TaskKey[Unit]("check") @@ -18,37 +16,36 @@ check := { require(sanitize(expected) == sanitize(output), s"Tree should have been [\n${sanitize(expected)}\n] but was [\n${sanitize(output)}\n]") val withVersion = - (whatDependsOn in Compile) - .toTask(" org.codehaus.jackson jackson-core-asl 1.9.10") + (Compile / whatDependsOn) + .toTask(" org.typelevel cats-core_2.13 2.6.0") .value - val expectedGraphWithVersion = - """org.codehaus.jackson:jackson-core-asl:1.9.10 - | +-com.codahale:jerkson_2.9.1:0.5.0 [S] - | | +-whatdependson:whatdependson_2.9.1:0.1.0-SNAPSHOT [S] - | | - | +-org.codehaus.jackson:jackson-mapper-asl:1.9.10 - | +-com.codahale:jerkson_2.9.1:0.5.0 [S] - | | +-whatdependson:whatdependson_2.9.1:0.1.0-SNAPSHOT [S] - | | - | +-whatdependson:whatdependson_2.9.1:0.1.0-SNAPSHOT [S] - | """.stripMargin + val expectedGraphWithVersion = { + """org.typelevel:cats-core_2.13:2.6.0 [S] + |+-org.typelevel:cats-effect-kernel_2.13:3.1.0 [S] + |+-org.typelevel:cats-effect-std_2.13:3.1.0 [S] + || +-org.typelevel:cats-effect_2.13:3.1.0 [S] + || +-whatdependson:whatdependson_2.13:0.1.0-SNAPSHOT [S] + || + |+-org.typelevel:cats-effect_2.13:3.1.0 [S] + |+-whatdependson:whatdependson_2.13:0.1.0-SNAPSHOT [S]""".stripMargin + } - checkOutput(withVersion, expectedGraphWithVersion) + checkOutput(withVersion.trim, expectedGraphWithVersion.trim) val withoutVersion = - (whatDependsOn in Compile) - .toTask(" org.codehaus.jackson jackson-mapper-asl") + (Compile / whatDependsOn) + .toTask(" org.typelevel cats-core_2.13") .value val expectedGraphWithoutVersion = - """org.codehaus.jackson:jackson-mapper-asl:1.9.10 - | +-com.codahale:jerkson_2.9.1:0.5.0 [S] - | | +-whatdependson:whatdependson_2.9.1:0.1.0-SNAPSHOT [S] - | | - | +-whatdependson:whatdependson_2.9.1:0.1.0-SNAPSHOT [S] - | - |org.codehaus.jackson:jackson-mapper-asl:[1.9.0,2.0.0) (evicted by: 1.9.10) - | +-com.codahale:jerkson_2.9.1:0.5.0 [S] - | +-whatdependson:whatdependson_2.9.1:0.1.0-SNAPSHOT [S] - | """.stripMargin - checkOutput(withoutVersion, expectedGraphWithoutVersion) + """org.typelevel:cats-core_2.13:2.6.0 [S] + |+-org.typelevel:cats-effect-kernel_2.13:3.1.0 [S] + |+-org.typelevel:cats-effect-std_2.13:3.1.0 [S] + || +-org.typelevel:cats-effect_2.13:3.1.0 [S] + || +-whatdependson:whatdependson_2.13:0.1.0-SNAPSHOT [S] + || + |+-org.typelevel:cats-effect_2.13:3.1.0 [S] + |+-whatdependson:whatdependson_2.13:0.1.0-SNAPSHOT [S]""".stripMargin + + checkOutput(withoutVersion.trim, expectedGraphWithoutVersion.trim) + } diff --git a/sbt-app/src/sbt-test/dependency-graph/whatDependsOn/disabled b/sbt-app/src/sbt-test/dependency-graph/whatDependsOn/test similarity index 100% rename from sbt-app/src/sbt-test/dependency-graph/whatDependsOn/disabled rename to sbt-app/src/sbt-test/dependency-graph/whatDependsOn/test diff --git a/sbt-app/src/sbt-test/dependency-management/inter-project-resolvers/a/src/main/scala/A.scala b/sbt-app/src/sbt-test/dependency-management/inter-project-resolvers/a/src/main/scala/A.scala deleted file mode 100644 index 954405774..000000000 --- a/sbt-app/src/sbt-test/dependency-management/inter-project-resolvers/a/src/main/scala/A.scala +++ /dev/null @@ -1,6 +0,0 @@ - -case class A(msg: String) - -object A { - def default = A("OK") -} diff --git a/sbt-app/src/sbt-test/dependency-management/inter-project-resolvers/b/src/main/scala/Main.scala b/sbt-app/src/sbt-test/dependency-management/inter-project-resolvers/b/src/main/scala/Main.scala deleted file mode 100644 index f2c112187..000000000 --- a/sbt-app/src/sbt-test/dependency-management/inter-project-resolvers/b/src/main/scala/Main.scala +++ /dev/null @@ -1,14 +0,0 @@ -import java.io.File -import java.nio.file.Files - -import scalaz.stream._ -import scalaz.concurrent.Task - -object Main extends App { - - val pch = Process.constant((i:Int) => Task.now(())).take(3) - val count = Process.constant(1).toSource.to(pch).runLog.run.size - assert(count == 3) - - Files.write(new File("output").toPath, A.default.msg.getBytes("UTF-8")) -} diff --git a/sbt-app/src/sbt-test/dependency-management/inter-project-resolvers/build.sbt b/sbt-app/src/sbt-test/dependency-management/inter-project-resolvers/build.sbt deleted file mode 100644 index 625c7c0d2..000000000 --- a/sbt-app/src/sbt-test/dependency-management/inter-project-resolvers/build.sbt +++ /dev/null @@ -1,17 +0,0 @@ -ThisBuild / scalaVersion := "2.11.12" - -lazy val a = project - .settings( - resolvers += "Scalaz Bintray Repo" at "https://dl.bintray.com/scalaz/releases" - ) - -lazy val b = project - .dependsOn(a) - .settings( - // resolver added in inter-project dependency only - should still be fine - libraryDependencies += "org.scalaz.stream" %% "scalaz-stream" % "0.7.1a" - ) - -lazy val root = project - .in(file(".")) - .aggregate(a, b) diff --git a/sbt-app/src/sbt-test/dependency-management/inter-project-resolvers/test b/sbt-app/src/sbt-test/dependency-management/inter-project-resolvers/test deleted file mode 100644 index ea53e1abb..000000000 --- a/sbt-app/src/sbt-test/dependency-management/inter-project-resolvers/test +++ /dev/null @@ -1,3 +0,0 @@ -$ delete output -> b/run -$ exists output diff --git a/sbt-app/src/sbt-test/dependency-management/pom-advanced/test b/sbt-app/src/sbt-test/dependency-management/pom-advanced/test index 1fb460f11..d639e4ae6 100644 --- a/sbt-app/src/sbt-test/dependency-management/pom-advanced/test +++ b/sbt-app/src/sbt-test/dependency-management/pom-advanced/test @@ -1,9 +1,9 @@ # write the default pom. The only repositories should be Scala Tools Releases and Snapshots -> checkPom https://scala-ci.typesafe.com/artifactory/scala-integration/ https://scala-ci.typesafe.com/artifactory/scala-pr-validation-snapshots/ https://oss.sonatype.org/content/repositories/releases/ https://oss.sonatype.org/content/repositories/snapshots/ +> checkPom https://scala-ci.typesafe.com/artifactory/scala-integration/ https://scala-ci.typesafe.com/artifactory/scala-pr-validation-snapshots/ https://oss.sonatype.org/service/local/repositories/releases/content/ https://oss.sonatype.org/content/repositories/snapshots/ # include file:// repositories. The generated repositories section should include the local Maven repository as well $ touch repo.all -> checkPom https://scala-ci.typesafe.com/artifactory/scala-integration/ https://scala-ci.typesafe.com/artifactory/scala-pr-validation-snapshots/ https://oss.sonatype.org/content/repositories/releases/ https://oss.sonatype.org/content/repositories/snapshots/ file://*.m2/repository/ +> checkPom https://scala-ci.typesafe.com/artifactory/scala-integration/ https://scala-ci.typesafe.com/artifactory/scala-pr-validation-snapshots/ https://oss.sonatype.org/service/local/repositories/releases/content/ https://oss.sonatype.org/content/repositories/snapshots/ file://*.m2/repository/ $ delete repo.all $ touch repo.none diff --git a/sbt-app/src/sbt-test/dependency-management/scala3-compiler-bridge-binary/build.sbt b/sbt-app/src/sbt-test/dependency-management/scala3-compiler-bridge-binary/build.sbt index 998afcca4..ef00fcef5 100644 --- a/sbt-app/src/sbt-test/dependency-management/scala3-compiler-bridge-binary/build.sbt +++ b/sbt-app/src/sbt-test/dependency-management/scala3-compiler-bridge-binary/build.sbt @@ -1,4 +1,4 @@ -ThisBuild / scalaVersion := "3.0.0-M2" +ThisBuild / scalaVersion := "3.0.0-M3" lazy val check = taskKey[Unit]("") diff --git a/sbt-app/src/sbt-test/plugins/doc-scala3-js/build.sbt b/sbt-app/src/sbt-test/plugins/doc-scala3-js/build.sbt new file mode 100644 index 000000000..af0c70797 --- /dev/null +++ b/sbt-app/src/sbt-test/plugins/doc-scala3-js/build.sbt @@ -0,0 +1,12 @@ +val scala3Version = "3.0.1-RC1-bin-20210525-8f3fdf5-NIGHTLY" + +enablePlugins(ScalaJSPlugin) + +lazy val root = project + .in(file(".")) + .settings( + name := "scala3-simple", + version := "0.1.0", + + scalaVersion := scala3Version, + ) diff --git a/sbt-app/src/sbt-test/plugins/doc-scala3-js/project/plugins.sbt b/sbt-app/src/sbt-test/plugins/doc-scala3-js/project/plugins.sbt new file mode 100644 index 000000000..c16aefc53 --- /dev/null +++ b/sbt-app/src/sbt-test/plugins/doc-scala3-js/project/plugins.sbt @@ -0,0 +1 @@ +addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.5.1") \ No newline at end of file diff --git a/sbt-app/src/sbt-test/plugins/doc-scala3-js/src/main/scala/test.scala b/sbt-app/src/sbt-test/plugins/doc-scala3-js/src/main/scala/test.scala new file mode 100644 index 000000000..dd119a269 --- /dev/null +++ b/sbt-app/src/sbt-test/plugins/doc-scala3-js/src/main/scala/test.scala @@ -0,0 +1,21 @@ +package test + +import scala.scalajs.js + +final case class RouteLocation(loc: String, state: js.UndefOr[js.Any]) + + +object RouteLocation: + def apply(loc: String): RouteLocation = RouteLocation(loc, js.undefined) + +/** + * ```scala sc:compile + * import scala.scalajs.js + * final case class RouteLocation(loc: String, state: js.UndefOr[js.Any]) + * + * + * object RouteLocation: + * def apply(loc: String): RouteLocation = RouteLocation(loc, js.undefined) + * ``` + */ +case class Test(s: String) \ No newline at end of file diff --git a/sbt-app/src/sbt-test/plugins/doc-scala3-js/test b/sbt-app/src/sbt-test/plugins/doc-scala3-js/test new file mode 100644 index 000000000..fd7163dc6 --- /dev/null +++ b/sbt-app/src/sbt-test/plugins/doc-scala3-js/test @@ -0,0 +1 @@ +> doc \ No newline at end of file diff --git a/sbt-app/src/sbt-test/project/sbt-plugin/build.sbt b/sbt-app/src/sbt-test/project/sbt-plugin/build.sbt index 072e6af4a..ae7ce14e9 100644 --- a/sbt-app/src/sbt-test/project/sbt-plugin/build.sbt +++ b/sbt-app/src/sbt-test/project/sbt-plugin/build.sbt @@ -1,6 +1,6 @@ lazy val root = project.in(file(".")) .enablePlugins(SbtPlugin) .settings( - scalaVersion := "2.12.13", + scalaVersion := "2.12.14", scalacOptions ++= Seq("-Xfatal-warnings", "-Xlint") ) diff --git a/sbt-app/src/sbt-test/project/sbt-plugin/changes/oldSbtPlugin.sbt b/sbt-app/src/sbt-test/project/sbt-plugin/changes/oldSbtPlugin.sbt new file mode 100644 index 000000000..063ee25e5 --- /dev/null +++ b/sbt-app/src/sbt-test/project/sbt-plugin/changes/oldSbtPlugin.sbt @@ -0,0 +1,6 @@ +lazy val root = project.in(file(".")) + .settings( + scalaVersion := "2.12.14", + sbtPlugin := true, + scalacOptions ++= Seq("-Xfatal-warnings", "-Xlint") + ) diff --git a/sbt-app/src/sbt-test/project/sbt-plugin/test b/sbt-app/src/sbt-test/project/sbt-plugin/test index 5df2af1f3..1e698be09 100644 --- a/sbt-app/src/sbt-test/project/sbt-plugin/test +++ b/sbt-app/src/sbt-test/project/sbt-plugin/test @@ -1 +1,3 @@ > compile +$ copy-file changes/oldSbtPlugin.sbt build.sbt +> compile diff --git a/sbt-app/src/sbt-test/project/scala3-binary-version/build.sbt b/sbt-app/src/sbt-test/project/scala3-binary-version/build.sbt new file mode 100644 index 000000000..521755296 --- /dev/null +++ b/sbt-app/src/sbt-test/project/scala3-binary-version/build.sbt @@ -0,0 +1,11 @@ +ThisBuild / scalaVersion := "3.0.0" + +lazy val check = taskKey[Unit]("check") + +lazy val root = project.in(file(".")) + .settings( + check := { + val dirs = (Compile / unmanagedSourceDirectories).value + assert(dirs == dirs.distinct) + } + ) diff --git a/sbt-app/src/sbt-test/project/scala3-binary-version/test b/sbt-app/src/sbt-test/project/scala3-binary-version/test new file mode 100644 index 000000000..15675b169 --- /dev/null +++ b/sbt-app/src/sbt-test/project/scala3-binary-version/test @@ -0,0 +1 @@ +> check diff --git a/sbt-app/src/sbt-test/project/scala3-sandwich-sjs/build.sbt b/sbt-app/src/sbt-test/project/scala3-sandwich-sjs/build.sbt index 01e81e167..661ac82a1 100644 --- a/sbt-app/src/sbt-test/project/scala3-sandwich-sjs/build.sbt +++ b/sbt-app/src/sbt-test/project/scala3-sandwich-sjs/build.sbt @@ -1,15 +1,15 @@ -ThisBuild / scalaVersion := "2.13.4" +ThisBuild / scalaVersion := "2.13.6" ThisBuild / scalacOptions += "-Ytasty-reader" lazy val scala3code = project .enablePlugins(ScalaJSPlugin) - .settings(scalaVersion := "3.0.0-M1") + .settings(scalaVersion := "3.0.0") lazy val app = project .enablePlugins(ScalaJSPlugin) .dependsOn(scala3code) .settings( - scalaVersion := "2.13.4", + scalaVersion := "2.13.6", scalacOptions += "-Ytasty-reader", scalaJSUseMainModuleInitializer := true ) diff --git a/sbt-app/src/sbt-test/project/scala3-sandwich-sjs/project/plugins.sbt b/sbt-app/src/sbt-test/project/scala3-sandwich-sjs/project/plugins.sbt index 8f1d0ac9b..56abd248d 100644 --- a/sbt-app/src/sbt-test/project/scala3-sandwich-sjs/project/plugins.sbt +++ b/sbt-app/src/sbt-test/project/scala3-sandwich-sjs/project/plugins.sbt @@ -1 +1 @@ -addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.3.1") +addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.6.0") diff --git a/sbt-app/src/sbt-test/project/scala3-sandwich/build.sbt b/sbt-app/src/sbt-test/project/scala3-sandwich/build.sbt index 69a2ca58f..75988d69d 100644 --- a/sbt-app/src/sbt-test/project/scala3-sandwich/build.sbt +++ b/sbt-app/src/sbt-test/project/scala3-sandwich/build.sbt @@ -1,6 +1,6 @@ -ThisBuild / scalaVersion := "3.0.0-M1" +ThisBuild / scalaVersion := "3.0.0" -lazy val scala213 = "2.13.4" +lazy val scala213 = "2.13.6" lazy val root = (project in file(".")) .aggregate(fooApp, fooCore, barApp, barCore) diff --git a/sbt-app/src/sbt-test/project/semanticdb-version/build.sbt b/sbt-app/src/sbt-test/project/semanticdb-version/build.sbt index 8b5c69c23..0600aa8dd 100644 --- a/sbt-app/src/sbt-test/project/semanticdb-version/build.sbt +++ b/sbt-app/src/sbt-test/project/semanticdb-version/build.sbt @@ -1,6 +1,6 @@ -ThisBuild / scalaVersion := "2.12.13" +ThisBuild / scalaVersion := "2.12.14" ThisBuild / semanticdbEnabled := true -ThisBuild / semanticdbVersion := "4.4.10" +ThisBuild / semanticdbVersion := "4.4.20" ThisBuild / semanticdbIncludeInJar := false lazy val root = (project in file(".")) @@ -8,7 +8,7 @@ lazy val root = (project in file(".")) lazy val check = taskKey[Unit]("Checks the configured semanticdbVersion") check := { - val expected = Some("4.4.10") + val expected = Some("4.4.20") val actual = allDependencies .value .find(_.name == "semanticdb-scalac") diff --git a/sbt-app/src/sbt-test/tests/scala-instance-classloader/build.sbt b/sbt-app/src/sbt-test/tests/scala-instance-classloader/build.sbt index 3e73d9178..3ed61dad2 100644 --- a/sbt-app/src/sbt-test/tests/scala-instance-classloader/build.sbt +++ b/sbt-app/src/sbt-test/tests/scala-instance-classloader/build.sbt @@ -3,7 +3,7 @@ import sbt.internal.inc.ScalaInstance lazy val OtherScala = config("other-scala").hide lazy val junitinterface = "com.novocode" % "junit-interface" % "0.11" lazy val akkaActor = "com.typesafe.akka" %% "akka-actor" % "2.5.17" -ThisBuild / scalaVersion := "2.12.13" +ThisBuild / scalaVersion := "2.12.14" lazy val root = (project in file(".")) .configs(OtherScala) diff --git a/server-test/src/server-test/response/build.sbt b/server-test/src/server-test/response/build.sbt index f75670640..105e64e77 100644 --- a/server-test/src/server-test/response/build.sbt +++ b/server-test/src/server-test/response/build.sbt @@ -1,6 +1,6 @@ import sbt.internal.server.{ ServerHandler, ServerIntent } -ThisBuild / scalaVersion := "2.12.13" +ThisBuild / scalaVersion := "2.12.14" Global / serverLog / logLevel := Level.Debug // custom handler