Hi,
I am unable to run an executable jar created from a graddle-spring-gatling project despite including all dependencies and simulations with in the jar. The jar will be then distributed to development teams to be able to execute the tests when needed by just including the jar under their Project build.gradle dependencies.
Here are the steps I followed:
1- create a spring-gradle based gatling project in eclipse.
2- added build.gradle javaexec task as follows to execute the simulations in eclipse. This steps runs as expected. simulation is executed and a default jar is created in build\libs folder
task runLoadTest(type: JavaExec) {
dependsOn testClasses
description = ‘Perf Test Running for Gatling Scripts’
classpath = sourceSets.main.runtimeClasspath
classpath += sourceSets.test.runtimeClasspath
classpath += sourceSets.test.resources
classpath += sourceSets.test.resources
def String gatlingDataFolder = “$project.rootDir.absolutePath/src/main/resources”
def String gatlingReportsFolder = “$project.buildDir.absolutePath/reports/gatling”
def String gatlingBodiesFolder = “$project.rootDir.absolutePath/src/main/resources”
def String gatlingSimulationsFolder = “$project.rootDir.absolutePath/src/main/scala”
//jvmArgs = [ “-Dgatling.core.directory.binaries=${sourceSets.test.output.classesDir.toString()}” ]
// Gatling application
main = “io.gatling.app.Gatling”
// Specify the simulation to run
args = [
“–simulation”, “DeviceTC1Simulation”,
“–results-folder”, “${buildDir}/reports/gatling-results”,
“–binaries-folder”, sourceSets.main.output.classesDir.toString(),
“–output-name”, “devicetc1simulation”,
“–bodies-folder”, sourceSets.main.resources.srcDirs.toList().first().toString() + “/gatling/bodies”, ]
}
//applicationDefaultJvmArgs = ["-Dgreeting.language=en"]
test.dependsOn runLoadTest
3- create the jar using the following code:
//create a single Jar with all dependencies
task fatJar(type: Jar) {
classifier ‘job’
destinationDir new File("$buildDir")
baseName = project.name + ‘-all’
from { configurations.runtime.collect {it.isDirectory() ? it : zipTree(it) }
configurations.compile.collect {it.isDirectory() ? it : zipTree(it) }
}
into(‘conf’){ from “$projectDir/conf” }
// into(‘lib’){ from “$projectDir/lib” }
into(‘classes’){ from “$buildDir/classes”
from “$projectDir/target” }
into(‘resources’){ from “$projectDir/src/main/resources” }
into(‘user-files’){ from “$projectDir/user-files” }
with jar
manifest {
attributes ‘Implementation-Title’: ‘Gradle Jar File testsuite’,
‘Implementation-Version’: version,
‘Main-Class’: ‘io.gatling.app.Gatling’
}
exclude ‘META-INF/.RSA’, 'META-INF/.SF’,‘META-INF/*.DSA’
}
4- open powershell, go to the build:–> libs–> locate the jar and run the following command to execute the jar
java -jar .\testsuite-jar-all-0.1.jar
5- error message:
The requested class DeviceTC1Simulation can not be found in the classpath or does not extends Simulation.
I looked into the gatling.class file under io.gatling.app package (included in gradle dependencies folder ) which refers to selection.class file for searching for simulations → which in turn looks for configurations in gatling-defaults.conf.
I made changes in the gatling-defaults to point to my local folder ( and a folder with in jar) as well as copied the user-files/simulations folder under the jar in all different locations but it’s still throwing the same error message as shown in point 5- above.