Skip to content

Commit f6c9af5

Browse files
lewismjglibas
authored andcommitted
scala 2.13 (#18)
* scala-2.13 compatibility * Add extra call in travis file and fix RpnCalculator.scala
1 parent 883a8b8 commit f6c9af5

File tree

9 files changed

+113
-52
lines changed

9 files changed

+113
-52
lines changed

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ jobs:
1313
- stage: test
1414
scala: 2.12
1515
script: mvn test -pl scala/scala_2.12,examples -B
16+
- stage: test
17+
scala: 2.13
18+
script: mvn test -pl scala/scala_2.13,examples -B
1619
- stage: deploy
1720
jdk: openjdk8
1821
script:

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ case class Op(value: String) extends Arg
1414
case class Val(value: Double) extends Arg
1515

1616
class RpnCalculator {
17-
private val stack = new Queue[Double]
17+
private val stack = Queue.empty[Double]
1818

1919
private def op(f: (Double, Double) => Double) =
2020
stack += f(stack.dequeue(), stack.dequeue())
@@ -30,4 +30,4 @@ class RpnCalculator {
3030
}
3131

3232
def value = stack.head
33-
}
33+
}

pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
<mockito.version>1.10.19</mockito.version>
3838
<scala.2.12.version>2.12.7</scala.2.12.version>
3939
<scala.2.11.version>2.11.12</scala.2.11.version>
40-
40+
<scala.2.13.version>2.13.0</scala.2.13.version>
4141
</properties>
4242

4343
<scm>
@@ -119,6 +119,7 @@
119119
<sourceDirectories>
120120
<sourceDirectory>${basedir}/scala/scala_2.11/target/generated-sources/i18n</sourceDirectory>
121121
<sourceDirectory>${basedir}/scala/scala_2.12/target/generated-sources/i18n</sourceDirectory>
122+
<sourceDirectory>${basedir}/scala/scala_2.13/target/generated-sources/i18n</sourceDirectory>
122123
</sourceDirectories>
123124
</configuration>
124125
</plugin>

scala/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
<modules>
1515
<module>scala_2.11</module>
16+
<module>scala_2.13</module>
1617
</modules>
1718

1819
<profiles>

scala/scala_2.13/pom.xml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
<modelVersion>4.0.0</modelVersion>
3+
4+
<parent>
5+
<groupId>io.cucumber</groupId>
6+
<artifactId>cucumber-scala-aggregator</artifactId>
7+
<version>4.4.1-SNAPSHOT</version>
8+
</parent>
9+
10+
<artifactId>cucumber-scala_2.13</artifactId>
11+
<packaging>jar</packaging>
12+
<name>Cucumber-JVM: Scala (2.13)</name>
13+
14+
<dependencies>
15+
<dependency>
16+
<groupId>org.scala-lang</groupId>
17+
<artifactId>scala-compiler</artifactId>
18+
<version>${scala.2.13.version}</version>
19+
<scope>provided</scope>
20+
</dependency>
21+
22+
<dependency>
23+
<groupId>org.scala-lang</groupId>
24+
<artifactId>scala-library</artifactId>
25+
<version>${scala.2.13.version}</version>
26+
<scope>test</scope>
27+
</dependency>
28+
</dependencies>
29+
30+
<build>
31+
<sourceDirectory>../sources/src/main/scala</sourceDirectory>
32+
<testSourceDirectory>../sources/src/test/scala</testSourceDirectory>
33+
<testResources>
34+
<testResource>
35+
<directory>../sources/src/test/resources</directory>
36+
</testResource>
37+
</testResources>
38+
<plugins>
39+
<plugin>
40+
<groupId>org.apache.maven.plugins</groupId>
41+
<artifactId>maven-compiler-plugin</artifactId>
42+
<configuration>
43+
<source>1.8</source>
44+
<target>1.8</target>
45+
</configuration>
46+
</plugin>
47+
<plugin>
48+
<groupId>net.alchim31.maven</groupId>
49+
<artifactId>scala-maven-plugin</artifactId>
50+
</plugin>
51+
<plugin>
52+
<groupId>org.apache.maven.plugins</groupId>
53+
<artifactId>maven-antrun-plugin</artifactId>
54+
</plugin>
55+
</plugins>
56+
</build>
57+
</project>

scala/sources/src/main/scala/cucumber/api/scala/ScalaDsl.scala

Lines changed: 38 additions & 38 deletions
Large diffs are not rendered by default.

scala/sources/src/main/scala/cucumber/runtime/scala/ScalaBackend.scala

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,15 @@ class ScalaBackend(resourceLoader:ResourceLoader, typeRegistry: TypeRegistry) ex
3434

3535
def getBeforeStepHooks = instances.flatMap(_.beforeStepHooks)
3636

37-
def disposeWorld() {
38-
instances = Nil
39-
}
37+
def disposeWorld() : Unit = { instances = Nil }
4038

4139
def getSnippet(step: PickleStep, keyword: String, functionNameGenerator: FunctionNameGenerator) = snippetGenerator.getSnippet(step, keyword, functionNameGenerator)
4240

43-
def buildWorld() {
41+
def buildWorld() : Unit = {
4442
//I don't believe scala has to do anything to clean out its world
4543
}
4644

47-
def loadGlue(glue: Glue, gluePaths: JList[URI]) {
45+
def loadGlue(glue: Glue, gluePaths: JList[URI]) : Unit = {
4846

4947
val cl = Thread.currentThread().getContextClassLoader
5048
val classFinder = new ResourceLoaderClassFinder(resourceLoader, cl)
@@ -70,15 +68,16 @@ class ScalaBackend(resourceLoader:ResourceLoader, typeRegistry: TypeRegistry) ex
7068
instField.setAccessible(true)
7169
instField.get(null).asInstanceOf[ScalaDsl]
7270
}
73-
val clsInstances = clsClasses map {_.newInstance()}
71+
val clsInstances = clsClasses.map {_.newInstance()}
7472

75-
instances = objInstances ++ clsInstances
73+
instances = objInstances.toSeq ++ clsInstances
7674

7775
getStepDefinitions map {glue.addStepDefinition(_)}
7876
getBeforeHooks map {glue.addBeforeHook(_)}
7977
getAfterHooks map {glue.addAfterHook(_)}
8078
getAfterStepHooks map {glue.addAfterStepHook(_)}
8179
getBeforeStepHooks map {glue.addBeforeStepHook(_)}
80+
()
8281
}
8382

8483
}

scala/sources/src/main/scala/cucumber/runtime/scala/ScalaHookDefinition.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ class ScalaHookDefinition(f:Scenario => Unit,
1515

1616
val tagPredicate = new TagPredicate(tags.asJava)
1717

18-
def getLocation(detail: Boolean) = "TODO: Implement getLocation in similar fashion to ScalaStepDefinition"
18+
def getLocation(detail: Boolean) = "TODO: Implement getLocation in similar fashion to ScalaStepDefinition"
1919

20-
def execute(scenario: Scenario) { f(scenario) }
20+
def execute(scenario: Scenario): Unit = f(scenario)
2121

2222
def matches(tags: Collection[PickleTag]) = tagPredicate.apply(tags)
2323

2424
def getOrder = order
2525

2626
def isScenarioScoped = false
27-
}
27+
}

scala/sources/src/main/scala/cucumber/runtime/scala/ScalaSnippetGenerator.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class ScalaSnippetGenerator extends Snippet {
2929
def name(clazz: Class[_]) =
3030
if(clazz.isPrimitive){
3131
val name = clazz.getName
32-
name.charAt(0).toUpper + name.substring(1)
32+
s"${name.charAt(0).toUpper}${name.substring(1)}"
3333
} else
3434
clazz.getSimpleName
3535

0 commit comments

Comments
 (0)