Skip to content

Commit

Permalink
Merge pull request #840 from xuwei-k/sbt-2
Browse files Browse the repository at this point in the history
add sbt 2.x build setting
  • Loading branch information
mkurz authored Oct 7, 2024
2 parents 71e2d56 + e5c47ee commit 8bca0a5
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 7 deletions.
11 changes: 10 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ lazy val compiler = project
}
},
libraryDependencies += parserCombinators(scalaVersion.value),
libraryDependencies += ("org.scalameta" %% "parsers" % "4.9.7").cross(CrossVersion.for3Use2_13),
libraryDependencies += ("org.scalameta" %% "parsers" % "4.10.1").cross(CrossVersion.for3Use2_13),
run / fork := true,
buildInfoKeys := Seq[BuildInfoKey](scalaVersion),
buildInfoPackage := "play.twirl.compiler",
Expand All @@ -137,6 +137,15 @@ lazy val plugin = project
sonatypeProfileName := "org.playframework",
scalaVersion := Scala212,
libraryDependencies += "org.scalatest" %%% "scalatest" % ScalaTestVersion % Test,
crossScalaVersions += Scala3,
pluginCrossBuild / sbtVersion := {
scalaBinaryVersion.value match {
case "2.12" =>
sbtVersion.value
case _ =>
"2.0.0-M2"
}
},
Compile / resourceGenerators += generateVersionFile.taskValue,
scriptedLaunchOpts += version.apply { v => s"-Dproject.version=$v" }.value,
// both `locally`s are to work around sbt/sbt#6161
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Copyright (C) from 2022 The Play Framework Contributors <https://github.com/playframework>, 2011-2021 Lightbend Inc. <https://www.lightbend.com>

sbt.version=1.10.0
sbt.version=1.10.2
4 changes: 3 additions & 1 deletion sbt-twirl/src/main/scala/play/twirl/sbt/SbtTwirl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ package play.twirl.sbt

import play.twirl.compiler.TwirlCompiler
import sbt.Keys._
import sbt._
// format: off
import sbt.{given, _}
// format: on
import scala.io.Codec

object Import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ object TemplateCompiler {
}

def generatedFiles(targetDirectory: File): Seq[File] = {
(targetDirectory ** "*.template.scala").get
(targetDirectory ** "*.template.scala").get()
}

def syncGenerated(targetDirectory: File, codec: Codec): Unit = {
generatedFiles(targetDirectory).map(GeneratedSource(_, codec)).foreach(_.sync)
generatedFiles(targetDirectory).map(GeneratedSource(_, codec)).foreach(_.sync())
}

def collectTemplates(
Expand All @@ -91,7 +91,7 @@ object TemplateCompiler {
excludeFilter: FileFilter
): Seq[(File, File, String, String)] = {
sourceDirectories.flatMap { sourceDirectory =>
(sourceDirectory ** includeFilter).get.flatMap { file =>
(sourceDirectory ** includeFilter).get().flatMap { file =>
val ext = file.name.split('.').last
if (!excludeFilter.accept(file) && templateFormats.contains(ext))
Some((file, sourceDirectory, ext, templateFormats(ext)))
Expand Down
2 changes: 1 addition & 1 deletion scripts/test-code.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
# Copyright (C) from 2022 The Play Framework Contributors <https://github.com/playframework>, 2011-2021 Lightbend Inc. <https://www.lightbend.com>

sbt "++$MATRIX_SCALA test; mavenPlugin/scripted" || exit 1
sbt +publishLocal +compiler/publishM2 +apiJVM/publishM2 plugin/test plugin/scripted || exit 1
sbt +publishLocal +compiler/publishM2 +apiJVM/publishM2 +plugin/test plugin/scripted || exit 1
(cd gradle-twirl && ./gradlew clean check -x spotlessCheck --no-daemon -Pscala.version="$MATRIX_SCALA") || exit 1

0 comments on commit 8bca0a5

Please sign in to comment.