Skip to content

Commit 9347efd

Browse files
committed
Cross compile to Scala 3.0.0-M1
1 parent e32563a commit 9347efd

File tree

9 files changed

+36
-13
lines changed

9 files changed

+36
-13
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ See also the [CHANGELOG](https://github.com/cucumber/cucumber-jvm/blob/master/CH
1313

1414
- [Build] Setup formatting using `scalafmt`
1515
- [CI] Build & test on both JDK 8 and 11
16+
- [Build] Cross compilation with Scala 3.0.0-M1
1617

1718
### Changed
1819

build.sbt

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ ThisBuild / homepage := Some(
3333
val scala211 = "2.11.12"
3434
val scala212 = "2.12.12"
3535
val scala213 = "2.13.3"
36+
val scala3 = "3.0.0-M1"
3637

3738
scalaVersion := scala213
3839

@@ -52,9 +53,11 @@ lazy val commonSettings = Seq(
5253
case Some((2, 11)) => ScalacOptions.scalacOptions211
5354
case Some((2, 12)) => ScalacOptions.scalacOptions212
5455
case Some((2, 13)) => ScalacOptions.scalacOptions213
56+
case Some((3, 0)) => ScalacOptions.scalacOptions3
5557
case _ => Seq()
5658
}
57-
}
59+
},
60+
scalacOptions ++= { if (isDotty.value) Seq("-source:3.0") else Nil }
5861
)
5962

6063
lazy val root = (project in file("."))
@@ -76,10 +79,11 @@ lazy val cucumberScala = (projectMatrix in file("cucumber-scala"))
7679
"io.cucumber" % "cucumber-core" % cucumberVersion,
7780
// Users have to provide it (for JacksonDefaultDataTableTransformer)
7881
"com.fasterxml.jackson.core" % "jackson-databind" % jacksonVersion % Provided,
79-
"com.fasterxml.jackson.module" %% "jackson-module-scala" % jacksonVersion % Provided,
82+
("com.fasterxml.jackson.module" %% "jackson-module-scala" % jacksonVersion % Provided).withDottyCompat(scalaVersion.value),
83+
8084
"junit" % "junit" % junitVersion % Test,
8185
"io.cucumber" % "cucumber-junit" % cucumberVersion % Test,
82-
"org.mockito" %% "mockito-scala" % mockitoScalaVersion % Test
86+
("org.mockito" %% "mockito-scala" % mockitoScalaVersion % Test).withDottyCompat(scalaVersion.value)
8387
),
8488
libraryDependencies ++= {
8589
CrossVersion.partialVersion(scalaVersion.value) match {
@@ -103,7 +107,7 @@ lazy val cucumberScala = (projectMatrix in file("cucumber-scala"))
103107
Seq(file)
104108
}.taskValue
105109
)
106-
.jvmPlatform(scalaVersions = Seq(scala213, scala212, scala211))
110+
.jvmPlatform(scalaVersions = Seq(scala3, scala213, scala212, scala211))
107111

108112
// Examples project
109113
lazy val examples = (projectMatrix in file("examples"))
@@ -117,7 +121,7 @@ lazy val examples = (projectMatrix in file("examples"))
117121
publishArtifact := false
118122
)
119123
.dependsOn(cucumberScala % Test)
120-
.jvmPlatform(scalaVersions = Seq(scala213, scala212))
124+
.jvmPlatform(scalaVersions = Seq(scala3, scala213, scala212))
121125

122126
// Release & Publish
123127

cucumber-scala/src/main/scala/io/cucumber/scala/GlueAdaptor.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class GlueAdaptor(glue: Glue) {
1616

1717
// If the registry is not consistent, this indicates a mistake in the users definition and we want to let him know.
1818
registry.checkConsistency().left.foreach {
19-
ex: IncorrectHookDefinitionException =>
19+
(ex: IncorrectHookDefinitionException) =>
2020
throw ex
2121
}
2222

cucumber-scala/src/main/scala/io/cucumber/scala/Implicits.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ object Implicits {
3333
table
3434
.asMaps[K, V](evK.runtimeClass, evV.runtimeClass)
3535
.asScala
36-
.map(_.asScala.map(nullToNone).toMap)
36+
.map(_.asScala.map(nullToNone(_)).toMap)
3737
.toSeq
3838
}
3939

@@ -79,7 +79,7 @@ object Implicits {
7979
table
8080
.asMap[K, V](evK.runtimeClass, evV.runtimeClass)
8181
.asScala
82-
.map(nullToNone)
82+
.map(nullToNone(_))
8383
.toMap
8484
}
8585

@@ -172,7 +172,7 @@ object Implicits {
172172
classOf[java.util.Map[String, String]]
173173
)
174174
.asScala
175-
.map { case (k, v) => (k, v.asScala.map(nullToNone).toMap) }
175+
.map { case (k, v) => (k, v.asScala.map(nullToNone(_)).toMap) }
176176
.toMap
177177
}
178178

cucumber-scala/src/main/scala/io/cucumber/scala/ScalaDsl.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1155,7 +1155,8 @@ private[scala] trait StepDsl extends BaseScalaDsl {
11551155
*
11561156
**/
11571157
def apply(f: => Unit): Unit = {
1158-
apply(() => f)
1158+
val fun0 = () => f
1159+
apply(fun0)
11591160
}
11601161

11611162
def apply(fun: Fun0): Unit = {

examples/src/main/scala/cucumber/examples/scalacalculator/RpnCalculator.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import scala.collection.mutable.Queue
55
sealed trait Arg
66

77
object Arg {
8-
implicit def op(s: String) = Op(s)
9-
implicit def value(v: Double) = Val(v)
8+
implicit def op(s:String): Op = Op(s)
9+
implicit def value(v:Double): Val = Val(v)
1010
}
1111

1212
case class Op(value: String) extends Arg

project/I18nGenerator.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ object I18nGenerator {
1616
private def keywordVal(kw: String): String = {
1717
val keyworkValName = java.text.Normalizer
1818
.normalize(kw.replaceAll("[\\s',!]", ""), java.text.Normalizer.Form.NFC)
19-
s"""val $keyworkValName = new Step("$keyworkValName")"""
19+
s""" val $keyworkValName = new Step("$keyworkValName")"""
2020
}
2121

2222
private def traitCode(language: String): String = {

project/ScalacOptions.scala

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
object ScalacOptions {
22

3+
val scalacOptions3 = Seq(
4+
"-rewrite",
5+
"-deprecation", // Emit warning and location for usages of deprecated APIs.
6+
"-explain", // Explain type errors in more detail.
7+
// "-explaintypes", // Explain type errors in more detail.
8+
"-feature", // Emit warning and location for usages of features that should be imported explicitly.
9+
"-language:existentials", // Existential types (besides wildcard types) can be written and inferred
10+
"-language:experimental.macros", // Allow macro definition (besides implementation and application)
11+
"-language:higherKinds", // Allow higher-kinded types
12+
"-language:implicitConversions", // Allow definition of implicit functions called views
13+
"-unchecked", // Enable additional warnings where generated code depends on assumptions.
14+
"-Xfatal-warnings" // Fail the compilation if there are any warnings.
15+
)
16+
317
// Source: https://nathankleyn.com/2019/05/13/recommended-scalac-flags-for-2-13/
418
val scalacOptions213 = Seq(
519
"-deprecation", // Emit warning and location for usages of deprecated APIs.

project/plugins.sbt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ addSbtPlugin("com.eed3si9n" % "sbt-projectmatrix" % "0.6.0")
44
// Scalafmt (formatter)
55
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.2")
66

7+
// Scala 3 (Dotty)
8+
addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.4.6")
9+
710
// Release
811
addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.13")
912

0 commit comments

Comments
 (0)