Gradle Fat Jar


Overloading existing Jar functionality

mainClassName = "com.company.application.Main"

jar {
  manifest { 
    attributes "Main-Class": "$mainClassName"
  }  

  from {
    configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
  }
}

Separate fatJar task

task fatJar(type: Jar) {
  baseName = project.name + '-all'
  from {
    configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
  }
  with jar
}

Source: http://stackoverflow.com/questions/4871656/using-gradle-to-build-a-jar-with-dependencies

Posted on Fri Apr 08 01:10:45 EDT 2016 by Subhash Chandran
gradle java build jar