Error in Gradle Kotlin DSL (build.gradle.kts)

Hi,

I’m currently migrating my build.gradle from Groovy DSL to Kotlin DSL (to build.gradle.kts). Until now I was using gatling for performance testing for a long time and it was working fine. I didn’t change anything during my migration, but it now shows errors in the build.gradle.kts and I’m also unable to run my Simulation due to unresolved imports.

My gatling setup in build.gradle (Groovy DSL):
plugins {
id ‘java’
id ‘io.gatling.gradle’ version ‘3.7.3’
}

repositories {
mavenCentral()
}

gatling {
jvmArgs = [’-server’, ‘-Xms512M’, ‘-Xmx1024M’, ‘-Xss100M’]
logHttp = ‘ALL’
}

My gatling setup in build.gradle.kts (Kotlin DSL):

plugins {
java
id(“io.gatling.gradle”) version “3.7.3”
}

repositories {
mavenCentral()
}

gatling {
jvmArgs = listOf("-server", “-Xms512M”, “-Xmx1024M”, “-Xss100M”)
logHttp = io.gatling.gradle.LogHttp.ALL
}

jvmArgs and logHttp show following error:

Cannot access ‘io.gatling.gradle.JvmConfigurable$Trait$FieldHelper’ which is a supertype of ‘io.gatling.gradle.GatlingPluginExtension’. Check your module classpath for missing or conflicting dependencies

Also in my source files some gatling imports are working fine, while the others are not resolved (red one):
import io.gatling.core.Predef._
import io.gatling.core.controller.inject.open.IncreasingUsersPerSecCompositeStep
import io.gatling.core.structure.ScenarioBuilder

I didn’t find any examples of how to configure gatling using Kotlin DSL. What am I missing here?

I didn’t change anything during my migration

That can’t possibly be true, because io.gatling.core.controller.inject.open.IncreasingUsersPerSecCompositeStep was renamed in Gatling 3.7 (it’s an internal, you’re not supposed to import it, use the parent OpenInjectionStep instead).

What I think you’ve done is that you’ve upgraded Gatling at the same time you’ve tried to migrate your build to Kotlin.

Regarding your first error Cannot access ‘io.gatling.gradle.JvmConfigurable$Trait$FieldHelper’ which is a supertype of ‘io.gatling.gradle.GatlingPluginExtension’. Check your module classpath for missing or conflicting dependencies, which version of gradle are you now using? We only support stable versions (not milestones of future major versions), from gradle 5 to 7, see https://gatling.io/docs/gatling/reference/current/extensions/gradle_plugin/#gradle-version.

Hi Stéphane,

What I think you’ve done is that you’ve upgraded Gatling at the same time you’ve tried to migrate your build to Kotlin.

You are absolutely right! I should’ve mention that and also check Gatling 7.3 migration guide. I applied your suggestion regarding imports and now I can successfully run my Simulations, DESPITE the error in the build.gradle.kts, which is still there.

which version of gradle are you now using?

As I opened this question, I was using Gradle 7.3.3. Now I also tried Gradle 7.0 and 6.9. But I was still getting this error with every Gradle version:
Cannot access ‘io.gatling.gradle.JvmConfigurable$Trait$FieldHelper’ which is a supertype of ‘io.gatling.gradle.GatlingPluginExtension’. Check your module classpath for missing or conflicting dependencies

Again, while I’m having this error in my build file, I can still successfully run the Simulations, which is really strange. Maybe this error is somehow related to IntelliJ IDEA? Or to the fact that I’m using Gatling in a Java project (so I have src/gatling/scala and src/main/java).

It would be great to get rid of this error. Do you know if there is any example of Gatling usage configured with build.gradle.kts?

No direct message please

If it works from your terminal, it means it’s an IntelliJ bug.
Try upgrading and reporting an issue on the IntelliJ bug tracker.

No direct message please

Sorry, I’m using Google Group for the first time, it’s not always clear how to do things here. :slight_smile:

Try upgrading and reporting an issue on the IntelliJ bug tracker.

Got you. Thank you for your help!