Build jar with Gradle

I need to build a jar using gradle so that i can include this jar as dependency on another project. I have few classes written using gatling, when i try to build jar using gradle.

Generated Jar has only following files:


Below is my project structure

  • resources
  • library files
  • resources
  • resources

i am using gatling Gradle plugin:
plugins {
// The following line allows to load io.gatling.gradle plugin and directly apply it
id ‘io.gatling.gradle’ version ‘3.5.1’


Hi Girish,

I believe this is because the gradle gatling plugin uses a different source set. If I’m not mistaken by default the “main” sourceSet is included into the JAR.
You should be able to include the output from the gatling sourceSet into your JAR by adding something like the following code snippet into your build.gradle:
jar {
from sourceSets.gatling.output

However if the “library files” you are referring to are external dependencies like jars, you probabaly rather want to have a “FatJar” that contains all required dependencies.

Hope this helps :slight_smile:

Julius that worked, Thanks a lot.