Skip to content

Commit 7d2b56c

Browse files
Atryclaude
andcommitted
Fix scripted test fixtures for sbt 2.x
CI on sbt 2.0.0 surfaced two sbt-1-isms in the test fixtures (keep-api-url already passed; only all-libraries and jdk failed): - all-libraries/test used the sbt 0.13 colon command syntax `+compile:doc::apiMappings`, which sbt 2.x rejects ("Expected ';'"). Switch to slash syntax `+Compile / doc / apiMappings`. - jdk/build.sbt read `sLog.value` in its check/fgrep/jgrep tasks. On sbt 2.x a Logger has no `HashWriter`, so reading it as a task input breaks the default task caching ("given evidence sjsonnew.HashWriter[...Logger...] is not found"). Use `println` for the diagnostic output instead — no task input needed. (The `Map[HashedVirtualFileRef, URI]` from apiMappings does have a HashWriter, as the passing keep-api-url test shows, so only the Logger was the problem.) Both changes are also valid on sbt 1.x. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 1e3264d commit 7d2b56c

2 files changed

Lines changed: 9 additions & 13 deletions

File tree

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
> +compile:doc::apiMappings
2-
> +test:doc::apiMappings
1+
> +Compile / doc / apiMappings
2+
> +Test / doc / apiMappings
33

44
> check
55
> +check

src/sbt-test/sbt-api-mappings/jdk/build.sbt

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ def isJava(x: Integer) = javaVersion match {
1717

1818
check := {
1919

20-
val log = sLog.value
21-
20+
// Avoid `sLog.value`: on sbt 2.x a Logger has no HashWriter, so reading it as a
21+
// task input breaks the default task caching. `println` needs no task input.
2222
val compileApiMappings = (Compile / doc / apiMappings).value
2323

2424
val expect = "https://docs.oracle.com/(?:en/java/)?javase/\\d+/docs/api/".r
@@ -28,14 +28,14 @@ check := {
2828
}
2929

3030
if (found) {
31-
log.info("Found javadoc url in apiMappings")
31+
println("Found javadoc url in apiMappings")
3232

3333
} else {
34-
log.info("Entries in apiMappings:")
34+
println("Entries in apiMappings:")
3535
compileApiMappings.values
3636
.map("+ " + _.toString)
3737
.foreach(
38-
log.info(_)
38+
println(_)
3939
)
4040
sys.error(s"Failed to match ${expect}")
4141
}
@@ -46,12 +46,10 @@ val fgrep = InputKey[Unit]("fgrep")
4646
fgrep := {
4747
val args: Seq[String] = Def.spaceDelimited().parsed
4848

49-
val log = sLog.value
50-
5149
val found = IO.readLines(file(args(1))).exists(_.contains(args(0)))
5250

5351
if (found) {
54-
log.info(s"Found '${args(0)}' in '${args(1)}'")
52+
println(s"Found '${args(0)}' in '${args(1)}'")
5553

5654
} else {
5755
sys.error(s"Failed to fgrep '${args(0)}' '${args(1)}'")
@@ -63,12 +61,10 @@ val jgrep = InputKey[Unit]("jgrep")
6361
jgrep := {
6462
val args: Seq[String] = Def.spaceDelimited().parsed
6563

66-
val log = sLog.value
67-
6864
val found = IO.readLines(file(args(1))).exists(regexMatches(args(0).r)(_))
6965

7066
if (found) {
71-
log.info(s"Found '${args(0)}' in '${args(1)}'")
67+
println(s"Found '${args(0)}' in '${args(1)}'")
7268

7369
} else {
7470
sys.error(s"Failed to jgrep '${args(0)}' '${args(1)}'")

0 commit comments

Comments
 (0)