Problems with Gatling Gradle plugin and Scala versions

I am trying to use the Gatling Gradle plugin in a Spring Boot app. I am getting a bunch of errors like the following:

> Task :compileGatlingScala
java.io.IOException: Scala signature Predef has wrong version
expected: 5.0
found: 5.2 in Predef.class

In searching on Google, this error appears to be caused by having version 2.13 of Scala, instead of 2.12. However, as far as I can see from the Gradle plugin in IntelliJ, I am using 2.12.

Here are snippets from my build.gradle.kts file:

plugins {
...
id("io.gatling.gradle") version "3.5.0"
}

dependencies {
...
gatling("org.scala-lang:scala-library") { version { strictly("2.12.10") } }
}

// The follow shows an error in the IDE, but it actually works to set the
// correct version in the Gradle `compileClasspath` and `runtimeClasspath`;
// without this, both of those get set to `2.13.4`
gatling {
scalaVersion = "2.12.10"
}

Here is the output of the gradle dependencies command:

compileClasspath - Compile classpath for compilation 'main' (target (jvm)).
...
\--- org.scala-lang:scala-library:2.12.10
...

gatling
+--- org.scala-lang:scala-library:{strictly 2.12.10} -> 2.12.10
\--- io.gatling.highcharts:gatling-charts-highcharts:3.5.0
+--- org.scala-lang:scala-library:2.13.3 -> 2.12.10
+--- io.gatling:gatling-app:3.5.0
> +--- org.scala-lang:scala-library:2.13.3 -> 2.12.10
> +--- io.gatling:gatling-core:3.5.0
> > +--- org.scala-lang:scala-library:2.13.3 -> 2.12.10
> > +--- io.gatling:gatling-commons:3.5.0
> > > +--- org.scala-lang:scala-library:2.13.3 -> 2.12.10
> > > +--- io.gatling:gatling-commons-shared:3.5.0
> > > > +--- org.scala-lang:scala-library:2.13.3 -> 2.12.10
(and on and on)
...

gatlingCompileClasspath - Compile classpath for compilation 'gatling' (target (jvm)).
+--- org.scala-lang:scala-library:{strictly 2.12.10} -> 2.12.10
+--- io.gatling.highcharts:gatling-charts-highcharts:3.5.0
> +--- org.scala-lang:scala-library:2.13.3 -> 2.12.10
(and on and on)
...

gatlingImplementation - Implementation only dependencies for compilation 'gatling' (target (jvm)). (n)
+--- org.scala-lang:scala-library:2.12.10 (n)
+--- unspecified (n)
\--- unspecified (n)

gatlingImplementationDependenciesMetadata
+--- org.scala-lang:scala-library:{strictly 2.12.10} -> 2.12.10
+--- io.gatling.highcharts:gatling-charts-highcharts:3.5.0
> +--- org.scala-lang:scala-library:2.13.3 -> 2.12.10
(and on and on)
...

gatlingRuntimeClasspath - Runtime classpath of compilation 'gatling' (target (jvm)).
+--- org.scala-lang:scala-library:{strictly 2.12.10} -> 2.12.10
+--- io.gatling.highcharts:gatling-charts-highcharts:3.5.0
> +--- org.scala-lang:scala-library:2.13.3 -> 2.12.10
> +--- io.gatling:gatling-app:3.5.0
> > +--- org.scala-lang:scala-library:2.13.3 -> 2.12.10
(and on and on)
...

Everywhere that the scala-library is showing up in the dependencies, the version is always being overridden to 2.12.10. So I’m not sure where the bad version is coming from.

I have no idea what is wrong, or how to resolve the issue.

Scala 2.12 and Scala 2.13 are different MAJOR versions that are not binary compatible.

Gatling 3.5 requires Scala 2.13, meaning that:

  • you must revert to 2.13.4 in your build.gradle.kts
  • if you want to compile from IntelliJ, you must configure Scala 2.13 there too, not 2.12 (look for Scala compiler in your project settings).

Thanks for the speedy answer, Stephane!

There’s the rub for me. I was trying to use Scala 2.12 so I could use this AMQP for Gatling library, so we could test messaging with RabbitMQ:
https://github.com/TinkoffCreditSystems/gatling-amqp-plugin

And the doc specifically says it will only run on Scala 2.12.

And actually, I got the info about what version of Scala to use from this web page:
https://gatling.io/docs/current/installation/#scala-version

That’s a 3rd party plugin, so there isn’t much we can do, unless the authors decide to donate it and contribute it upstream.
Have you tried reaching out to the authors, e.g. opening a ticket on their bugtracker?

And actually, I got the info about what version of Scala to use from this web page:
https://gatling.io/docs/current/installation/#scala-version

Oh right, we missed this page when we switched to 2.13. Will fix, thanks.

Thanks again, Stephane! I just reverted my gatling version to “3.4.0”, and I’m able to run the AMQP plugin. But I will suggest they do an upgrade for Scala 2.13.x.