I'm extending an existing performance test project, which is a Scala project that uses Gatling for simulations and Maven as a build tool. I need Scalaj as a new depenency. I changed Scala version from 2.12.8
to 2.13.0
so that I could use the most recent version of Scalaj (2.4.2
) and this resulted in a compile error from a class that uses the /
operator from io.gatling.commons.util.PathHelper
.
I only get this error if I run the project using IntelliJ config but not if I run mvn package
and mvn gatling:test
. I also don't get the error if I go with the IntelliJ config and Scala 2.12.8
.
I thought this could be a compatibility issue and checked the Gatling documentation & release notes but the last thing they mentioned concerning Scala compatibility was that from 2.3
on Gatling requires Scala 2.12
. I suppose it means 2.12
or higher. Am I wrong at this point?
I also checked if there's an update to the IntelliJ Scala plugin but found nothing.
Here's the relevant part of my pom.xml
file:
<dependencies>
<dependency>
<groupId>io.gatling.highcharts</groupId>
<artifactId>gatling-charts-highcharts</artifactId>
<version>3.0.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>2.13.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.scalaj/scalaj-http -->
<dependency>
<groupId>org.scalaj</groupId>
<artifactId>scalaj-http_2.13</artifactId>
<version>2.4.2</version>
</dependency>
</dependencies>
The class that doesn't compile (where /
is a function from the imported class):
package com.example.mypackage
import io.gatling.commons.util.PathHelper._
object PathHelper {
val projectRootDir: Path = "root_directory"
val mavenSourcesDirectory: Path = projectRootDir / "src"
}
An example entry point:
package com.example.mypackage
object ApplicationRunner {
def main(args: Array[String]): Unit = {
println(mavenSourcesDirectory.toString)
}
}
The error message I get after I hit IntelliJ's Run button (I changed some irrelevant project-specific info to comments between <>
's):
Error:scalac: Error: assertion failed:
no extension method found for:
method /:(pathString: String)java.nio.file.Path
Candidates:
Candidates (signatures normalized):
"
while compiling: /home/me/example-repo/src/test/scala/com/example/mypackage/PathHelper.scala
during phase: globalPhase=erasure, enteringPhase=refchecks
library version: version 2.13.0
compiler version: version 2.13.0
reconstructed args: -classpath <.jar path for every dependency I use>
last tree to typer: Select(Apply(method to), foreach$mVc$sp)
tree position: <some line in an entirely different class where I don't use PathHelper>
tree tpe: (f: Int => Unit)Unit
symbol: (final override) method foreach$mVc$sp in class Range
symbol definition: final override def foreach$mVc$sp(f: Int => Unit): Unit (a MethodSymbol)
symbol package: scala.collection.immutable
symbol owners: method foreach$mVc$sp -> class Range
call site: object PathHelper in package mypackage in package mypackage
== Source file context for tree position ==
12 <line from file>
13 <line from file>
14 <tree position>
15 <line from file>
at scala.reflect.internal.SymbolTable.throwAssertionError(SymbolTable.scala:170)
at scala.tools.nsc.transform.ExtensionMethods.$anonfun$extensionMethod$1(ExtensionMethods.scala:54)
at scala.tools.nsc.transform.ExtensionMethods.extensionMethod(ExtensionMethods.scala:49)
at scala.tools.nsc.transform.Erasure$ErasureTransformer$$anon$4.preEraseNormalApply(Erasure.scala:1102)
at scala.tools.nsc.transform.Erasure$ErasureTransformer$$anon$4.preEraseApply(Erasure.scala:1204)
at scala.tools.nsc.transform.Erasure$ErasureTransformer$$anon$4.preErase(Erasure.scala:1214)
at scala.tools.nsc.transform.Erasure$ErasureTransformer$$anon$4.transform(Erasure.scala:1333)
at scala.tools.nsc.transform.Erasure$ErasureTransformer$$anon$4.transform(Erasure.scala:993)
at scala.reflect.internal.Trees$ValDef.$anonfun$transform$4(Trees.scala:405)
at scala.reflect.api.Trees$Transformer.atOwner(Trees.scala:2625)
<and so on for 78 more lines of stack trace>
After all, it looks like an IntelliJ dependency handling issue to me. I already found two workarounds so this problem isn't killing me but it's inconvenient and I'm interested in learning about fixing it. Also, I'm fairly new to Scala so there's a good chance I'm missing something.
Any insight would be appreciated.
Haven't tried it myself but it seems Gatling is not yet compatible with Scala 2.13:
https://github.com/gatling/gatling/issues/3566
It might be easiest to go back to 2.12.