-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathbuild.gradle
303 lines (246 loc) · 8.89 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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
apply plugin: 'java'
apply plugin: 'eclipse'
configurations {
pluginjar
pluginjar_linux_x86
pluginjar_linux_x86_64
pluginjar_windows_x86
pluginjar_windows_x86_64
pluginjar_macosx_x86
pluginjar_macosx_x86_64
}
repositories {
mavenCentral()
maven {
url "http://maven-eclipse.github.io/maven"
}
}
project.ext {
pluginId = "gui"
pluginName = "GUI"
pluginVersion = "0.4.9-alpha"
pluginDebianVersion = "1"
pluginDate = new Date()
pluginAppMinVersion = "0.4.5-alpha"
pluginRelease = rootProject.ext.applicationRelease
pluginConflictsWith = ""
pluginVersionSnapshot = rootProject.ext.applicationVersionSnapshot
pluginVersionFull = "${pluginVersion}${pluginVersionSnapshot}"
pluginNeedsOperatingSystemAndArchitecture = true
}
// Include tasks ///////////////////////////////////////////////////////////////
apply from: 'core/gradle/gradle/plugins.jar.gradle'
apply from: 'core/gradle/gradle/plugins.debian.gradle'
// Task to determine SWT library ///////////////////////////////////////////////
public String getOs() {
return (project.ext.has("pluginOperatingSystem") && !"all".equals(project.ext.pluginOperatingSystem)) ? project.ext.pluginOperatingSystem : System.getProperty("os.name").toLowerCase().split()[0]
}
public String getArch() {
String arch = (project.ext.has("pluginArchitecture") && !"all".equals(project.ext.pluginArchitecture)) ? project.ext.pluginArchitecture : System.getProperty("os.arch")
return arch.substring(arch.length()-2, arch.length())
}
public String getOsArch(String os, String arch) {
return os + "_" + arch
}
public String getOsArch() {
return getOsArch(getOs(), getArch())
}
public String getSwtLibrary(String os, String arch) {
String osArch = getOsArch(os, arch)
String swtJarName;
switch(osArch) {
case 'windows_86': swtJarName = 'win32.win32.x86'; break;
case 'windows_64': swtJarName = 'win32.win32.x86_64'; break;
case 'linux_86': swtJarName = 'gtk.linux.x86'; break;
case 'linux_64': swtJarName = 'gtk.linux.x86_64'; break;
case 'mac_64': case 'macosx_64': swtJarName = 'cocoa.macosx.x86_64'; break;
case 'mac_86': case 'macosx_86': swtJarName = 'cocoa.macosx'; break;
default: throw new Exception('Unknown OS');
}
return swtJarName;
}
public String getSwtLibrary() {
return getSwtLibrary(getOs(), getArch())
}
// GUI Dependencies ////////////////////////////////////////////////////////////
dependencies {
compile project(":syncany-lib")
compile project(":syncany-util")
compile project(":syncany-cli")
compile "commons-net:commons-net:2.2"
compile "commons-beanutils:commons-beanutils:1.9.0"
compile "org.eclipse.swt:org.eclipse.swt.${getSwtLibrary()}:4.4"
compile "org.apache.httpcomponents:httpclient:4.3.4"
compile "org.simpleframework:simple-xml:2.7.1"
compile "com.google.guava:guava:15.0"
compile "commons-io:commons-io:2.4"
compile "org.ocpsoft.prettytime:prettytime:3.2.5.Final"
pluginjar "commons-net:commons-net:2.2"
pluginjar "commons-beanutils:commons-beanutils:1.9.0"
pluginjar "org.ocpsoft.prettytime:prettytime:3.2.5.Final"
pluginjar_windows_x86 "org.eclipse.swt:org.eclipse.swt.win32.win32.x86:4.4"
pluginjar_windows_x86_64 "org.eclipse.swt:org.eclipse.swt.win32.win32.x86_64:4.4"
pluginjar_linux_x86 "org.eclipse.swt:org.eclipse.swt.gtk.linux.x86:4.4"
pluginjar_linux_x86_64 "org.eclipse.swt:org.eclipse.swt.gtk.linux.x86_64:4.4"
pluginjar_macosx_x86 "org.eclipse.swt:org.eclipse.swt.cocoa.macosx:4.4"
pluginjar_macosx_x86_64 "org.eclipse.swt:org.eclipse.swt.cocoa.macosx.x86_64:4.4"
testCompile project(path: ":syncany-lib", configuration: "tests")
testCompile project(path: ":syncany-util", configuration: "tests")
testCompile "junit:junit:4.9"
}
// GUI-specific Debian Tasks ///////////////////////////////////////////////////
task pluginDebianGuiPrepare(dependsOn: [pluginDebianClean, pluginJar]) {
doLast {
copy {
from files("gradle/debian/syncany-plugin-gui")
into file("build/debian/syncany-plugin-gui/debian")
}
copy {
from file("gradle/debian/syncany-plugin-gui/debian")
include "control"
expand([
pluginAppMinVersion: "${pluginAppMinVersion}",
pluginDebianArchitecture: "${pluginDebianArchitecture}",
pluginMiscDepends: "\${misc:Depends}" // Dirty hack to keep ${misc:Depends} debian variable
])
into file("build/debian/syncany-plugin-gui/debian/debian")
}
copy {
from files("build/libs")
into file("build/debian/syncany-plugin-gui/debian/usr/share/syncany/lib")
}
exec {
workingDir file(".")
commandLine(
rootProject.file("gradle/debian/makechangelog.pl"),
"syncany-plugin-gui",
"${pluginDebianDistribution}",
"${pluginDebianVersionFull}",
file("CHANGELOG.md"),
file("build/debian/syncany-plugin-gui/debian/debian/changelog")
)
}
}
}
task pluginDebianGuiDeb(dependsOn: [pluginDebianGuiPrepare]) {
doLast {
exec {
workingDir file("build/debian/syncany-plugin-gui/debian")
commandLine "debuild -i -us -uc -b -a${pluginDebianArchitecture}".split()
}
if (!project.ext.has('pluginDebDontCopyToUpload')) {
copy {
from files("build/debian/syncany-plugin-gui")
include "*.deb"
into file("build/upload")
}
}
}
}
// Windows Installer ///////////////////////////////////////////////////////////
task cleanInstallAndLibDirs(type: Delete) {
delete files("build/install")
delete files("build/libs")
}
rootProject.installApp.mustRunAfter = [cleanInstallAndLibDirs] // Dirty hack to fix order in dependsOn
task exeWithGui(dependsOn: [cleanInstallAndLibDirs, rootProject.installApp, pluginJar]) << {
String applicationArchitecuresAllowed = (pluginArchitecture == "x86") ? "x86" : "x64"
String applicationArchitecureSuffix = pluginArchitecture;
def innoSetupDir = new File("${buildDir}/innosetup")
delete innoSetupDir
innoSetupDir.mkdir();
copy {
from("${rootProject.projectDir}/build/install")
into("${buildDir}/install")
}
copy {
from("${rootProject.projectDir}/gradle/innosetup/setup-icon.ico")
into("${buildDir}/install/syncany")
rename("setup-icon.ico", "syncany.ico")
}
copy {
from("${buildDir}/libs")
include("*.jar")
into("${buildDir}/install/syncany/lib")
}
copy {
from("${rootProject.projectDir}/gradle/innosetup/setup-left.bmp")
from("${rootProject.projectDir}/gradle/innosetup/setup-top.bmp")
from("${rootProject.projectDir}/gradle/innosetup/setup-info-before.rtf")
from("${rootProject.projectDir}/gradle/innosetup/setup-info-after.rtf")
from("${rootProject.projectDir}/gradle/innosetup/setup-icon.ico")
from("${rootProject.projectDir}/gradle/innosetup/modpath.iss")
from("${rootProject.projectDir}/gradle/innosetup/code.iss")
into(innoSetupDir)
}
copy {
from("gradle/innosetup/launcher.vbs")
into("${buildDir}/install/syncany/bin")
}
copy {
from("gradle/innosetup/setup-gui.iss.skel")
rename("setup-gui.iss.skel", "setup-gui.iss")
expand([
applicationVersion: "${applicationVersion}",
applicationVersionFull: "${applicationVersionFull}",
applicationArchitecuresAllowed: "${applicationArchitecuresAllowed}",
applicationArchitecureSuffix: "${applicationArchitecureSuffix}"
])
into(innoSetupDir)
}
exec {
workingDir projectDir
commandLine "iscc ${innoSetupDir}/setup-gui.iss".split()
}
if (!project.ext.has('pluginExeDontCopyToUpload')) {
copy {
from files("${buildDir}/innosetup")
include "*.exe"
into file("${buildDir}/upload")
}
}
}
// OSX /////////////////////////////////////////////////////////////////////////
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.github.cr0:gradle-macappbundle-plugin:3.1.0'
}
}
apply plugin: 'com.github.cr0.macappbundle'
macAppBundle {
appName = "Syncany"
appCategory = "public.app-category.utilities"
icon = "gradle/icon/syncany.icns"
agent = true
version = applicationVersionFull
shortVersion = applicationVersion
mainClassName = "org.syncany.cli.GuiCommand"
bundleJRE = false
bundleExecutable = "Syncany"
bundleIdentifier = "org.syncany.osx"
bundleCopyright = "(C) Copyright 2011-2015 Philipp Heckel"
bundleExtras.put("NSHighResolutionCapable", "true")
javaProperties.put("file.encoding", "utf-8")
javaXProperties.add("mx2048M")
javaXProperties.add("startOnFirstThread")
javaClassPath.add("/Users/\$CURRENT_USER/.config/syncany/plugins/lib/*")
archiveName = "syncany-${applicationVersionFull}-${pluginArchitecture}.app"
archiveOutputDir = "upload"
}
// GUI Tasks ///////////////////////////////////////////////////////////////////
task(runGui, dependsOn: 'classes', type: JavaExec) {
main = "org.syncany.cli.GuiCommand"
// SWT need -XStartOnFirstThread to run on OSX
jvmArgs = getOs().startsWith("mac") ? ['-XstartOnFirstThread'] : []
classpath = sourceSets.main.runtimeClasspath
}
task(runGuiAppIndicator, dependsOn: 'classes', type: JavaExec) {
main = "org.syncany.cli.GuiCommand"
args = ["--tray", "appindicator"]
// SWT need -XStartOnFirstThread to run on OSX
jvmArgs = getOs().startsWith("mac") ? ['-XstartOnFirstThread'] : []
classpath = sourceSets.main.runtimeClasspath
}