Created
December 3, 2017 05:52
-
-
Save kimhanjoon/7423bcc8e062832fbb25527c764f3e2a to your computer and use it in GitHub Desktop.
spring-boot-gradle-proguard-excutable-jar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
buildscript { | |
repositories { | |
mavenCentral() | |
} | |
dependencies { | |
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.5.8.RELEASE") | |
classpath("net.sf.proguard:proguard-gradle:5.3.3") | |
} | |
} | |
apply plugin: 'java' | |
apply plugin: 'org.springframework.boot' | |
sourceCompatibility = 1.8 | |
targetCompatibility = 1.8 | |
compileJava.options.encoding = 'UTF-8' | |
compileTestJava.options.encoding = 'UTF-8' | |
springBoot { | |
executable = true | |
} | |
def proguardJarPath = jar.archivePath.absolutePath.replace(".jar", "-proguard.jar") | |
task proguard(type: proguard.gradle.ProGuardTask, dependsOn: jar) { | |
configuration "proguard.conf" | |
injars jar.archivePath.absolutePath | |
outjars proguardJarPath | |
libraryjars "${System.getProperty('java.home')}/lib/rt.jar" | |
libraryjars project.configurations.compile | |
} | |
task proguardJar(type: Jar, overwrite: true, dependsOn: proguard) { | |
from zipTree(proguardJarPath) | |
} | |
bootRepackage { | |
withJarTask = proguardJar | |
} | |
repositories { | |
mavenCentral() | |
} | |
dependencies { | |
compile "org.springframework.boot:spring-boot-starter-web" | |
} |
@mikeshi80 did you find a way to get it working with spring boot 2.0?
@ricmf @mikeshi80 any hope? :)
Works with Spring Boot 1.5.22 but I had to delete the "overwrite: true" argument to proguardJar
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great, but it does not work in Spring Boot 2.0 since Gradle plugin API has changed a lot.