Table of Contents

Gradle - Application Plugin

About

The Application plugin allows you to:

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

Example

Basic

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

where:

StartScript

In kotlin:

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
 */
tasks.withType<CreateStartScripts>{
  (windowsStartScriptGenerator as TemplateBasedScriptGenerator).template = resources.text.fromFile("src/gradle/windowsStartScript.bat")
}

Documentation