-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathbuild.gradle
396 lines (335 loc) · 12.7 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
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
plugins {
id "com.jfrog.bintray" version "1.4"
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
jar.baseName 'phoenix'
group 'phoenix'
version '3.5.0'
archivesBaseName = "phoenix"
sourceCompatibility = 1.8
targetCompatibility = 1.8
ext {
plugin_name = "phoenix"
plugin_desc = "Phoenix apis"
plugin_longdesc = "Phoenix apis for SageTV"
plugin_version = version
}
configurations {
configure
genapi
sagesubmit
}
sourceSets {
main {
java.srcDirs = ['src/main/java','src/generated/java','src/tools/java']
resources.srcDirs = ['src/main/resources','src/generated/resources','src/tools/resources']
}
test {
java.srcDirs = ['src/test/java']
resources.srcDirs = ['src/test/resources']
}
}
repositories {
mavenLocal()
mavenCentral()
jcenter()
maven {
//Github does not support public maven packages so to retrieve you will need
// a Personal Access Token to get the package
// Create the 2 environment variables below with the user and token
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/jusjoken/sagetv-dependencies-task")
credentials {
username = project.findProperty("gpr.user") ?: System.getenv("GITHUB_USER")
password = project.findProperty("gpr.key") ?: System.getenv("GITHUB_TOKEN")
}
}
maven {
//Github does not support public maven packages so to retrieve you will need
// a Personal Access Token to get the package
// Create the 2 environment variables below with the user and token
name = "GitHubPackages2"
url = uri("https://maven.pkg.github.com/jusjoken/phoenix-api-builder")
credentials {
username = project.findProperty("gpr.user") ?: System.getenv("GITHUB_USER")
password = project.findProperty("gpr.key") ?: System.getenv("GITHUB_TOKEN")
}
}
//maven {
// url "http://dl.bintray.com/opensagetv/maven"
//}
//maven {
// url "http://dl.bintray.com/stuckless/sagetvphoenix"
//}
}
dependencies {
// used by the configure target
configure 'sagex:sagex.plugin.resolver:1.7'
configure 'dom4j:dom4j:1.6.1'
// used by the generate api target
genapi 'phoenix:phoenix-api-builder:2.2.1'
// used by sluggers sagetv notify plugin
sagesubmit 'slugger:slugger-dev-tools:0.0.1'
// the plugin jars should be extrated here
compile fileTree(dir: 'lib', include: '*.jar')
// we also need some servlet jars for compilation that are not a part of plugins
compile 'javax.servlet:servlet-api:2.5'
// compile time jars
testCompile 'org.easymock:easymock:2.5.2'
testCompile 'org.mockito:mockito-all:1.9.5'
testCompile group: 'junit', name: 'junit', version: '4.12'
}
jar {
manifest {
attributes(
"Implementation-Title": "phoenix-api",
"Implementation-Version": version
)
}
}
// setup testing
test {
// set a system property for the test JVM(s)
systemProperty 'some.prop', 'value'
// explicitly include or exclude tests
include 'sagex/phoenix/**'
exclude 'test/junit/**'
// show standard out and standard error of the test JVM(s) on the console
testLogging.showStandardStreams = true
// set heap size for the test JVM(s)
minHeapSize = "128m"
maxHeapSize = "512m"
// listen to events in the test execution lifecycle
beforeTest { descriptor ->
logger.lifecycle("Running test: " + descriptor)
}
// listen to standard out and standard error of the test JVM(s)
onOutput { descriptor, event ->
logger.lifecycle("Test: " + descriptor + ": " + event.message )
}
workingDir 'target/testing/'
}
clean {
delete 'target'
delete 'bin'
}
task testInit << {
println('Creating testing home: target/testing')
file('target/testing').mkdirs()
}
test.dependsOn testInit
// eventually we'll be getting rid of gwt
task processResourcesGwt << {
// sometimes the ant task is just easier to configure :(
ant.copy(toDir:"build/resources/main/gwt/", failonerror:"true") {
fileset(dir:"src/main/resourcesGwt/gwt/") {
include (name: "phoenix.gwt.xml")
}
}
ant.copy(toDir:"build/resources/main/gwt/src", failonerror:"true") {
fileset(dir:"src/main/resourcesGwt/gwt/src/")
}
ant.copy(toDir:"build/resources/main/gwt/src", failonerror:"true") {
fileset(dir:"src/main/java/") {
include (name: "sagex/phoenix/metadata/MetadataException.java" )
include (name: "sagex/phoenix/metadata/search/SearchQuery.java" )
include (name: "sagex/phoenix/metadata/MediaType.java" )
include (name: "sagex/phoenix/metadata/MediaArtifactType.java" )
include (name: "sagex/phoenix/vfs/I*.java" )
include (name: "sagex/phoenix/progress/I*.java" )
include (name: "sagex/phoenix/metadata/I*.java" )
include (name: "sagex/phoenix/metadata/proxy/SageProperty.java" )
include (name: "sagex/phoenix/util/HasHints.java" )
include (name: "sagex/phoenix/util/Hints.java" )
include (name: "sagex/phoenix/configuration/Config.java" )
}
}
}
processResources.finalizedBy processResourcesGwt
task configureDependencies << {
// remove all dependency jars
ant.delete(dir:"lib", includes: "*.*",failonerror:"false")
ant.taskdef(
name: 'sagetvdeps',
classname: 'sagex.plugin.resolver.ant.SageDependencies',
classpath: configurations.configure.asPath
)
ant.sagetvdeps(
downloadSageJar:true,
jardir:"lib",
pluginname:"phoenix-core",
devpluginsxml:"SageTVPluginsDev_phoenix.xml, src/plugins/phoenix-api/plugin-api.xml, src/plugins/phoenix-core/plugin-core.xml"
)
// delete the phoenix jar if it's downloaded as a dependency
ant.delete(file:"lib/phoenix.jar", failonerror:"false")
}
task generateApi << {
delete {
fileTree(dir: "src/main/java/phoenix/", include: '*.java', exclude: 'api.java' )
}
ant.taskdef(
name: 'genapi',
classname: 'phoenix.apibuilder.ant.APIBuilderTask',
classpath: configurations.genapi.asPath
)
ant.genapi(
source: "src/main/java",
output: "src/main/java/phoenix",
debug: "true"
)
}
// task placeholder for configuration dependency stuf
task configure(dependsOn: generateApi) {
}
configure.finalizedBy configureDependencies
// after a clean eclipse we need to download the configuration dependencies and make sure eclipse
// target will have the required deps
cleanEclipse.finalizedBy configure
task packageApi(type: Zip, dependsOn: jar) {
baseName "phoenix-api"
from "build/libs/"
include "phoenix-*.jar"
rename("phoenix-${version}.jar","phoenix.jar")
}
task packageCore(type: Zip) {
baseName "phoenix-core"
from "src/plugins/phoenix-core"
excludes = ['**/db/**','**/*Test*','**/Skins/**', '**/Themes/**','**/Plugins/**','**/ext/**', 'plugin-core.xml']
}
task packageArchives(type: Task, dependsOn: packageApi) {
}
packageArchives.finalizedBy packageCore
task packagePlugins << {
def changelog = file('CHANGELOG.md').text;
// note Copy will always overwrite, so we'll have clean files to manipulate
copy {
from 'src/plugins/phoenix-api/plugin-api.xml'
from 'src/plugins/phoenix-core/plugin-core.xml'
into 'build/tmp/'
}
ant.checksum (file:"build/distributions/phoenix-core-${version}.zip", property:"md5_system")
ant.checksum (file:"build/distributions/phoenix-api-${version}.zip", property:"md5_jar")
ant.tstamp {
format(property:"lastmodified", pattern:"yyyy.MM.dd")
}
ant.replace(file:"build/tmp/plugin-api.xml", summary:"yes") {
replacefilter(token: "@@last-modified@@", value: ant.lastmodified)
replacefilter(token: "@@version@@", value: version)
replacefilter(token: "@@jar-checksum@@", value: ant.md5_jar)
replacefilter(token: "@@system-checksum@@", value: ant.md5_system)
replacefilter(token: "@@changelog@@", value: changelog)
}
ant.replace(file:"build/tmp/plugin-core.xml", summary:"yes") {
replacefilter(token: "@@last-modified@@", value: ant.lastmodified)
replacefilter(token: "@@version@@", value: version)
replacefilter(token: "@@jar-checksum@@", value: ant.md5_jar)
replacefilter(token: "@@system-checksum@@", value: ant.md5_system)
replacefilter(token: "@@changelog@@", value: changelog)
}
copy {
from 'build/tmp/plugin-api.xml'
from 'build/tmp/plugin-core.xml'
into 'build/distributions/'
rename ('plugin-api.xml', "phoenix-api-${version}.xml")
rename ('plugin-core.xml', "phoenix-core-${version}.xml")
}
// update the deployed manifest
copy {
from 'build/tmp/plugin-api.xml'
from 'build/tmp/plugin-core.xml'
into 'deployed/'
}
}
packagePlugins.dependsOn packageArchives
task dist << {
}
dist.dependsOn packagePlugins
/**
* note: call like
* ./gradlew -PsagetvDir=/home/seans/unRAID/mnt/user/apps/sagetv/server/ -PotherSageTVPlugins=OtherSageTVpluginsDev.xml buildDevPlugins
* newly created SageTVPluginsDev.xml will be copied to the sagetvDir
*/
task buildDevPlugins << {
def fname1 = "phoenix-api-${version}"
def server = "http://localhost:8085"
ant.replaceregexp(
file:"build/distributions/${fname1}.xml",
byline: true,
match:"<Location>.*</Location>",
replace:"<Location>${server}/build/distributions/${fname1}.zip</Location>"
)
def fname2 = "phoenix-core-${version}"
ant.replaceregexp(
file:"build/distributions/${fname2}.xml",
byline: true,
match:"<Location>.*</Location>",
replace:"<Location>${server}/build/distributions/${fname2}.zip</Location>"
)
// now concat the files and create the plugins dev
def xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
xml += "<PluginRepository version=\"${version}\">\n"
xml += new File("build/distributions/${fname1}.xml").text.replaceAll("<\\?.*\\?>", "")
xml += "\n"
xml += new File("build/distributions/${fname2}.xml").text.replaceAll("<\\?.*\\?>", "")
if (project.hasProperty("otherSageTVPlugins")) {
println("Added additional plugins from ${otherSageTVPlugins}")
def otherXml = new File("${otherSageTVPlugins}").text
otherXml = otherXml.replaceAll("<\\?.*\\?>", "")
otherXml = otherXml.replaceAll("<[/]*PluginRepository.*>", "")
xml += otherXml
}
xml += "</PluginRepository>\n"
// if this fails then the xml processing went wrong
println("Validating new plugins xml")
def testXml = new XmlSlurper().parseText(xml)
new File('SageTVPluginsDev.xml').text = xml
if (project.hasProperty("sagetvDir")) {
println("\n\nCopying SageTVPluginsDev.xml to ${sagetvDir}");
copy {
from 'SageTVPluginsDev.xml'
into "${sagetvDir}"
}
} else {
println("\n\nSageTVPluginsDev is created but you need to manually copy it to SageTV, or pass -PsagetvDir=YOUR_SAGETV_DIR");
}
}
task serveDevPlugins << {
SimpleHttpFileServerFactory factory = new SimpleHttpFileServerFactory()
HttpFileServer server = factory.start(new File("."), 8085)
println("Server Started on 8085 ctrc+c to kill it")
java.lang.Thread.sleep(Long.MAX_VALUE);
}
buildDevPlugins.dependsOn packagePlugins
serveDevPlugins.dependsOn buildDevPlugins
// uploading to BinTray
bintray {
user = System.getenv("BINTRAY_USER")
key = System.getenv("BINTRAY_API");
filesSpec {
from ('build/distributions/') {
include "*${plugin_version}*"
}
into "phoenix/${plugin_version}"
}
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-plugins'
name = 'phoenix'
userOrg = 'opensagetv'
desc = 'Phoenix Plugin for SageTV'
licenses = ['Apache-2.0']
vcsUrl = 'https://github.com/stuckless/sagetv-phoenix-core'
labels = ['sagetv', 'phoenix', 'sagetv-plugin']
publicDownloadNumbers = true
//attributes= ['a': ['ay1', 'ay2'], 'b': ['bee'], c: 'cee'] //Optional package-level attributes
version {
name = "${plugin_version}"
desc = 'Phoenix'
vcsTag = "${plugin_version}"
//attributes = ['gradle-plugin': 'com.use.less:com.use.less.gradle:gradle-useless-plugin']
}
}
}