diff --git a/gradle/gradle-fat-jar/build.gradle b/gradle/gradle-fat-jar/build.gradle new file mode 100644 index 0000000000..6afad80652 --- /dev/null +++ b/gradle/gradle-fat-jar/build.gradle @@ -0,0 +1,41 @@ +buildscript { + repositories { + jcenter() + } + dependencies { + classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.1' + } +} + +apply plugin: 'java' +apply plugin: 'com.github.johnrengelman.shadow' + +repositories { + mavenCentral() +} + +jar { + manifest { + attributes "Main-Class": "com.baeldung.fatjar.Application" + } + + from { + configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } + } +} + + +task customFatJar(type: Jar) { + manifest { + attributes 'Main-Class': 'com.baeldung.fatjar.Application' + } + baseName = 'all-in-one-jar' + from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } + with jar +} + + +dependencies{ + compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25' + compile group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.25' +} \ No newline at end of file diff --git a/gradle/gradle-fat-jar/src/main/java/com/baeldung/fatjar/Application.java b/gradle/gradle-fat-jar/src/main/java/com/baeldung/fatjar/Application.java new file mode 100644 index 0000000000..470d89c332 --- /dev/null +++ b/gradle/gradle-fat-jar/src/main/java/com/baeldung/fatjar/Application.java @@ -0,0 +1,16 @@ +package com.baeldung.fatjar; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +public class Application { + + static final Logger logger = LoggerFactory.getLogger(Application.class); + + public static void main(String[] args) { + + logger.info("Hello at Baeldung!"); + } + +} \ No newline at end of file