Cross build laika-sbt for sbt 2 - #774
Conversation
| logLevel = MessageFilter.Warning | ||
| ) | ||
|
|
||
| private def unapply(conf: LaikaConfig) = conf |
There was a problem hiding this comment.
unused, removed for suppress warning in Scala3.
| Laika / clean := Tasks.clean.value, | ||
| laikaSite / mappings := Def.sequential(Tasks.site, Tasks.mappings).value | ||
| ) :+ (cleanFiles += (Laika / target).value) | ||
| @nowarn("msg=unused import") |
There was a problem hiding this comment.
For sbtcompat.PluginCompat.* in Scala3.
reardonj
left a comment
There was a problem hiding this comment.
This looks pretty reasonable. I'm not familiar with the CI setup stuff enough to comment on it.
|
|
||
| enablePlugins(LaikaPlugin) | ||
|
|
||
| Laika / target := baseDirectory.value / "target" / "docs" |
There was a problem hiding this comment.
Did this have to be added due to sbt2 changes the target directory setup?
There was a problem hiding this comment.
Yes, by default, it's target/out/jvm/scala-xxx/<moduleName> for sbt 2.x, while sbt 1.x is target/.... If we didn't add this configuration, test script's $ must-mirror target/docs/site/hello.html doesn't work across sbt 1.x and 2.x.
Alternatively, we can define a custom sbt task that checks the content of generated files, but I think configuring Laika / target would be the easiest fix (smallest diff).
There was a problem hiding this comment.
I think it's fine as is. Just was confirming my understanding.
| else Some(8) | ||
| }, | ||
| // Scaladoc 3 cannot currently resolve some TASTy from sbt 2 transitive dependencies. | ||
| // https://github.com/scala/scala3/issues/18487 |
There was a problem hiding this comment.
I see you fixed this bug. I guess we are stuck until at least 3.9 to make use of it though?
There was a problem hiding this comment.
When I was investigating the bug, I realized that it matters only when the plugin has a dependency to any symbols that is annotated with @datatype.data (such as https://github.com/sbt/sbt/blob/d4e8fb583c1a61733500112a2ec6dd8af2a4de4c/lm-coursier/definitions/src/main/scala/lmcoursier/CoursierConfiguration.scala#L23).
So there's no problem for laika, I'll remove this workaround 🙇
done 5c9a317
| // TODO: Re-enable MiMa for sbt 2 once a previous sbt 2 plugin artifact exists. | ||
| // The sbt 2 / Scala 3 plugin artifact did not exist in previous Laika releases, | ||
| // so MiMa cannot compare against a missing baseline. | ||
| mimaPreviousArtifacts := { |
There was a problem hiding this comment.
I don't suppose there is a nicer way to do this @armanbilge ?
There was a problem hiding this comment.
Oh, I learnt that there's tlVersionIntroduced in sbt-typelevel:
Maybe we wanna set tlVersionIntroduced := Map("3" -> "1.3.3") (where 1.3.3 is the next release version, maybe 1.4.0 ?)
Then we don't need to manually remove this mimaPreviousArtifacts when we have scala3 release.
There was a problem hiding this comment.
Set tlVersionIntroduced := Map("3" -> "1.3.3"). I'm not sure the next version is either 1.3.3 or 1.4.0 though :)
e4dae94
There was a problem hiding this comment.
I believe a new target would get a minor release, so it should be 1.4.0
| Seq( | ||
| Laika / sourceDirectories := Seq(sourceDirectory.value / "docs"), | ||
| Laika / excludeFilter := HiddenFileFilter, | ||
| laikaInputs := Def.uncached(Settings.defaultInputs.value), |
There was a problem hiding this comment.
Do these need to be uncached or is this just for ease of migration?
There was a problem hiding this comment.
Oops, nice catch, they're settingKey (not taskKey) and we didn't need Def.uncached. (5c9a317)
fix typelevel#773 - Exclude all laika-sbt tasks from sbt 2 caching with `Def.uncached`. - Adapt to sbt2 API changes using https://github.com/sbt/sbt2-compat if you don't like adding dependency, we can define small set of PluginCompat. - Run the plugin build and tests in CI with sbt 2, Scala 3, and Java 17. - Set `Laika / target` explicitly in each scripted project `build.sbt` so scripted tests work across sbt 1 and 2 target directory. Depends on upstream sbt change sbt/sbt#9377
e4dae94 to
6fb313f
Compare
|
FYI, force pushing makes it basically impossible to review what actually changed since you destroy the history when do this. I’d have to review this whole PR from scratch now because all the commits changed so I can’t assume there are no other changes. |
|
Ah, sorry I should've used fixup commits |
| val mappings: Initialize[Task[Seq[(File, String)]]] = task { | ||
| sbt.Path.allSubpaths((laikaSite / target).value).toSeq | ||
| val mappings: Initialize[Task[Seq[(FileRef, String)]]] = task { | ||
| implicit val fileConverter: FileConverter = (ThisBuild / sbt.Keys.fileConverter).value |
| streams.value.log.info(s"Packaging $zipFile ...") | ||
|
|
||
| sbt.IO.zip((laikaSite / sbt.Keys.mappings).value, zipFile, None) | ||
| implicit val fileConverter: FileConverter = (ThisBuild / sbt.Keys.fileConverter).value |
|
|
||
| enablePlugins(LaikaPlugin) | ||
|
|
||
| Laika / target := baseDirectory.value / "target" / "docs" |
There was a problem hiding this comment.
Is this something that will change in the downstream user configuration? Will we need to document these changes somewhere?
There was a problem hiding this comment.
If I understand correctly, this is just a test file that is being forced to use an sbt 1.x output path for testing convenience. Actual users of Laika in sbt 2 would see their output follow standard sbt 2 behaviour. If the user upgrades and has other script assume the output path, they would see issues, so it would be good to note the behaviour as part of the cross-build release.
Depends on upstream sbt change sbt/sbt#9377,
we need to wait until sbt 2.0.12.0.1 is released with that fix.close #773
Def.uncached.Laika / targetexplicitly in each scripted projectbuild.sbtso scripted tests work across sbt 1 and 2 target directory.Depends on upstream sbt change sbt/sbt#9377