forked from java-decompiler/jd-gui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
190 lines (166 loc) · 4.95 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
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.netflix.nebula:gradle-ospackage-plugin:2.2.6'
classpath 'org.spockframework:spock-core:1.0-groovy-2.3'
}
}
apply plugin: 'java'
apply plugin: 'distribution'
apply plugin: 'nebula.os-package'
// Common configuration //
allprojects {
version='1.2.0'
apply plugin: 'eclipse'
apply plugin: 'idea'
tasks.withType(JavaCompile) {
sourceCompatibility = '1.7'
targetCompatibility = '1.7'
}
tasks.withType(GroovyCompile) {
sourceCompatibility = '1.7'
targetCompatibility = '1.7'
}
repositories {
mavenCentral()
maven {
url 'https://raw.github.com/java-decompiler/mvn-repo/master'
}
}
configurations {
provided
compile.extendsFrom provided
}
}
// 'cleanIdea' task extension //
cleanIdea {
file(project.name + '.iws').delete()
ant.delete(dir: 'out')
}
// All in one JAR //
subprojects.each { subproject ->
evaluationDependsOn(subproject.path)
}
jar {
dependsOn subprojects.tasks['jar']
def deps = []
subprojects.each { subproject ->
from subproject.sourceSets.main.output.classesDir
from subproject.sourceSets.main.output.resourcesDir
deps += subproject.configurations.runtime - subproject.configurations.provided
}
subprojects.each { subproject ->
deps -= subproject.jar.archivePath
}
deps = deps.unique().collect { it.isDirectory() ? it : zipTree(it) }
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': '0.7.1'
}
from deps
exclude 'META-INF/services/jd.gui.spi.*'
duplicatesStrategy DuplicatesStrategy.EXCLUDE
doFirst {
// Create temporary directory
def tmpSpiDir = file('build/tmp/spi')
tmpSpiDir.deleteDir()
tmpSpiDir.mkdirs()
// Copy and merge SPI config files
subprojects.each { subproject ->
def servicesDir = file(subproject.sourceSets.main.output.resourcesDir.path + File.separator + 'META-INF' + File.separator + 'services')
if (servicesDir.exists()) {
servicesDir.eachFile { source ->
def target = file(tmpSpiDir.path + File.separator + source.name)
target << source.text
}
}
}
// Add to JAR file
into('META-INF/services') {
from tmpSpiDir
}
}
}
// Windows wrapper configuration to generate "jd-gui.exe" //
task launch4jConfig(type: Copy) {
from 'src/launch4j/resources/config/launch4j.xml'
into 'build/launch4j'
expand(
JAR_FILE: project.jar.archivePath,
VERSION: project.version,
ICON: file('src/launch4j/resources/images/jd-gui.ico')
)
}
task launch4j(type: Exec, dependsOn: [':jar', ':launch4jConfig']) {
def launch4jCfg = file('build/launch4j/launch4j.xml')
def launch4jExe = System.properties['LAUNCH4J_HOME'] + '/launch4j.exe'
onlyIf {
System.properties['os.name'].startsWith('Windows')
}
if (new File(launch4jExe).exists()) {
commandLine 'cmd', '/c', launch4jExe, launch4jCfg
} else {
commandLine 'cmd', '/c', 'echo', 'OFF'
doLast {
errorOutput.println "ERROR: 'LAUNCH4J_HOME' not defined or invalid. Launch4j (http://launch4j.sourceforge.net) is required to generare 'jd-gui.exe'."
}
}
}
// Distributions for OSX and Windows //
task copyAndReplaceVariablesInInfoPlist(type: Copy) {
from 'src/osx/resources/Info.plist'
into 'build/tmp/distributions/osx'
expand(
VERSION: project.version
)
}
distributions {
osx.contents {
into('JD-GUI.app/Contents') {
from 'build/tmp/distributions/osx'
}
into('JD-GUI.app/Contents/Resources/Java') {
from jar.archivePath
}
from 'LICENSE', 'NOTICE', 'README.md'
doFirst {
ant.chmod(file:'src/osx/dist/JD-GUI.app/Contents/MacOS/universalJavaApplicationStub.sh', perm:'+x')
}
}
windows.contents {
from 'build/launch4j/jd-gui.exe'
from 'LICENSE', 'NOTICE', 'README.md'
}
}
ospackage {
packageName = project.name
description = 'A Java Decompiler'
os = LINUX
url = 'https://github.com/java-decompiler/jd-gui'
license = file('LICENSE')
into '/opt/' + project.name
from ('build/libs/') {
fileMode = 0755
}
from ('src/linux/resources/') {
fileMode = 0755
}
from ('app/src/main/resources/images/jd_icon_128.png') {
fileMode = 0755
}
from 'LICENSE', 'NOTICE', 'README.md'
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'
preUninstall 'cd /opt/'+ project.name+'; rm -f ./jd-gui.jar; xdg-desktop-menu uninstall ./*.desktop'
}
installOsxDist.dependsOn jar, copyAndReplaceVariablesInInfoPlist
osxDistTar.dependsOn jar, copyAndReplaceVariablesInInfoPlist
osxDistZip.dependsOn jar, copyAndReplaceVariablesInInfoPlist
installWindowsDist.dependsOn launch4j
windowsDistTar.dependsOn launch4j
windowsDistZip.dependsOn launch4j
buildDeb.dependsOn jar
buildRpm.dependsOn jar