Skip to content

Commit 0ad4c9e

Browse files
author
emmanue1
committed
Minify JAR file, EXE file, OSX app and Linux packages
1 parent e1b178a commit 0ad4c9e

File tree

3 files changed

+72
-13
lines changed

3 files changed

+72
-13
lines changed

build.gradle

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ buildscript {
55
dependencies {
66
classpath 'com.netflix.nebula:gradle-ospackage-plugin:5.3.0' // RPM & DEB support
77
classpath 'edu.sc.seis.gradle:launch4j:2.4.4'
8+
classpath 'net.sf.proguard:proguard-gradle:6.1.0'
89
}
910
}
1011

@@ -49,7 +50,7 @@ cleanIdea.doFirst {
4950
followSymlinks = true
5051
}
5152

52-
// All in one JAR //
53+
// All in one JAR file //
5354
subprojects.each { subproject ->
5455
evaluationDependsOn(subproject.path)
5556
}
@@ -80,6 +81,8 @@ jar {
8081
'JD-Core-Version': project.jdCoreVersion
8182
}
8283
exclude 'META-INF/licenses/**', 'META-INF/maven/**', 'META-INF/INDEX.LIST'
84+
exclude '**/ErrorStrip_*.properties', '**/RSyntaxTextArea_*.properties', '**/RTextArea_*.properties'
85+
exclude '**/FocusableTip_*.properties', '**/RSyntaxTextArea_License.txt'
8386
duplicatesStrategy DuplicatesStrategy.EXCLUDE
8487
doFirst {
8588
// Create SPI directory
@@ -99,17 +102,31 @@ jar {
99102
}
100103
}
101104

105+
// Minify JAR file //
106+
task proguard(type: proguard.gradle.ProGuardTask, dependsOn: 'jar') {
107+
configuration 'src/proguard/resources/proguard.config.txt'
108+
injars jar.archivePath
109+
outjars 'build/libs/' + project.name + '-' + project.version + '-min.jar'
110+
libraryjars System.getProperty('java.home') + '/lib/rt.jar'
111+
}
112+
102113
// Java executable wrapper for Windows //
103114
launch4j {
115+
createExe.dependsOn 'proguard'
116+
104117
version = textVersion = project.version
105118
fileDescription = productName = 'JD-GUI'
106119
errTitle 'JD-GUI Windows Wrapper'
107120
copyright 'JD-GUI (C) 2008-2019 Emmanuel Dupuy'
108121
icon projectDir.path + '/src/launch4j/resources/images/jd-gui.ico'
122+
jar projectDir.path + '/' + proguard.outJarFiles[0]
109123
}
110124

111125
// Packages for Linux //
112126
ospackage {
127+
buildDeb.dependsOn 'proguard'
128+
buildRpm.dependsOn 'proguard'
129+
113130
license = file('LICENSE')
114131
maintainer 'Emmanuel Dupuy <[email protected]>'
115132
os LINUX
@@ -121,16 +138,16 @@ ospackage {
121138
url 'https://github.com/java-decompiler/jd-gui'
122139

123140
into '/opt/' + project.name
124-
from ('build/libs/') {
141+
from (proguard.outJarFiles[0]) {
125142
fileMode 0755
126143
}
127144
from ('src/linux/resources/') {
128145
fileMode 0755
129146
}
130147
from 'LICENSE', 'NOTICE', 'README.md'
131148

132-
postInstall 'cd /opt/'+ project.name+'; ln -s ./jd-gui-'+project.version+'.jar ./jd-gui.jar; xdg-icon-resource install --size 128 --novendor ./jd_icon_128.png jd-gui; xdg-desktop-menu install ./*.desktop'
133-
preUninstall 'cd /opt/'+ project.name+'; rm -f ./jd-gui.jar; rm -fr ./ext; xdg-desktop-menu uninstall ./*.desktop'
149+
postInstall 'cd /opt/' + project.name + '; ln -s ./' + file(proguard.outJarFiles[0]).name + ' ./jd-gui.jar; xdg-icon-resource install --size 128 --novendor ./jd_icon_128.png jd-gui; xdg-desktop-menu install ./*.desktop'
150+
preUninstall 'cd /opt/' + project.name + '; rm -f ./jd-gui.jar; rm -fr ./ext; xdg-desktop-menu uninstall ./*.desktop'
134151
}
135152

136153
// Distributions for OSX and Windows //
@@ -139,7 +156,8 @@ distributions {
139156
into('JD-GUI.app/Contents') {
140157
from('src/osx/resources') {
141158
include 'Info.plist'
142-
expand VERSION: project.version
159+
expand VERSION: project.version,
160+
JAR: file(proguard.outJarFiles[0]).name
143161
}
144162
}
145163
into('JD-GUI.app/Contents/MacOS') {
@@ -149,22 +167,23 @@ distributions {
149167
}
150168
}
151169
into('JD-GUI.app/Contents/Resources/Java') {
152-
from jar.archivePath
170+
from proguard.outJarFiles[0]
153171
}
154172
from 'LICENSE', 'NOTICE', 'README.md'
155173
}
156174
windows.contents {
157175
from 'build/launch4j/jd-gui.exe'
158176
from 'LICENSE', 'NOTICE', 'README.md'
159177
}
160-
}
161178

162-
installWindowsDist.dependsOn createExe
163-
windowsDistTar.dependsOn createExe
164-
windowsDistZip.dependsOn createExe
179+
installWindowsDist.dependsOn createExe
180+
windowsDistTar.dependsOn createExe
181+
windowsDistZip.dependsOn createExe
165182

166-
buildDeb.dependsOn jar
167-
buildRpm.dependsOn jar
183+
installOsxDist.dependsOn 'proguard'
184+
osxDistTar.dependsOn 'proguard'
185+
osxDistZip.dependsOn 'proguard'
186+
}
168187

169188
build.finalizedBy buildDeb
170189
build.finalizedBy buildRpm

src/osx/resources/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
<dict>
9696
<key>MainClass</key> <string>org.jd.gui.OsxApp</string>
9797
<key>JVMVersion</key> <string>1.8+</string>
98-
<key>ClassPath</key> <string>\$JAVAROOT/jd-gui-${VERSION}.jar</string>
98+
<key>ClassPath</key> <string>\$JAVAROOT/${JAR}</string>
9999
<key>WorkingDirectory</key> <string>\$JAVAROOT</string>
100100
<key>Properties</key>
101101
<dict>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# java -jar proguard.jar @proguard.config.txt
2+
3+
#-injars jd-gui-1.4.2.jar
4+
#-outjars jd-gui-1.4.2-minify.jar
5+
#-libraryjars C:/Program Files/Java/jre1.8.0_121/lib/rt.jar
6+
#-printmapping myapplication.map
7+
8+
-keep public class org.jd.gui.App {
9+
public static void main(java.lang.String[]);
10+
}
11+
12+
-keep public class org.jd.gui.OsxApp {
13+
public static void main(java.lang.String[]);
14+
}
15+
16+
-dontwarn com.apple.eawt.**
17+
-keepattributes Signature
18+
19+
-keep public interface org.jd.gui.api.** {*;}
20+
-keep public interface org.jd.gui.spi.** {*;}
21+
-keep public class * extends org.jd.gui.spi.*
22+
23+
-keep class org.fife.ui.rsyntaxtextarea.TokenTypes {public static final <fields>;}
24+
-keep class org.fife.ui.rsyntaxtextarea.DefaultTokenMakerFactory
25+
26+
-keep class org.fife.ui.rsyntaxtextarea.modes.CSSTokenMaker
27+
-keep class org.fife.ui.rsyntaxtextarea.modes.DtdTokenMaker
28+
-keep class org.fife.ui.rsyntaxtextarea.modes.HTMLTokenMaker
29+
-keep class org.fife.ui.rsyntaxtextarea.modes.JavaScriptTokenMaker
30+
-keep class org.fife.ui.rsyntaxtextarea.modes.JavaTokenMaker
31+
-keep class org.fife.ui.rsyntaxtextarea.modes.JsonTokenMaker
32+
-keep class org.fife.ui.rsyntaxtextarea.modes.JSPTokenMaker
33+
-keep class org.fife.ui.rsyntaxtextarea.modes.PlainTextTokenMaker
34+
-keep class org.fife.ui.rsyntaxtextarea.modes.PropertiesFileTokenMaker
35+
-keep class org.fife.ui.rsyntaxtextarea.modes.SQLTokenMaker
36+
-keep class org.fife.ui.rsyntaxtextarea.modes.XMLTokenMaker
37+
38+
-adaptresourcefilenames ErrorStrip.properties
39+
-adaptresourcefilenames RSyntaxTextArea.properties
40+
-adaptresourcefilenames FocusableTip.properties

0 commit comments

Comments
 (0)