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

Add sbt 2 crossbuilds #256

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ jobs:
uses: playframework/.github/.github/workflows/cmd.yml@v3
with:
java: 17, 11, 8
scala: 2.12.20
scala: 2.12.20, 3.3.4
cmd: |
sbt ++$MATRIX_SCALA test ^scripted
sbt ++$MATRIX_SCALA test scripted

finish:
name: Finish
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ jobs:
persist-credentials: false

- name: Check project is formatted
uses: jrouly/scalafmt-native-action@v3
uses: jrouly/scalafmt-native-action@v4
with:
arguments: '--list --mode diff-ref=origin/main'
5 changes: 5 additions & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,8 @@ align.tokens."+" = [
]
}
]
fileOverride {
"glob:**/scala-3/**" {
runner.dialect = scala3
}
}
18 changes: 18 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ developers += Developer(
url("https://github.com/playframework")
)

lazy val scala212 = "2.12.20"
lazy val scala3 = "3.3.4"
ThisBuild / crossScalaVersions := Seq(scala212, scala3)

libraryDependencies ++= Seq(
"org.webjars" % "webjars-locator-core" % "0.59",
"org.specs2" %% "specs2-core" % "4.20.8" % "test",
Expand All @@ -26,3 +30,17 @@ Global / onLoad := (Global / onLoad).value.andThen { s =>
dynverAssertTagVersion.value
s
}

(pluginCrossBuild / sbtVersion) := {
scalaBinaryVersion.value match {
case "2.12" => "1.10.2"
case _ => "2.0.0-M2"
}
}

scalacOptions := {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, major)) => Seq("-Xsource:3")
case _ => Seq.empty
}
}
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.10.1
sbt.version=1.10.2
2 changes: 1 addition & 1 deletion sbt-web-tester/project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.10.1
sbt.version=1.10.2
31 changes: 31 additions & 0 deletions src/main/scala-2.12/com/typesafe/sbt/PluginCompat.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.typesafe.sbt

import sbt.*
import sbt.Keys.Classpath
import xsbti.FileConverter

import java.nio.file.{ Path => NioPath }

private[sbt] object PluginCompat {
type FileRef = java.io.File
type Out = java.io.File

def toNioPath(a: Attributed[File])(implicit conv: FileConverter): NioPath =
a.data.toPath
def toFile(a: Attributed[File])(implicit conv: FileConverter): File =
a.data
def toNioPaths(cp: Seq[Attributed[File]])(implicit conv: FileConverter): Vector[NioPath] =
cp.map(_.data.toPath()).toVector
def toFiles(cp: Seq[Attributed[File]])(implicit conv: FileConverter): Vector[File] =
cp.map(_.data).toVector
def toSet[A](iterable: Iterable[A]): Set[A] = iterable.to[Set]
def classpathToFiles(classpath: Classpath)(implicit conv: FileConverter): Seq[FileRef] =
classpath.files
def toKey(settingKey: SettingKey[String]): AttributeKey[String] = settingKey.key
def toNioPath(f: File)(implicit conv: FileConverter): NioPath =
f.toPath
def toFile(f: File)(implicit conv: FileConverter): File = f
def toFileRef(f: File)(implicit conv: FileConverter): FileRef = f
def selectFirstPredicate: Seq[FileRef] => Boolean = files =>
files.forall(_.isFile) && files.map(_.hashString).distinct.size == 1
}
33 changes: 33 additions & 0 deletions src/main/scala-3/com/typesafe/sbt/PluginCompat.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.typesafe.sbt

import java.nio.file.{ Path => NioPath }
import java.io.{ File => IoFile }
import sbt.*
import sbt.Keys.Classpath
import xsbti.{ FileConverter, HashedVirtualFileRef, VirtualFile }

private[sbt] object PluginCompat:
type FileRef = HashedVirtualFileRef
type Out = VirtualFile

def toNioPath(a: Attributed[HashedVirtualFileRef])(using conv: FileConverter): NioPath =
conv.toPath(a.data)
inline def toFile(a: Attributed[HashedVirtualFileRef])(using conv: FileConverter): File =
toNioPath(a).toFile
def toNioPaths(cp: Seq[Attributed[HashedVirtualFileRef]])(using conv: FileConverter): Vector[NioPath] =
cp.map(toNioPath).toVector
inline def toFiles(cp: Seq[Attributed[HashedVirtualFileRef]])(using conv: FileConverter): Vector[File] =
toNioPaths(cp).map(_.toFile)
def toSet[A](iterable: Iterable[A]): Set[A] = iterable.to(Set)
inline def classpathToFiles(classpath: Classpath)(using conv: FileConverter): Seq[File] =
toFiles(classpath.to(Seq))
inline def toKey(settingKey: SettingKey[String]): StringAttributeKey = StringAttributeKey(settingKey.key.label)
def toNioPath(hvf: HashedVirtualFileRef)(using conv: FileConverter): NioPath =
conv.toPath(hvf)
def toFile(hvf: HashedVirtualFileRef)(using conv: FileConverter): File =
toNioPath(hvf).toFile
inline def toFileRef(file: File)(using conv: FileConverter): FileRef =
conv.toVirtualFile(file.toPath)
inline def selectFirstPredicate(using conv: FileConverter): Seq[FileRef] => Boolean = files =>
files.forall(toFile(_).isFile) && files.map(_.contentHashStr).distinct.size == 1
end PluginCompat
Loading
Loading