We are writing Gatling simulations using Eclipse. We are using a project structure as described in this wiki page: https://github.com/excilys/gatling/wiki/Development-environment
We would like to package the whole project as a stand alone jar (with dependencies) and run it everywhere we need it.
We are trying to package such a jar with maven-assembly-plugin but we are facing an error when running a simple ‘java -jar thehugejar-jar-with-dependencies.jar’:
Exception in thread “main” java.lang.RuntimeException: Can’t find the jar matching (.*compiler-interface-\d+.\d+.\d±sources.jar)$
Gatling 1.5.2, Maven 3.0.4…
Could you please help us to solve this issue?
It won’t work, sorry.
We depend on Zinc (Scala incremental compiler) for compiling simulations on the fly, and you have to feed it java.io.Files for its dependencies.
An alternative solution that might work is to use the appassembler-maven-plugin in combination with the maven-assembly-plugin to create a zip file with all the original jar-dependencies. Appassembler will create a script to run Engine.class with the necessary classpath. You wouldn’t be able to run java -jar uberjar.jar but unzip simulation.zip && simulation/bin/simulation.sh isn’t that bad either.
I wasn’t aware of this appassembler-maven-plugin, thanks for the pointer Frode.
We’ll rework Gatling’s outer layer in M4 so that you can build this kind of standalone jar (this will be part of our work on our SBT plugin).
Note that you’ll have to:
ship pre-compiled simulations in order to by pass Zinc
force from the command line the one simulation you want to run in order to bypass Simulations discovery
David, would this meet your needs (won’t be developed anytime soon though, I fear)?
In case someone is still interested, I was able to run packaged simulations by creating a run.sh in a maven assembly which does: java -Dgatling.core.disableCompiler=true -Dgatling.core.simulationClass=simulations.Base -cp .:lib -jar simulations.jar
The jar packaging is standard maven packaging, with scala source compiled with scala-maven-plugin.
But I can’t figure out how to make discovery work at all. (2.0.0-M3a), hardcoding simulation names is what I do for now.
Thanks for your feedback.
Gatling’s discovery only works when compiling from Gatling: we just scan the directory containing the generated classes, searching for classes extending Simulation. We don’t want to scan the whole classpath, ending up loading the whole of it into the ClassLoader.
Very interestin. Can u tell me something more on the procedure?
Sure, give me some time and I’ll write a blog post about it.
can you please write detailed instruction how you achieved this?
I tried to find some example how to do this, but I didn’t.
We would want to create a stand alone jar for a gatling project. Can somebody help with steps.
Adrian - Thanks for the pointer. This worked like a charm