Skip to content

Commit b47a7c5

Browse files
committed
sbt 2.0.5
Build definitions are now compiled with Scala 3, and the launcher shipped in the repo cannot boot sbt 2, so it is replaced with the 2.0.5 launcher. Notable changes beyond the version bump: - `test` now means what `testQuick` used to mean and its results are cached across `clean`, so a warm cache runs no tests at all. CI and the Makefile use `testFull` to always run the full suite. - Task results must be serializable, so `externalResolvers` is wrapped in `Def.uncached`. - The one-jar target read the runtime classpath with `export`, which now renders entries as virtual file refs rather than paths on disk. A `printRuntimeClasspath` task converts them back and the Makefile uses that. - `Test / testForkedParallel` defaults to true in sbt 2, which would run the test classes for a project concurrently. It only applies to forked tests, which this build does not use, but it is pinned to false so the tests stay serial if forking is ever enabled. - Scala 3 fixes in the build: `PathFinder.get()` and an explicit import for the String/URI to License conversion. - The per-project scopes sbt-git sets up for `gitDescribedVersion` and `gitUncommittedChanges` are unused here and are now excluded from lintUnused.
1 parent 8aaa667 commit b47a7c5

12 files changed

Lines changed: 36 additions & 14 deletions

.github/workflows/pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
distribution: 'zulu'
1919
cache: 'sbt'
2020
- name: Build
21-
run: cat /dev/null | project/sbt ++${{ matrix.scala }} clean test doc
21+
run: cat /dev/null | project/sbt ++${{ matrix.scala }} clean testFull doc
2222
check:
2323
runs-on: ubuntu-latest
2424
steps:

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
PGP_PASSPHRASE: ${{ secrets.ORG_SIGNING_PASSWORD }}
3535
run: |
3636
git fetch --unshallow --tags
37-
cat /dev/null | project/sbt ++2.13.18 clean test +publishSigned
37+
cat /dev/null | project/sbt ++2.13.18 clean testFull +publishSigned
3838
cat /dev/null | project/sbt sonaRelease
3939
4040
release-asset:

.github/workflows/snapshot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ jobs:
3232
PGP_PASSPHRASE: ${{ secrets.ORG_SIGNING_PASSWORD }}
3333
run: |
3434
git fetch --unshallow --tags
35-
cat /dev/null | project/sbt ++2.13.18 clean test +publishSigned
35+
cat /dev/null | project/sbt ++2.13.18 clean testFull +publishSigned

Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ LAUNCHER_JAR_URL := https://repo1.maven.org/maven2/com/netflix/iep/iep-launcher/
1515
.PHONY: build snapshot release clean format update-wiki publish-wiki
1616

1717
build:
18-
$(SBT) clean test checkLicenseHeaders scalafmtCheckAll
18+
$(SBT) clean testFull checkLicenseHeaders scalafmtCheckAll
1919

2020
snapshot:
2121
# Travis uses a depth when fetching git data so the tags needed for versioning may not
2222
# be available unless we explicitly fetch them
2323
git fetch --unshallow --tags
2424
$(SBT) storeBintrayCredentials
25-
$(SBT) clean test checkLicenseHeaders publish
25+
$(SBT) clean testFull checkLicenseHeaders publish
2626

2727
release:
2828
# Travis uses a depth when fetching git data so the tags needed for versioning may not
@@ -35,7 +35,7 @@ release:
3535
# The storeBintrayCredentials still needs to be on the subsequent command or we get:
3636
# [error] (iep-service/*:bintrayEnsureCredentials) java.util.NoSuchElementException: None.get
3737
$(SBT) storeBintrayCredentials
38-
$(SBT) clean test checkLicenseHeaders storeBintrayCredentials publish bintrayRelease
38+
$(SBT) clean testFull checkLicenseHeaders storeBintrayCredentials publish bintrayRelease
3939

4040
clean:
4141
$(SBT) clean
@@ -62,7 +62,7 @@ publish-wiki: update-wiki
6262
one-jar:
6363
mkdir -p target
6464
curl -fL $(LAUNCHER_JAR_URL) -o target/iep-launcher.jar
65-
classpath=`$(SBT) --error "export atlas-standalone/runtime:fullClasspath" | tr -d '\r' | tr ':' '\n' | grep '\.jar$$'`; \
66-
test -n "$$classpath" || { echo "error: no jars in classpath from sbt export" >&2; exit 1; }; \
65+
classpath=`$(SBT) --error "atlas-standalone/printRuntimeClasspath" | tr -d '\r' | grep '\.jar$$'`; \
66+
test -n "$$classpath" || { echo "error: no jars in classpath from sbt" >&2; exit 1; }; \
6767
java -classpath target/iep-launcher.jar com.netflix.iep.launcher.JarBuilder \
6868
target/standalone.jar com.netflix.atlas.standalone.Main $$classpath

project/BuildSettings.scala

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ object BuildSettings {
1515
lazy val checkLicenseHeaders = taskKey[Unit]("Check the license headers for all source files.")
1616
lazy val formatLicenseHeaders = taskKey[Unit]("Fix the license headers for all source files.")
1717

18+
lazy val printRuntimeClasspath =
19+
taskKey[Unit]("Print the runtime classpath, one absolute path per line.")
20+
1821
lazy val baseSettings: Seq[Def.Setting[?]] = GitVersion.settings
1922

2023
lazy val buildSettings: Seq[Def.Setting[?]] = baseSettings ++ Seq(
@@ -31,19 +34,32 @@ object BuildSettings {
3134
crossScalaVersions := Dependencies.Versions.crossScala,
3235
sourcesInBase := false,
3336
exportJars := true, // Needed for one-jar, with multi-project
34-
externalResolvers := BuildSettings.resolvers,
37+
externalResolvers := Def.uncached(BuildSettings.resolvers),
3538
// Evictions: https://github.com/sbt/sbt/issues/1636
3639
// Linting: https://github.com/sbt/sbt/pull/5153
3740
(update / evictionWarningOptions).withRank(KeyRanks.Invisible) := EvictionWarningOptions.empty,
3841
checkLicenseHeaders := LicenseCheck.checkLicenseHeaders(streams.value.log, sourceDirectory.value),
3942
formatLicenseHeaders := LicenseCheck.formatLicenseHeaders(streams.value.log, sourceDirectory.value),
43+
// Used by the one-jar target in the Makefile. The classpath cannot be read with
44+
// `export`, which renders the entries as virtual file refs under sbt 2, so convert
45+
// them back to paths on disk here.
46+
printRuntimeClasspath := Def.uncached {
47+
val converter = fileConverter.value
48+
(Runtime / fullClasspath).value.foreach { entry =>
49+
println(converter.toPath(entry.data).toAbsolutePath.toString)
50+
}
51+
},
4052
packageBin / packageOptions += Package.ManifestAttributes(
4153
"Build-Date" -> java.time.Instant.now().toString,
4254
"Build-Number" -> sys.env.getOrElse("GITHUB_RUN_ID", "unknown"),
4355
"Commit" -> sys.env.getOrElse("GITHUB_SHA", "unknown")
4456
),
4557
testFrameworks += new TestFramework("munit.Framework"),
46-
Test / parallelExecution := false
58+
Test / parallelExecution := false,
59+
60+
// Only takes effect if the tests are forked, which they are not today. sbt 2 flipped
61+
// the default to true, so pin it to keep tests serial if forking is ever enabled.
62+
Test / testForkedParallel := false
4763
)
4864

4965
val commonDeps: Seq[ModuleID] = Seq(

project/GitVersion.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ object GitVersion {
6565
case v => v
6666
}
6767
},
68-
ThisBuild / versionScheme := Some("semver-spec")
68+
ThisBuild / versionScheme := Some("semver-spec"),
69+
70+
// Only used at the build level to compute the version, the per-project scopes
71+
// set up by sbt-git are unused and would otherwise be flagged by lintUnused.
72+
Global / excludeLintKeys += git.gitDescribedVersion,
73+
Global / excludeLintKeys += git.gitUncommittedChanges
6974
)
7075
}

project/LicenseCheck.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ object LicenseCheck {
3939
""".stripMargin.trim
4040

4141
def findFiles(dir: File): Seq[File] = {
42-
(dir ** "*.scala").get ++ (dir ** "*.java").get
42+
(dir ** "*.scala").get() ++ (dir ** "*.java").get()
4343
}
4444

4545
def checkLicenseHeaders(log: Logger, srcDir: File): Unit = {

project/SonatypeSettings.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import sbt.*
22
import sbt.Keys.*
3+
import sbt.librarymanagement.syntax.given
34

45
object SonatypeSettings {
56

project/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=1.12.9
1+
sbt.version=2.0.5

project/sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ java \
2020
-Dsbt.ivy.home=${WORKSPACE:-$HOME}/.ivy2 \
2121
-Dsbt.gigahorse=false \
2222
$OPTIONS \
23-
-jar `dirname $0`/sbt-launch-1.2.8.jar "$@"
23+
-jar `dirname $0`/sbt-launch-2.0.5.jar "$@"

0 commit comments

Comments
 (0)