forked from java-decompiler/jd-gui
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
231 lines (202 loc) · 6.93 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.guardsquare:proguard-gradle:7.6.0'
}
}
plugins {
id 'java'
id 'distribution'
id('edu.sc.seis.launch4j') version '3.0.6'
id('com.netflix.nebula.ospackage') version '11.10.0'
}
repositories {
mavenCentral()
maven {
url 'https://plugins.gradle.org/m2/'
}
mavenLocal()
}
// Common configuration //
version = '1.7.1'
ext.set('jdCoreVersion', '1.2.1')
allprojects {
apply plugin: 'eclipse'
apply plugin: 'idea'
tasks.withType(JavaCompile) {
sourceCompatibility = targetCompatibility = '1.8'
options.compilerArgs << '-Xlint:deprecation'
options.compilerArgs << '-Xlint:unchecked'
options.encoding = 'UTF-8'
}
repositories {
mavenCentral()
maven {
url 'https://plugins.gradle.org/m2/'
}
mavenLocal()
}
configurations {
provided
compile.extendsFrom provided
}
}
// All in one JAR file //
subprojects.each { subproject ->
evaluationDependsOn(subproject.path)
}
jar {
dependsOn subprojects.tasks['jar']
// Add SPI directory
def tmpSpiDir = file('build/tmp/spi')
from tmpSpiDir
// Add dependencies
def deps = []
subprojects.each { subproject ->
from subproject.sourceSets.main.output.classesDirs
from subproject.sourceSets.main.output.resourcesDir
deps += subproject.configurations.runtimeClasspath - subproject.configurations.provided
}
subprojects.each { subproject ->
deps -= subproject.jar.archivePath
}
deps = deps.unique().collect { it.isDirectory() ? it : zipTree(it) }
from deps
manifest {
attributes 'Main-Class': 'org.jd.gui.App',
'SplashScreen-Image': 'org/jd/gui/images/jd_icon_128.png',
'JD-GUI-Version': project.version,
'JD-Core-Version': project.jdCoreVersion
}
exclude 'META-INF/licenses/**', 'META-INF/maven/**', 'META-INF/INDEX.LIST'
exclude '**/ErrorStrip_*.properties', '**/RSyntaxTextArea_*.properties', '**/RTextArea_*.properties'
exclude '**/FocusableTip_*.properties', '**/RSyntaxTextArea_License.txt'
duplicatesStrategy DuplicatesStrategy.EXCLUDE
doFirst {
// Create SPI directory
tmpSpiDir.deleteDir()
def tmpSpiServicesDir = file(tmpSpiDir.path + '/META-INF/services')
tmpSpiServicesDir.mkdirs()
// Copy and merge SPI config files
subprojects.each { subproject ->
def servicesDir = file(subproject.sourceSets.main.output.resourcesDir.path + '/META-INF/services')
if (servicesDir.exists()) {
servicesDir.eachFile { serviceFile ->
def target = file(tmpSpiServicesDir.path + '/' + serviceFile.name)
target << serviceFile.text
}
}
}
}
}
// Minify JAR file //
task proguard(type: proguard.gradle.ProGuardTask) {
dependsOn 'jar'
configuration 'src/proguard/resources/proguard.config.txt'
injars jar.archivePath
outjars 'build/libs/' + project.name + '-' + project.version + '-min.jar'
libraryjars System.getProperty('java.home') + '/lib/rt.jar'
libraryjars System.getProperty('java.home') + '/jmods/'
}
// Java executable wrapper for Windows //
launch4j {
createExe.dependsOn 'proguard'
version = textVersion = project.version
fileDescription = productName = 'JD-GUI'
errTitle = 'JD-GUI Windows Wrapper'
copyright = 'JD-GUI (C) 2008-2019 Emmanuel Dupuy'
icon = projectDir.path + '/src/launch4j/resources/images/jd-gui.ico'
jarTask = proguard
bundledJrePath = '%JAVA_HOME%'
}
// Packages for Linux //
ospackage {
buildDeb.dependsOn 'proguard'
buildRpm.dependsOn 'proguard'
os LINUX
distribution 'focal'
customField 'Urgency', 'medium'
packageName project.name
packageDescription 'JD-GUI, a standalone graphical utility that displays Java sources from class files'
summary 'A Java Decompiler'
packageGroup 'java'
maintainer 'Quentin Lienhardt <[email protected]>'
version project.version
release '1'
customField 'Standards-Version', '4.6.2'
url 'https://github.com/QuentiumYT/jd-gui'
customField 'Vcs-Browser', 'https://github.com/QuentiumYT/jd-gui'
customField 'Vcs-Git', 'https://github.com/QuentiumYT/jd-gui.git'
license = file('LICENSE')
requires 'default-jre | default-jre-headless | openjdk-8-jre-headless | openjdk-11-jre-headless | openjdk-17-jre-headless'
into '/opt/' + project.name
from (proguard.outJarFiles[0]) {
fileMode 0755
}
from ('src/linux/resources/') {
fileMode 0755
}
from 'LICENSE', 'NOTICE', 'README.md'
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'
preUninstall 'cd /opt/' + project.name + '; rm -f ./jd-gui.jar; rm -fr ./ext; xdg-desktop-menu uninstall ./jd-gui.desktop'
afterEvaluate {
def outputDir = "build/distributions/${project.name}-${project.version}"
tasks.buildDeb.doLast {
copy {
from buildDeb.outputs.files
into outputDir
}
copy {
from 'src/linux/resources/debian'
into outputDir + '/debian'
}
}
}
}
// Distributions for OSX and Windows //
distributions {
osx.contents {
into('JD-GUI.app/Contents') {
from('src/osx/resources') {
include 'Info.plist'
expand VERSION: project.version,
JAR: file(proguard.outJarFiles[0]).name
}
}
into('JD-GUI.app/Contents/MacOS') {
from('src/osx/resources') {
include 'universalJavaApplicationStub'
fileMode 0755
}
}
into('JD-GUI.app/Contents/Resources/Java') {
from proguard.outJarFiles[0]
}
from 'LICENSE', 'NOTICE', 'README.md'
}
windows.contents {
from 'build/launch4j/jd-gui.exe'
from 'LICENSE', 'NOTICE', 'README.md'
}
installWindowsDist.dependsOn createExe
windowsDistTar.dependsOn createExe
windowsDistZip.dependsOn createExe
installOsxDist.dependsOn 'proguard'
osxDistTar.dependsOn 'proguard'
osxDistZip.dependsOn 'proguard'
}
// Task to run debuild -S after buildDeb
tasks.register('debuild', Exec) {
def debFolder = file("build/distributions/${project.name}-${project.version}")
if (debFolder.exists()) {
// Run 'debuild -S' in the correct folder
commandLine 'bash', '-c', 'yes | debuild -S'
workingDir debFolder.absolutePath
} else {
throw new GradleException("Deb folder ${debFolder} does not exist!")
}
}
build.finalizedBy buildDeb
build.finalizedBy buildRpm