Skip to content

Migrate to sbt2 - #7

Merged
windymelt merged 11 commits into
mainfrom
migrate-to-sbt2
Aug 10, 2026
Merged

windymelt merged 11 commits into
mainfrom
migrate-to-sbt2

Conversation

@windymelt

Copy link
Copy Markdown
Owner

No description provided.

Relocate comport.scala to src/main/scala/dev/capslock/comport/Main.scala,
strip scala-cli directives, and add the package declaration. Anchor the
`comport`/`Comport` .gitignore patterns to the repo root so they do not
match the new source directory.
Introduce build.sbt, project/build.properties, and project/plugins.sbt to
build comport with sbt 2.0.2 and sbt-scala-native 0.5.12 on Scala 3.8.2.
The native config keeps the previous release-fast / full LTO / commix GC
settings and appends whitespace-separated flags from the LINKFLAGS
environment variable so the static-link path from the Alpine container
build still works.
Replace the scala-cli invocation with `sbt nativeLink`; native config now
lives in build.sbt, so build.sh just exports LINKFLAGS and copies the
produced binary at target/scala-3.8.2/comport-out to ./comport for
compatibility with existing callers (README, CI upload paths).
Swap `coursier launch scala-cli` for `coursier install sbt` in the
Dockerfile so the container ships a sbt wrapper on PATH, and drop the
SCALA_CLI_LAUNCH override from build-with-container.sh (build.sh now
defaults to `sbt`). JDK 17 headless is already installed, which meets
sbt 2's runtime requirement.
- Compile and macOS jobs: install Temurin 17 and sbt via
  actions/setup-java + sbt/setup-sbt, then run `sbt compile` / `./build.sh`.
- Release Linux job: reuse `./build-with-container.sh` (Alpine + sbt image)
  instead of an inline `docker run` that installed scala-cli each time,
  matching the CI Linux path and removing the previous inline LTO=thin
  divergence (release now uses full LTO like build.sbt specifies).
sbt-scala-native 0.5.12 on sbt 2 puts the produced binary at
`target/out/native0.5/scala-<binVer>/<name>/<name>`, not the sbt 1
`target/scala-<binVer>/<name>-out` layout that build.sh initially copied
from. Verified locally that `./build.sh` now produces a working `./comport`.
Replace scala-cli instructions with `sbt run` for iteration and
`./build.sh` for producing the native binary, matching the new build.
Add `target/`, `project/target/`, and `project/project/` to .gitignore so
sbt's build outputs stop showing up in `git status`.
Repository policy requires all actions be pinned to a full-length commit
SHA rather than a tag reference. Resolve each `@vN` tag through the
GitHub API and pin the workflows accordingly. Tag comments are preserved
alongside so the intended version stays visible.
sbt 2's default launcher runs the sbtn thin client, whose distributed
binary is glibc-linked and does not execute on Alpine (musl); the
extraction path also picks unzip on non-linux-gnu OSTYPE, which is not
installed in the builder image. Pass `--server` in build.sh so the
launcher sets use_sbtn=0 and skips sbtn entirely, matching sbt 1
behavior. SBT_NATIVE_CLIENT is not usable here because the launcher only
consults it in the enabling direction.
sbt 2 injects bare top-level settings into all subprojects (including
the implicit root), which replaces the role ThisBuild used to play, and
bare `enablePlugins(...)` applies to the implicit root project as well
(pattern used by e.g. `sbt-app/src/sbt-test/nio/code-formatter/build.sbt`
in the sbt 2.0.2 source tree). Drop the explicit
`lazy val comport = project.in(file("."))` scaffolding and ThisBuild
scoping accordingly. Verified locally with `sbt --server nativeLink` and
`./build.sh`.
@windymelt
windymelt merged commit 505c42f into main Aug 10, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant