Gradle - Application Plugin


The Application plugin allows you to:

  • get all applications JARs as well as all of their transitive dependencies
  • add two startup scripts (one for UNIX-like operations systems and one for Windows) to run your application.
  • bundle all this material into a single ZIP or TAR file.

Shortcut of the maven assembly plugin

You don't get the possibility to bundle a JVM. See this page for an example on how to do it in pure gradle: How to bundle a jvm in a Gradle application targeting Windows, Linux or Macos



plugins {
    id 'java'        
    id 'application' 
mainClassName = 'package.mainClass'



In kotlin:

  • creating a script
val tabliStartScripts = tasks.register<CreateStartScripts>("tabliStartScripts") {
  outputDir = file("${buildDir}/scripts")
  applicationName = "applicationName"
  mainClassName = "com.example.Main"
  classpath = files(configurations.runtimeClasspath) + files(jar.archiveFileName)
 * Bug in windows: The input line is too long because of a big classpath
  (windowsStartScriptGenerator as TemplateBasedScriptGenerator).template = resources.text.fromFile("src/gradle/windowsStartScript.bat")


Discover More
Gradle - Distribution Plugin

A page the Distribution plugin that creates zip or tar archive and is mostly used in combination with the application plugin ...
How to bundle a jvm in a Gradle application targeting Windows, Linux or Macos

The gradle application plugin does not give the possibility to embed a jvm. This page shows how to do with a minimal knowledge of Gradle code

Share this page:
Follow us:
Task Runner