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

[Scala] Compile cucumber-scala_2.12 against Java 8 #1171

Merged
merged 2 commits into from
Jul 9, 2017
Merged
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
6 changes: 5 additions & 1 deletion History.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## [2.0.0-SNAPSHOT](https://github.com/cucumber/cucumber-jvm/compare/v1.2.5...master) (In Git)

* [Scala] Compile cucumber-scala_2.12 against Java 8 ([#1171](https://github.com/cucumber/cucumber-jvm/pull/1171), [#1087](https://github.com/cucumber/cucumber-jvm/issues/1087) M.P. Korstanje, Paolo Ambrosio). This includes:
* Update Scala Versions
- 2.12.0-M1 to 2.12.2
- 2.11.8 to 2.11.11
* Use Manifest instead of Java reflection to provide type information
* [Core] Add TestRunStarted event, let Stats handle the exit code ([#1162](https://github.com/cucumber/cucumber-jvm/pull/1162) Björn Rasmusson)
* [Core, JUnit, Android] Add the ambiguous result type ([#1168](https://github.com/cucumber/cucumber-jvm/pull/1168) Björn Rasmusson)
* [Core] Add the SnippetsSuggestedEvent ([#1163](https://github.com/cucumber/cucumber-jvm/pull/1163) Björn Rasmusson)
Expand Down
2 changes: 1 addition & 1 deletion examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
<module>java-calculator</module>
<module>java-calculator-testng</module>
<module>groovy-calculator</module>
<module>scala-calculator</module>
<module>pax-exam</module>
</modules>

Expand All @@ -28,6 +27,7 @@
<jdk>1.8</jdk>
</activation>
<modules>
<module>scala-calculator</module>
<module>java-wicket</module>
<module>java-webbit-websockets-selenium</module>
</modules>
Expand Down
25 changes: 15 additions & 10 deletions examples/scala-calculator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

<parent>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-jvm</artifactId>
<relativePath>../../pom.xml</relativePath>
<artifactId>cucumber-examples</artifactId>
<version>2.0.0-SNAPSHOT</version>
</parent>

Expand All @@ -20,7 +19,8 @@
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-scala_2.11</artifactId>
<artifactId>cucumber-scala_2.12</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -36,23 +36,28 @@
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala.latest.version}</version>
<scope>test</scope>
<version>${scala.2.12.version}</version>
</dependency>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-compiler</artifactId>
<version>${scala.latest.version}</version>
<scope>test</scope>
<version>${scala.2.12.version}</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<version>2.15.2</version>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<configuration>
<!--encoding>UTF-8</encoding-->
<excludes>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cucumber.examples.scalacalculator

import collection.mutable.Stack
import scala.collection.mutable.Queue


sealed trait Arg

Expand All @@ -13,18 +14,18 @@ case class Op(value: String) extends Arg
case class Val(value: Double) extends Arg

class RpnCalculator {
private val stack = new Stack[Double]
private val stack = new Queue[Double]

private def op(f: (Double, Double) => Double) =
stack push f(stack.pop(), stack.pop())
stack += f(stack.dequeue(), stack.dequeue())

def push(arg: Arg) {
arg match {
case Op("+") => op(_ + _)
case Op("-") => op(_ - _)
case Op("*") => op(_ * _)
case Op("/") => op(_ / _)
case Val(value) => stack push value
case Val(value) => stack += value
}
}

Expand Down
10 changes: 3 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@
<guice.version>4.0</guice.version>
<!-- Remember to bounce version in examples/clojure_cukes/project.clj as well -->
<clojure.version>1.8.0</clojure.version>
<!-- This is only here for the example project to use, the 3 scala projects maintain their own versions -->
<scala.latest.version>2.11.8</scala.latest.version>
<scala.2.12.version>2.12.2</scala.2.12.version>
<scala.2.11.version>2.11.11</scala.2.11.version>
<scala.2.10.version>2.10.6</scala.2.10.version>
<gosu.version>1.14.6</gosu.version>
<rhino.version>1.7.7.1</rhino.version>
<jsoup.version>1.9.2</jsoup.version>
Expand Down Expand Up @@ -163,11 +164,6 @@
<artifactId>cucumber-picocontainer</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-scala_2.11</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-html</artifactId>
Expand Down
21 changes: 18 additions & 3 deletions scala/pom.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<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">
<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">
<modelVersion>4.0.0</modelVersion>

<parent>
Expand All @@ -15,9 +17,20 @@
<modules>
<module>scala_2.11</module>
<module>scala_2.10</module>
<module>scala_2.12</module>
</modules>

<profiles>
<profile>
<id>java8</id>
<activation>
<jdk>1.8</jdk>
</activation>
<modules>
<module>scala_2.12</module>
</modules>
</profile>
</profiles>

<dependencies>
<dependency>
<groupId>io.cucumber</groupId>
Expand Down Expand Up @@ -104,7 +117,9 @@
<phase>generate-sources</phase>
<configuration>
<target>
<taskdef name="groovy" classname="org.codehaus.groovy.ant.Groovy" classpathref="maven.plugin.classpath" />
<taskdef name="groovy"
classname="org.codehaus.groovy.ant.Groovy"
classpathref="maven.plugin.classpath"/>

<groovy><![CDATA[
import groovy.text.SimpleTemplateEngine
Expand Down
8 changes: 2 additions & 6 deletions scala/scala_2.10/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,18 @@
<packaging>jar</packaging>
<name>Cucumber-JVM: Scala (2.10)</name>

<properties>
<scala.version>2.10.6</scala.version>
</properties>

<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-compiler</artifactId>
<version>${scala.version}</version>
<version>${scala.2.10.version}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala.version}</version>
<version>${scala.2.10.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
8 changes: 2 additions & 6 deletions scala/scala_2.11/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,18 @@
<packaging>jar</packaging>
<name>Cucumber-JVM: Scala (2.11)</name>

<properties>
<scala.version>2.11.8</scala.version>
</properties>

<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-compiler</artifactId>
<version>${scala.version}</version>
<version>${scala.2.11.version}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala.version}</version>
<version>${scala.2.11.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
20 changes: 10 additions & 10 deletions scala/scala_2.12/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,18 @@
<packaging>jar</packaging>
<name>Cucumber-JVM: Scala (2.12)</name>

<properties>
<!--
Upgrading to 2.12.0-M2 or higher causes:

initializationError(cucumber.runtime.scala.test.RunCukesTest) Time elapsed: 0.006 sec <<< ERROR! java.util.NoSuchElementException: next on empty iterator [no stack trace] -->
<scala.version>2.12.0-M1</scala.version>
</properties>

<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-compiler</artifactId>
<version>${scala.version}</version>
<version>${scala.2.12.version}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala.version}</version>
<version>${scala.2.12.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand All @@ -45,6 +37,14 @@
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion scala/sources/gen.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ for (i <- 1 to 22) {
val f = "(" + ts + ") => Any"
val p1 = "def apply[" + ts + "](f: " + f + ")"
val p2 = "(implicit " + (1 to i).map(n => "m" + n + ":Manifest[T" + n + "]").mkString(", ") + ")"
val register = "\n register(functionParams(f)) {\n"
val register = "\n register(" +(1 to i).map(n => "m" + n).mkString(", ") + ") {\n"
val pf = " case List(" + (1 to i).map("a" + _ + ":AnyRef").mkString(", ") + ") => \n f(" + (1 to i).map(n => "a" + n + ".asInstanceOf[T" + n + "]").mkString(",\n ") + ")"
val closeRegister = "\n }\n}"

Expand Down
Loading