2

Trying to import the Play Json Library with Gradle 7 to be used in Gatling Scala code plugin 3.8.3.2. It seems to be the finest tool to work Json in this context. I get this error not found: object play at the line where the import play.api.libs.json._ is.

Altought the Official Play Readme indicates that compile group: 'com.typesafe.play', name: 'play-json_2.13', version: -version- should be used, it does not work.

Any idea on how to make the Play Library available?

Stéphane LANDELLE
  • 6,076
  • 2
  • 10
  • 12
RicHincapie
  • 3,275
  • 1
  • 18
  • 30

2 Answers2

1

The key is the gatling configuration that generally is placed in gradle.build:

gatling {
  // WARNING: options below only work when logback config file isn't provided
  logLevel = 'WARN' // logback root level
  logHttp = 'NONE' // set to 'ALL' for all HTTP traffic in TRACE, 'FAILURES' for failed HTTP traffic in DEBUG
  enterprise {
    // Enterprise Cloud (https://cloud.gatling.io/) configuration reference: https://gatling.io/docs/gatling/reference/current/extensions/gradle_plugin/#working-with-gatling-enterprise-cloud
    // Enterprise Self-Hosted configuration reference: https://gatling.io/docs/gatling/reference/current/extensions/gradle_plugin/#working-with-gatling-enterprise-self-hosted
  }
}

It is a default Gatling configuration to which you must refer when using Play's Framework Readme snippet, like this:

dependencies {
  gatling 'com.google.code.gson:gson:2.8.0'
  gatlingImplementation 'org.apache.commons:commons-lang3:3.4'
  gatlingRuntimeOnly 'cglib:cglib-nodep:3.2.0'
}

So, in order to include the dependencies, you need to prepend gatling to the code provided in the Play Readme.

Here's my working gradle.build file:

plugins {
    id 'scala'
    id 'io.gatling.gradle' version '3.8.3.2'
}

gatling {
  logLevel = 'WARN' // logback root level
  logHttp = 'NONE' // set to 'ALL' for all HTTP traffic in TRACE, 'FAILURES' for failed HTTP traffic in DEBUG
}

repositories {
  mavenCentral()
}

dependencies {
  // https://mvnrepository.com/artifact/com.typesafe.play/play-json
  gatlingImplementation group: 'com.typesafe.play', name: 'play-json_2.13', version: '2.9.2'
}
RicHincapie
  • 3,275
  • 1
  • 18
  • 30
0

For Gatling scala specific

Updating the build.gradle file with gatling group dependency solved the issue

dependencies { gatling group: 'com.typesafe.play', name: 'play-json_2.13', version: '2.9.3' }