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

  • sbtn on windows CI
  • scripted sbt1
    [error] 	sbt-scalafix/basic
    
  • 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

@@ -376,19 +383,19 @@ object ScalafixPlugin extends AutoPlugin {

}

private def scalafixAllInputTask(): Def.Initialize[InputTask[Unit]] = {
// workaround https://github.com/sbt/sbt/issues/3572 by invoking directly what Def.inputTaskDyn would via macro
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 3 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 2 times, most recently from ea8ff83 to cf75fe4 Compare March 12, 2025 20:36
@@ -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
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