Skip to content

Commit ad497a6

Browse files
committed
Use sbt instead of Maven
1 parent f0f9d03 commit ad497a6

File tree

115 files changed

+1246
-888
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+1246
-888
lines changed

.m2/maven-version-rules.xml

Lines changed: 0 additions & 15 deletions
This file was deleted.

.m2/travis-ci-toolchains.xml

Lines changed: 0 additions & 13 deletions
This file was deleted.

.travis.yml

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,19 @@
11
language: scala
22
os: linux
3+
jdk:
4+
- oraclejdk8
35

46
cache:
57
directories:
6-
- "$HOME/.m2"
8+
- $HOME/.sbt/1.0
9+
- $HOME/.sbt/boot/scala*
10+
- $HOME/.sbt/cache
11+
- $HOME/.sbt/launchers
12+
- $HOME/.ivy2/cache
13+
- $HOME/.coursier
714

8-
install:
9-
- which java
10-
- mvn install -DskipTests=true -DskipITs=true -Dmaven.javadoc.skip=true -B -V --toolchains .m2/travis-ci-toolchains.xml
11-
12-
jobs:
13-
include:
14-
- stage: test
15-
scala:
16-
- 2.11.12
17-
script: mvn test -pl scala/scala_2.11 -B --toolchains .m2/travis-ci-toolchains.xml
18-
jdk: openjdk8
19-
- stage: test
20-
scala:
21-
- 2.12.11
22-
script: mvn test -pl scala/scala_2.12,examples -B --toolchains .m2/travis-ci-toolchains.xml
23-
jdk: openjdk8
24-
- stage: test
25-
scala:
26-
- 2.13.2
27-
script: mvn test -pl scala/scala_2.13,examples -B --toolchains .m2/travis-ci-toolchains.xml
28-
jdk: openjdk8
15+
script:
16+
- sbt +compile +test
2917

3018
branches:
3119
only:

build.sbt

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
2+
val scala211 = "2.11.12"
3+
val scala212 = "2.12.12"
4+
val scala213 = "2.13.3"
5+
6+
val cucumberVersion = "6.8.2"
7+
val jacksonVersion = "2.11.3"
8+
val mockitoScalaVersion = "1.16.0"
9+
val junitVersion = "4.13.1"
10+
11+
scalaVersion := scala213
12+
13+
// Source: https://nathankleyn.com/2019/05/13/recommended-scalac-flags-for-2-13/
14+
lazy val scalacOptions213 = Seq(
15+
"-deprecation", // Emit warning and location for usages of deprecated APIs.
16+
"-explaintypes", // Explain type errors in more detail.
17+
"-feature", // Emit warning and location for usages of features that should be imported explicitly.
18+
"-language:existentials", // Existential types (besides wildcard types) can be written and inferred
19+
"-language:experimental.macros", // Allow macro definition (besides implementation and application)
20+
"-language:higherKinds", // Allow higher-kinded types
21+
"-language:implicitConversions", // Allow definition of implicit functions called views
22+
"-unchecked", // Enable additional warnings where generated code depends on assumptions.
23+
"-Xcheckinit", // Wrap field accessors to throw an exception on uninitialized access.
24+
"-Xfatal-warnings", // Fail the compilation if there are any warnings.
25+
"-Xlint:adapted-args", // Warn if an argument list is modified to match the receiver.
26+
"-Xlint:constant", // Evaluation of a constant arithmetic expression results in an error.
27+
"-Xlint:delayedinit-select", // Selecting member of DelayedInit.
28+
"-Xlint:doc-detached", // A Scaladoc comment appears to be detached from its element.
29+
"-Xlint:inaccessible", // Warn about inaccessible types in method signatures.
30+
"-Xlint:infer-any", // Warn when a type argument is inferred to be `Any`.
31+
"-Xlint:missing-interpolator", // A string literal appears to be missing an interpolator id.
32+
// "-Xlint:nullary-override", // Warn when non-nullary `def f()' overrides nullary `def f'.
33+
"-Xlint:nullary-unit", // Warn when nullary methods return Unit.
34+
"-Xlint:option-implicit", // Option.apply used implicit view.
35+
"-Xlint:package-object-classes", // Class or object defined in package object.
36+
"-Xlint:poly-implicit-overload", // Parameterized overloaded implicit methods are not visible as view bounds.
37+
"-Xlint:private-shadow", // A private field (or class parameter) shadows a superclass field.
38+
"-Xlint:stars-align", // Pattern sequence wildcard must align with sequence component.
39+
"-Xlint:type-parameter-shadow", // A local type parameter shadows a type already in scope.
40+
"-Ywarn-dead-code", // Warn when dead code is identified.
41+
"-Ywarn-extra-implicit", // Warn when more than one implicit parameter section is defined.
42+
"-Ywarn-numeric-widen", // Warn when numerics are widened.
43+
"-Ywarn-unused:implicits", // Warn if an implicit parameter is unused.
44+
"-Ywarn-unused:imports", // Warn if an import selector is not referenced.
45+
"-Ywarn-unused:locals", // Warn if a local definition is unused.
46+
"-Ywarn-unused:params", // Warn if a value parameter is unused.
47+
"-Ywarn-unused:patvars", // Warn if a variable bound in a pattern is unused.
48+
"-Ywarn-unused:privates", // Warn if a private member is unused.
49+
"-Ywarn-value-discard", // Warn when non-Unit expression results are unused.
50+
"-Ybackend-parallelism", "8", // Enable paralellisation — change to desired number!
51+
"-Ycache-plugin-class-loader:last-modified", // Enables caching of classloaders for compiler plugins
52+
"-Ycache-macro-class-loader:last-modified", // and macro definitions. This can lead to performance improvements.
53+
)
54+
55+
val scalacOptions212 = Seq(
56+
"-deprecation", // Emit warning and location for usages of deprecated APIs.
57+
"-encoding", "utf-8", // Specify character encoding used by source files.
58+
"-feature", // Emit warning and location for usages of features that should be imported explicitly.
59+
"-language:implicitConversions", // Allow definition of implicit functions called views
60+
)
61+
62+
val scalacOptions211 = Seq(
63+
"-deprecation",
64+
"-encoding", "UTF-8", // yes, this is 2 args
65+
"-feature",
66+
"-language:implicitConversions"
67+
)
68+
69+
lazy val commonSettings = Seq(
70+
organization := "io.cucumber",
71+
libraryDependencies += "com.novocode" % "junit-interface" % "0.11" % Test,
72+
scalacOptions += "-target:jvm-1.8",
73+
scalacOptions ++= {
74+
CrossVersion.partialVersion(scalaVersion.value) match {
75+
case Some((2, 11)) => scalacOptions211
76+
case Some((2, 12)) => scalacOptions212
77+
case Some((2, 13)) => scalacOptions213
78+
case _ => Seq()
79+
}
80+
},
81+
)
82+
83+
lazy val root = (project in file("."))
84+
.settings(commonSettings)
85+
.aggregate(
86+
cucumberScala.projectRefs ++
87+
examples.projectRefs: _*
88+
)
89+
90+
lazy val cucumberScala = (projectMatrix in file("cucumber-scala"))
91+
.settings(commonSettings)
92+
.settings(
93+
name := "cucumber-scala",
94+
libraryDependencies ++= Seq(
95+
"io.cucumber" % "cucumber-core" % cucumberVersion,
96+
97+
// Users have to provide it (for JacksonDefaultDataTableTransformer)
98+
"com.fasterxml.jackson.core" % "jackson-databind" % jacksonVersion % Provided,
99+
"com.fasterxml.jackson.module" %% "jackson-module-scala" % jacksonVersion % Provided,
100+
101+
"junit" % "junit" % junitVersion % Test,
102+
"io.cucumber" % "cucumber-junit" % cucumberVersion % Test,
103+
"org.mockito" %% "mockito-scala" % mockitoScalaVersion % Test
104+
),
105+
libraryDependencies ++= {
106+
CrossVersion.partialVersion(scalaVersion.value) match {
107+
case Some((2, n)) if n <= 12 => List("org.scala-lang.modules" %% "scala-collection-compat" % "2.2.0")
108+
case _ => Nil
109+
}
110+
},
111+
unmanagedSourceDirectories in Compile ++= {
112+
val sourceDir = (sourceDirectory in Compile).value
113+
CrossVersion.partialVersion(scalaVersion.value) match {
114+
case Some((2, n)) if n <= 11 => Seq(sourceDir / "scala-2.11")
115+
case _ => Seq()
116+
}
117+
},
118+
scalacOptions ++= Seq()
119+
)
120+
.jvmPlatform(scalaVersions = Seq(scala213, scala212, scala211))
121+
122+
lazy val examples = (projectMatrix in file("examples"))
123+
.settings(commonSettings)
124+
.settings(
125+
name := "scala-examples",
126+
libraryDependencies ++= Seq(
127+
"io.cucumber" % "cucumber-junit" % cucumberVersion % Test,
128+
"junit" % "junit" % junitVersion % Test
129+
)
130+
)
131+
.dependsOn(cucumberScala % Test)
132+
.jvmPlatform(scalaVersions = Seq(scala213, scala212))
133+
134+
// TODO src jar ?
135+
// TODO javadoc jar
136+
137+
// TODO OSS publish settings
138+
// But not the examples
139+
140+
// TODO Makefile
File renamed without changes.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Generates the I18n.scala file.
3+
*/
4+
5+
import io.cucumber.gherkin.GherkinDialectProvider
6+
7+
import scala.jdk.CollectionConverters._
8+
9+
val dialectProvider = new GherkinDialectProvider()
10+
11+
val unsupported = Seq("em")
12+
val allLanguages = dialectProvider.getLanguages().asScala.filterNot(l => unsupported.contains(l))
13+
14+
def keywordVal(kw: String): String = {
15+
val keyworkValName = java.text.Normalizer.normalize(kw.replaceAll("[\\s',!]", ""), java.text.Normalizer.Form.NFC)
16+
s"""val $keyworkValName = new Step("$keyworkValName")"""
17+
}
18+
19+
def traitCode(language: String): String = {
20+
val traitName = language.replaceAll("[\\s-]", "_").toUpperCase()
21+
val keywords = dialectProvider
22+
.getDialect(language, null).getStepKeywords()
23+
.asScala
24+
.filter(kw => !kw.contains('*') && !kw.matches("^\\d.*"))
25+
.sorted
26+
.distinct
27+
28+
s"""
29+
|trait $traitName {
30+
| this: ScalaDsl =>
31+
|${keywords.map(kw => keywordVal(kw)).mkString("\n\n")}
32+
|}
33+
|""".stripMargin
34+
}
35+
36+
val i18n = s"""
37+
|package io.cucumber.scala
38+
|
39+
|${allLanguages.map(l => traitCode(l)).mkString("\n\n")}
40+
|""".stripMargin
41+
42+
println(i18n)

0 commit comments

Comments
 (0)