forked from google/sagetv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
371 lines (314 loc) · 10.6 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
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
import org.gradle.internal.os.OperatingSystem
plugins {
id "com.jfrog.bintray" version "1.3.1"
}
apply plugin: "java"
apply plugin: "eclipse"
apply plugin: "idea"
// Globals
ext {
sageBuildDir = 'buildoutput'
stageBuildDir = 'build'
appName = 'SageTV'
sageJarName = 'Sage.jar'
sageJarDestinationDir = 'build/release/'
sageReleaseDestinationDir = 'build/serverrelease/'
miniJarName = 'MiniClient.jar'
miniJarDestinationDir = 'build/minirelease/'
miniclientReleaseDestinationDir = 'build/clientrelease/'
// This the version of JOGL we are using
jogampVer = '2.3.1'
arch=Integer.parseInt(System.getProperty('sun.arch.data.model')); // 32 or 64
releaseBuild = (System.getProperty("SAGETV_RELEASE", System.getenv("SAGETV_RELEASE")) != null)
snapshotId = (releaseBuild?"":("SNAPSHOT-"+ new java.text.SimpleDateFormat("yyyyMMdd_hhmm").format(new java.util.Date() )))
// SageTV version info as per Version.java
// eventually version should be sourced from another location, but until then
// we can look it up this way
versionText = new File('java/sage/Version.java').text
majorVersion = (versionText =~ /MAJOR_VERSION = ([0-9]+)/)[0][1]
minorVersion = (versionText =~ /MINOR_VERSION = ([0-9]+)/)[0][1]
microVersion = (versionText =~ /MICRO_VERSION = ([0-9]+)/)[0][1]
buildVersionText = new File('java/sage/SageConstants.java').text
buildVersion = (buildVersionText =~ /BUILD_VERSION = ([0-9]+)/)[0][1]
baseVersion = "${majorVersion}.${minorVersion}.${microVersion}.${buildVersion}"
versionArch = "${baseVersion}_" + (arch==64 ? 'amd64' : 'i386')
}
version = baseVersion
// Just printing out the SAGETV build version for informational purposes
System.out.println("SAGETV VERSION ${versionArch}");
// set gradle's buildDir to something other than the default 'build', or
// we'll end up deleting EVERYTHING in 'build' when we ./gradlew clean
buildDir = new File(rootProject.projectDir, sageBuildDir);
repositories {
mavenCentral()
jcenter()
}
configurations {
miniclient.extendsFrom compile
}
// Maybe someday we'll target >1.5 (hopefully)
targetCompatibility = 1.5
sourceCompatibility = 1.5
compileJava {
options.warnings = false
//options.incremental = true
//options.debugOptions.debugLevel = "source,lines,vars"
}
sourceSets {
// main configuration for the Sage.jar
main {
java {
srcDirs = [
'java',
'third_party/Javolution/java',
'third_party/jcraft/java',
'third_party/jtux/java',
'third_party/MetadataExtractor/java',
'third_party/Ogle/java',
'third_party/RSSLIB4J/java',
'third_party/SingularSys/java'
]
excludes = [
// mac files, need to be on a Mac to build these
'sage/QuartzSageRenderer.java',
'sage/miniclient/QuartzGFXCMD.java',
// does not appear to compile, maybe an older file??
'sage/JOGLSageRenderer.java'
]
}
}
// Miniclient configuration only specifies the Minimal files and
// javac will find and compile all the dependencies based on the
// main configuration being the sourcepath reference
miniclient {
java {
srcDirs = [
'java',
]
includes = [
'sage/miniclient/MiniClient.java',
'sage/PowerManagement.java',
'sage/UIUtils.java',
'sage/miniclient/OpenGLGFXCMD.java'
]
}
}
}
dependencies {
compile files(
'third_party/UPnPLib/sbbi-upnplib-1.0.3.jar',
'third_party/Oracle/vecmath.jar',
'third_party/Lucene/lucene-core-3.6.0.jar',
'third_party/JCIFS/jcifs-1.1.6.jar',
)
compile 'com.apple:AppleJavaExtensions:1.4'
compile "org.jogamp.jogl:jogl-all:$jogampVer"
compile "org.jogamp.gluegen:gluegen-rt-main:$jogampVer"
// Miniclient dependendencies for compiling
miniclientCompile "org.jogamp.gluegen:gluegen-rt-main:$jogampVer"
miniclientCompile "org.jogamp.jogl:jogl-all-main:$jogampVer"
}
/**
* this is sort of a hack... normally we'd never set the -sourcepath on a java compile
* but, sagetv usues this hack to selectively compile and include files into each jar
* so we'll mimic the behaviour here until we need to do something different
*/
tasks.withType(JavaCompile) {
//options.fork=true
options.compilerArgs << "-sourcepath" << sourceSets.main.java.srcDirs.join(":")
}
task miniclient(type:JavaCompile) << {
}
// remove the Sage.jar before updating it
task cleanSageJar(type: Delete) {
delete sageJarDestinationDir+'/'+sageJarName
}
// build the Sage.jar
task sageJar(type: Jar) {
description = 'Build the Sage.jar'
archiveName = sageJarName
destinationDir = file(sageJarDestinationDir)
from files(sourceSets.main.output.classesDir) {
// exclude the Mac stuff for now
excludes = [
'sage/miniclient/**',
'sage/MacAboutBox*',
'sage/MacApplicationListener.class',
'sage/QuartzRendererView.class'
]
}
from files(sourceSets.main.output.resourcesDir)
// Add in images and localization files
from 'images/SageTV/'
from ('i18n') {
include '*.properties'
}
doLast {
println "$sageJarName created in $sageJarDestinationDir"
}
}
// clean miniclient jar
task cleanMiniJar(type: Delete) {
delete miniJarDestinationDir+'/'+miniJarName
}
// build miniclient jar
task miniclientJar(type: Jar) {
archiveName = miniJarName
destinationDir = file(miniJarDestinationDir)
from files(sourceSets.miniclient.output.classesDir) {
}
// Add in images and localization files
from 'images/MiniClient/'
doLast {
println "$miniJarName created in $miniJarDestinationDir"
}
}
// LinuxOnly: calls a unix script and ensures that JDK_HOME is set
def linuxScript(String script) {
String jdk="$System.env.JDK_HOME"
if (jdk==null || jdk==""||jdk=='null') throw new GradleException('JDK_HOME must be set to the JDK installation directory');
File jdkInclude = new File(new File(jdk),"include");
if (!jdkInclude) throw new GradleException('JDK_HOME does not point to a valid JDK home: ' + jdk);
exec {
workingDir = 'build'
executable script
environment JDK_HOME: jdk
}
}
// currently Linux Only -- Need to look at supporting Windows
task (linuxMiniClientRelease) << {
if (!OperatingSystem.current().isLinux()) {
throw new GradleException('This target is not supported on Windows, yet.');
}
if (!(new File('build/so/libSage.so')).exists()) {
linuxScript('./buildso.sh');
}
if (!(new File('build/elf/mplayer')).exists()) {
linuxScript('./build3rdparty.sh');
}
delete miniclientReleaseDestinationDir
copy {
from('build/minirelease/MiniClient.jar') {
}
from ('build/clientfiles/')
from 'third_party/swscale/libswscale.so'
from ('build/so/libSageX11.so') {
rename 'libSageX11.so', 'libSage.so'
}
from ('build/so/libjtux.so')
from ('build/so/libImageLoader.so')
from ('build/elf/mplayer')
from (configurations.miniclientRuntime)
into(miniclientReleaseDestinationDir)
exclude '**/*-macosx-*', '**/*-solaris-*', '**/*-windows-*', '**/*-android-*', '**/*-linux-arm*'
}
}
// build RAW javadoc
task sageJavadoc(type: Javadoc) {
source = sourceSets.main.allJava
}
// task dependencies
sageJar.dependsOn classes, cleanSageJar
miniclientJar.dependsOn clean, miniclientClasses, cleanMiniJar
linuxMiniClientRelease.dependsOn miniclientJar
// Eclipse project setup
eclipse {
project {
name = appName
}
classpath {
file {
// java appears twice in the classpath because it is configured for sage and miniclient,
// need to remove the miniclient one, or else it will cause eclipse to complain
whenMerged { classpath ->
def item=null;
classpath.entries.each {
if (it.path == 'java' && it.includes.size()>0) {
item=it
}
}
if (item!=null) {
classpath.entries.remove(item)
}
}
}
}
}
// ======= launch tasks for testing ========
// Run configuration for MiniClient testing
// NOTE you can run with ./gradlew linuxRunMiniClient --debug-jvm and then use
// eclipse remote debugging on port 5005 to debug the app
task linuxRunMiniClient(type:JavaExec) {
description 'Run the MiniClient. Be sure you have run linuxMiniClientRelease at once, to get the dependency jars into the build/clientrelease area.'
main = "sage.miniclient.MiniClient"
classpath = fileTree(miniclientReleaseDestinationDir) {
include '*.jar'
exclude 'MiniClient.jar'
}
classpath += sourceSets.miniclient.runtimeClasspath
classpath += files('images/MiniClient/')
environment 'LD_LIBRARY_PATH', file(miniclientReleaseDestinationDir).getAbsolutePath()
workingDir file(miniclientReleaseDestinationDir)
}
linuxRunMiniClient.doFirst {
if (!new File(miniclientReleaseDestinationDir, 'sageclient.sh').exists()) {
System.out.println('\nRun ./gradlew linuxMiniClientRelease before running the client, for the first time.\n')
System.exit(1)
}
}
// Run configuration for Sage Server testing
// NOTE you can run with ./gradlew linuxRunServer --debug-jvm and then use
// eclipse remote debugging on port 5005 to debug the app
task linuxRunServer(type:JavaExec) {
args '0', '0', 'x', 'sagetv Sage.properties'
main = "sage.Sage"
classpath = sourceSets.main.runtimeClasspath
classpath += files('images/SageTV/')
classpath += files('i18n')
systemProperty 'java.awt.headless', true
environment 'LD_LIBRARY_PATH', file(sageReleaseDestinationDir).getAbsolutePath()
workingDir file(sageReleaseDestinationDir)
}
linuxRunServer.doFirst {
file(sageReleaseDestinationDir).mkdirs()
if (!new File(sageReleaseDestinationDir, 'libSage.so').exists()) {
System.out.println('\nRun build/buildall.sh to setup the build/serverrelease/ directory, before running the server for the first time.\n')
System.exit(1)
}
}
// Upload tasks
// use ./gradlew bintrayUpload
// make sure your BINTRAY_API is set in the environment
//
bintray {
user = System.getenv("BINTRAY_USER")
key = System.getenv("BINTRAY_API");
filesSpec {
from 'build/release'
from ('build') {
include '*.tar.gz', '*.deb'
}
into "sagetv/${baseVersion}"
}
dryRun = false //Whether to run this as dry-run, without deploying
publish = true //If version should be auto published after an upload
pkg {
repo = 'sagetv'
name = 'SageTV'
userOrg = 'opensagetv'
desc = "SageTV Release"
licenses = ['Apache-2.0']
vcsUrl = 'https://github.com/google/sagetv'
labels = ['sagetv']
publicDownloadNumbers = true
version {
name = "$baseVersion"
released = new Date()
desc = "SageTV ${baseVersion}"
//vcsTag = "V${version}"
//attributes = ['gradle-plugin': 'com.use.less:com.use.less.gradle:gradle-useless-plugin']
}
}
}
// This get run when you call ./gradlew without any targets
defaultTasks 'sageJar'