From 87eefe93663f523284f629ba853b5bafb4747064 Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 19 Mar 2019 13:11:52 +0200 Subject: [PATCH] gradle: Add full fat jar build option --- README.md | 11 +++++++++++ build.gradle | 20 ++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/README.md b/README.md index 8c62d63..2057b15 100644 --- a/README.md +++ b/README.md @@ -32,3 +32,14 @@ dependencies { } I've also listed an example build.gradle with this repo. + +# Compiling as JAR file +DemiBOT can also be compiled as a standalone JAR file. + +However, if you decide to go this route, you will need to supply the ffmpeg, wget and nircmd binaries alongside the JAR file. + +First, install [Gradle 5.2.1](https://gradle.org/next-steps/?version=5.2.1&format=bin) and add Gradle's bin folder into your PATH environment variable. + +Then, run this command to build your JAR file: `gradle fatjar` + +The artifacts can then be copied from the `build/libs` folder. \ No newline at end of file diff --git a/build.gradle b/build.gradle index ece466f..d9273c0 100644 --- a/build.gradle +++ b/build.gradle @@ -21,3 +21,23 @@ version '1.0-SNAPSHOT' apply plugin: 'java' sourceCompatibility = 1.8 + +jar { + manifest { + attributes("Manifest-Version": "1.0", "Main-Class": "pro.loonatic.demibot.Main"); + } +} + +task fatJar(type: Jar) { + manifest.from jar.manifest + classifier = 'all' + from { + configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) } + } + { + exclude "META-INF/*.SF" + exclude "META-INF/*.DSA" + exclude "META-INF/*.RSA" + } + with jar +} \ No newline at end of file