/gradle-capsule-plugin

A Gradle plugin for Capsule, the packaging and deployment tool for JVM apps.

Primary LanguageGroovyMIT LicenseMIT

gradle-capsule-plugin

A Gradle plugin for Capsule, the packaging and deployment tool for JVM apps.

Currently using capsule v1.0.3.

Adding the Plugin

This plugin requires Gradle 2.4 and above. Simply define the plugins at the top of your build script:

plugins {
  id "us.kirchmeier.capsule" version "1.0.2"
}

Gradle 2.0 to 2.3 were last supported with plugin version 1.0.0.

Quick Start

This plugin defines no tasks, but instead provides several task types for building your own tasks.

FatCapsule

The FatCapsule type embedds your application and all of its dependencies into one executable jar file:

task fatCapsule(type: FatCapsule) {
  applicationClass 'com.foo.HelloWorld'
}

Use it like so:

$ gradle fatCapsule

$ cd build/libs
$ ls
project.jar project-capsule.jar

$ java -jar project-capsule.jar
Hello World!

Without further configuration:

  • It obtains your project source from the jar task.
  • It will include all of the dependencies from the runtime dependency configuration.
  • It will have the capsule classifier in it's file name.

MavenCapsule

The MavenCapsule type embeds only your application. It will download dependencies when the user executes the capulse.

Under the hood, it uses the maven capsule, which caches dependencies after downloading them.

task mavenCapsule(type: MavenCapsule){
  applicationClass 'com.foo.CoolCalculator'
}

Without further configuration:

  • It obtains your project source from the jar task.
  • It will download at runtime all of the dependencies from the runtime dependency configuration.
  • It will have the capsule classifier in it's file name.

Configuration

Capsule allows you define attributes in your capsule to onfigure system properties, pass in arguments to your application, limit compatible JVM versions and more. You may configure these using the capsuleManifest block.

See also: Capsule: Manifest Attributes and Source: CapsuleManifest

task myCapsule(type:FatCapsule){
  applicationClass 'com.foo.FancyCalculator'

  capsuleManifest {
    systemProperties['log4j.configuration'] = 'log4j.xml'
    args = ['--very-fancy']
    minJavaVersion = '1.8.0'
  }
}

Documentation

More thorough documentation is available in DOCUMENTATION.md.

Support

If you run into any issues or have an enhancement idea, please file an issue.

If you have any questions, capsule or gradle related, please start a topic on the Google Group/Mailing List.