Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP use sbt 2.0.0-M4 & cross-build against it #440

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

bjaglin
Copy link
Collaborator

@bjaglin bjaglin commented Oct 5, 2024

https://www.scala-sbt.org/2.x/docs/en/changes/migrating-from-sbt-1.x.html
https://github.com/sbt/sbt/wiki/sbt-2.x-plugin-migration

Remaining

  • scripted sbt2
    [error]         sbt-scalafix/relax-scalacOptions
    [error]         sbt-scalafix/scalafixOnCompile
    [error]         skip-java17+/scalafixResolvers
    [error]         skip-sbt1.4/cross-build-scala3
    [error]         skip-sbt1.4/testkit
    

@bjaglin bjaglin force-pushed the sbt2 branch 3 times, most recently from c9451e2 to 42e7e69 Compare October 5, 2024 22:05
@bjaglin bjaglin changed the title sbt 2.x cross-build to sbt 2.x Oct 5, 2024
@@ -155,21 +155,21 @@ object ScalafixEnable {
} else {
val latestAvailable =
tail.lastOption.getOrElse(earliestAvailable)
Seq(
Copy link
Collaborator Author

@bjaglin bjaglin Oct 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was picked as significant indentation by the compiler (and has been also all along by scalafmt, as scala3 is aggressively/incorrectly used on all files as dialect), which was causing latestAvailable's type to be recursive ...

@bjaglin bjaglin force-pushed the sbt2 branch 2 times, most recently from 0bc3b43 to 50acf94 Compare October 5, 2024 22:19
@bjaglin bjaglin changed the title cross-build to sbt 2.x WIP cross-build to sbt 2.x Feb 16, 2025
@bjaglin bjaglin force-pushed the sbt2 branch 2 times, most recently from ea0dc68 to 077670f Compare March 9, 2025 17:12
Comment on lines +10 to +31
.get(Keys.moduleIDStr)
.map(Classpaths.moduleIdJsonKeyFormat.read)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bjaglin bjaglin force-pushed the sbt2 branch 4 times, most recently from ffeacb0 to 1b3e208 Compare March 9, 2025 18:07
@bjaglin bjaglin changed the title WIP cross-build to sbt 2.x WIP cross-build against sbt 2.0.0-M4 Mar 9, 2025
@bjaglin bjaglin force-pushed the sbt2 branch 3 times, most recently from 4060b04 to 55d9026 Compare March 9, 2025 19:22
@bjaglin bjaglin closed this Mar 9, 2025
@bjaglin bjaglin reopened this Mar 9, 2025
@bjaglin bjaglin force-pushed the sbt2 branch 3 times, most recently from 0ffcf86 to ab7704f Compare March 9, 2025 19:45
Comment on lines +16 to +24
def toPath(
attributed: Attributed[HashedVirtualFileRef]
)(using conv: FileConverter): Path =
conv.toPath(attributed.data)

def toFile(
attributed: Attributed[HashedVirtualFileRef]
)(using conv: FileConverter): File =
toPath(attributed).toFile()
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"sbt."
"*"
]
targetDialect = Scala3
Copy link
Collaborator Author

@bjaglin bjaglin Mar 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks to -Xsource:3 (which was added by default for sbt1 but was removed in sbt2, needing an explicit addition in this PR), Scala 3 import syntax can be used sbt1 metabuilds (and thus sb1 plugins) .

So we might as well start using OrganizeImports with Scala 3 syntax for all files (not just the Scala 3 ones), as we start enforcing scalafix for ExplicitResultTypes

@@ -7,6 +7,7 @@ object Dependencies {
val all = List(
"org.eclipse.jgit" % "org.eclipse.jgit" % "5.13.3.202401111512-r",
"ch.epfl.scala" % "scalafix-interfaces" % scalafixVersion,
"io.get-coursier" % "interface" % "1.0.28"
"io.get-coursier" % "interface" % "1.0.28",
"org.scala-lang.modules" %% "scala-collection-compat" % "2.13.0"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

helps getting rid of import scala.collection.JavaConverters.* mostly

@bjaglin bjaglin force-pushed the sbt2 branch 2 times, most recently from 9ea8c73 to 31bc4fc Compare March 10, 2025 01:30
- run: ./bin/scalafmt --test
- run: sbt "scalafixAll --check"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enforcing scalafix in this PR mostly for ExplicitResultTypes, to have deterministic types from the beginning for the sbt 2.x artifact

@bjaglin bjaglin force-pushed the sbt2 branch 5 times, most recently from cdf1d14 to 539b3f4 Compare March 12, 2025 08:15
@bjaglin bjaglin closed this Mar 12, 2025
@bjaglin bjaglin reopened this Mar 12, 2025
@bjaglin bjaglin force-pushed the sbt2 branch 3 times, most recently from cf75fe4 to 42dcb6e Compare March 12, 2025 20:47
@@ -1 +1 @@
sbt.version=1.10.7
sbt.version=2.0.0-M4
Copy link
Collaborator Author

@bjaglin bjaglin Mar 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ this currently breaks metals integration (even with BSP handled by sbt itself rather than metals) pending sbt-metals cross-publishing to 2.0.0-M4

strategy:
fail-fast: false
matrix:
scala: ["2.12"]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ sbt2 does not seem to start on CI windows

Run sbt ++2.12 test-skip-windows scripted
[info] entering *experimental* thin client - BEEP WHIRR
[info] server was not detected. starting an instance
[error] Failed to start server : java.io.IOException: Cannot run program "C:/Program Files" (in directory "D:\a\sbt-scalafix\sbt-scalafix"): CreateProcess error=5, Access is denied
[error] failed to connect to server

@@ -1,12 +1,12 @@
resolvers ++= Resolver.sonatypeOssRepos("public")
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.9.2")
//addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.9.2")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ pending cross-publishing to 2.0.0-M4

@bjaglin bjaglin changed the title WIP cross-build against sbt 2.0.0-M4 WIP use sbt 2.0.0-M4 & cross-build against it Mar 13, 2025
@@ -38,7 +36,7 @@ checkLogs := {
.map(_.replaceAll("\u001B\\[[;\\d]*m", "")) // remove control chars (colors)
.force
assert(
logLines.exists(_ == "[error] -import scala.concurrent.Future"),
logLines.exists(_.startsWith("[error] -import scala.concurrent.Future")),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for some weird reason, the lines have non-visible trailing characters when the scripted is run from sbt2 in JDK<21

@bjaglin bjaglin force-pushed the sbt2 branch 2 times, most recently from ac9bc6a to e5e2f7d Compare March 13, 2025 21:55
@bjaglin bjaglin force-pushed the sbt2 branch 2 times, most recently from 17b11e4 to 6e22571 Compare March 13, 2025 23:18
@@ -72,12 +38,14 @@ jobs:
apps: sbt
- run: rm -r -fo src\sbt-test\skip-sbt1.4
- run: rm -r -fo src\sbt-test\skip-windows
- run: sbt test-skip-windows scripted
shell: bash
Copy link
Collaborator Author

@bjaglin bjaglin Mar 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The presence of this was triggering sbtn usage, which does not seem to work on any github action

before

Run sbt -v '++2.12.x test-skip-windows scripted'
  sbt -v '++2.12.x test-skip-windows scripted'
  shell: C:\Program Files\Git\bin\bash.EXE --noprofile --norc -e -o pipefail {0}
  env:
    COURSIER_BIN_DIR: C:\Users\runneradmin\cs\bin
[sbt_options] declare -a sbt_options=()
[debug] running native client
# Executing command line:
"/c/Program Files (x86)/sbt/bin/sbtn-x86_64-pc-win32.exe"
"--sbt-script=/c/Program%20Files (x86)/sbt/bin/sbt"
-v
"++2.12.x test-skip-windows scripted"

[info] entering *experimental* thin client - BEEP WHIRR
[info] server was not detected. starting an instance
[error] Failed to start server : java.io.IOException: Cannot run program "C:/Program Files" (in directory "D:\a\sbt-scalafix\sbt-scalafix"): CreateProcess error=5, Access is denied
[error] failed to connect to server

after


Started at 1741908079000
Run sbt ++2.12.x test-skip-windows scripted
  sbt ++2.12.x test-skip-windows scripted
  shell: C:\Program Files\PowerShell\7\pwsh.EXE -command ". '{0}'"
  env:
    COURSIER_BIN_DIR: C:\Users\runneradmin\cs\bin
[info] [launcher] getting org.scala-sbt sbt 2.0.0-M4  (this may take some time)...
[info] [launcher] getting Scala 3.6.4 (for sbt)...
[info] welcome to sbt 2.0.0-M4 (Temurin Java 1.8.0_442)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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