-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.gradle
341 lines (290 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
plugins {
id "com.jfrog.bintray" version "1.4"
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
ext {
plugin_name = "sagex-api"
plugin_desc = "SageTV API Extensions and Remote APIs"
plugin_longdesc = "Wrapper for SageTV APIs, adding plugin extensions, remote REST extensions, and other general utility type functions"
plugin_version = '9.2.8.1'
targetdir = 'target'
}
archivesBaseName = "${plugin_name}"
group 'sagex.plugins'
version = plugin_version
sourceCompatibility = 1.8
targetCompatibility = 1.8
configurations {
configure
}
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")
}
}
}
dependencies {
// used by the configure target
configure 'sagex:sagex.plugin.resolver:1.7'
configure 'dom4j:dom4j:1.6.1'
// the plugin jars should be extrated here
compile fileTree(dir: 'lib', include: '*.jar')
// https://mvnrepository.com/artifact/log4j/log4j
compile group: 'log4j', name: 'log4j', version: '1.2.17'
// used for the api generator
compile group: 'org.apache.ant', name: 'ant', version: '1.9.7'
// compile time jars
testCompile 'org.mockito:mockito-all:1.9.5'
testCompile group: 'junit', name: 'junit', version: '4.12'
}
jar {
exclude('org/**')
manifest {
attributes(
"Implementation-Title": "${plugin_name}",
"Implementation-Version": version
)
}
}
// setup testing
test {
// set a system property for the test JVM(s)
systemProperty 'java.library.path', file('lib').getAbsolutePath()
// explicitly include or exclude tests
include '**'
// if you need to exclude some tests
// 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 )
}
// if you need to set another working dir for tests
//workingDir 'target/testing/'
}
clean {
// extra folders to clean
delete 'target'
delete 'bin'
}
task configureDependencies() {
doLast {
// 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: "sagex-api,sagex-api-services,sagexmlinfo,htmlparser,log4j",
devpluginsxml: "src/main/plugin/plugin.xml,src/main/plugin/plugin-services.xml,src/main/plugin/jettystarter_plugin.xml"
)
// delete the plugin jar if it's downloaded as a dependency
ant.delete(file: "lib/${plugin_name}.jar", failonerror: "false")
}
}
task configure(dependsOn: 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 packagePluginServices() {
doLast {
ant.mkdir(dir: "build/sage/jetty/webapps/")
//ant.mkdir(dir: "build/sage/jetty/static/")
ant.mkdir(dir: "build/sage/sagex/services/")
ant.copy(file: "${targetdir}/build/sagex.war", todir: "build/sage/jetty/webapps/")
//ant.copy(file: "src/main/jetty/contexts/sagex.xml", todir: "build/sage/jetty/contexts/")
ant.copy(todir: "build/sage/jetty/webapps") {
fileset(dir: "src/main/jetty/static")
}
ant.copy(file: "src/main/services/sagex.js", todir: "build/sage/sagex/services/")
ant.zip(file: "build/distributions/${plugin_name}-services-${version}.zip") {
fileset(dir: "build/sage", includes: "**/**")
}
}
}
task packagePlugin(type: Zip, dependsOn: jar) {
baseName "${plugin_name}"
from "build/libs/"
include "${plugin_name}-*.jar"
rename("${plugin_name}-${version}.jar","${plugin_name}.jar")
}
task packagePluginServicesManifest() {
doLast {
// note Copy will always overwrite, so we'll have clean files to manipulate
copy {
from 'src/main/plugin/plugin-services.xml'
into 'build/tmp/'
}
ant.checksum(file: "build/distributions/${plugin_name}-services-${version}.zip", property: "md5_system")
ant.tstamp {
format(property: "lastmodified", pattern: "yyyy.MM.dd")
}
ant.replace(file: "build/tmp/plugin-services.xml", summary: "yes") {
replacefilter(token: "@@last-modified@@", value: ant.lastmodified)
replacefilter(token: "@@version@@", value: version)
replacefilter(token: "@@system-checksum@@", value: ant.md5_system)
replacefilter(token: "@@plugin-name@@", value: "${plugin_name}-services")
replacefilter(token: "@@plugin-desc@@", value: plugin_desc)
replacefilter(token: "@@plugin-longdesc@@", value: plugin_longdesc)
}
copy {
from 'build/tmp/plugin-services.xml'
into 'build/distributions/'
rename('plugin-services.xml', "${plugin_name}-services-${version}.xml")
}
// update the deployed manifest
copy {
from 'build/tmp/plugin-services.xml'
into 'deployed/'
}
}
}
packagePlugin.finalizedBy packagePluginServices
packagePluginServices.finalizedBy packagePluginServicesManifest
task packagePluginManifest() {
doLast {
// note Copy will always overwrite, so we'll have clean files to manipulate
copy {
from 'src/main/plugin/plugin.xml'
into 'build/tmp/'
}
ant.checksum(file: "build/distributions/${plugin_name}-${version}.zip", property: "md5_jar")
ant.tstamp {
format(property: "lastmodified", pattern: "yyyy.MM.dd")
}
ant.replace(file: "build/tmp/plugin.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: "@@plugin-name@@", value: plugin_name)
replacefilter(token: "@@plugin-desc@@", value: plugin_desc)
replacefilter(token: "@@plugin-longdesc@@", value: plugin_longdesc)
}
copy {
from 'build/tmp/plugin.xml'
into 'build/distributions/'
rename('plugin.xml', "${plugin_name}-${version}.xml")
}
// update the deployed manifest
copy {
from 'build/tmp/plugin.xml'
into 'deployed/'
}
}
}
packagePluginManifest.dependsOn packagePlugin
/**
* Entry point for creating all plugins with manifest, making it ready for upload
*/
task dist() {
doLast {
println "Packages build and placed in build/distributions/"
}
}
dist.dependsOn packagePluginManifest
// uploading to BinTray
// use ./gradlew bintrayUpload
bintray {
user = System.getenv("BINTRAY_USER")
key = System.getenv("BINTRAY_API");
filesSpec {
from ('build/distributions/') {
include "*${version}*"
}
/* this is the dirname */
into "${plugin_name}/${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 = "${plugin_name}"
userOrg = 'opensagetv'
desc = "${plugin_desc}"
licenses = ['Apache-2.0']
vcsUrl = 'https://github.com/stuckless/sagetv-sagex-api'
labels = ['sagetv', 'sagetv-plugin']
publicDownloadNumbers = true
//attributes= ['a': ['ay1', 'ay2'], 'b': ['bee'], c: 'cee'] //Optional package-level attributes
version {
name = "${plugin_version}"
desc = "${plugin_desc}"
vcsTag = "${plugin_version}"
//attributes = ['gradle-plugin': 'com.use.less:com.use.less.gradle:gradle-useless-plugin']
}
}
}
task createVersion() {
doLast {
File versionFile = new File("src/generated/java/sagex/api/Version.java")
versionFile.text = """
package sagex.api;
public class Version {
public static final String VERSION = \"${version}\";
public static String GetVersion() {
return VERSION;
}
}"""
}
}
compileJava.dependsOn createVersion
task generateApi(type: JavaExec) {
classpath = sourceSets.main.runtimeClasspath
main = 'org.jdna.sage.api.generator.Main'
}
task gendocs(type: Javadoc) {
//options.stylesheetFile = new File("./assets/doc_style.css")
version = version
title = "SageTV sagex ${version} API"
options.windowTitle = "SageTV sagex API"
options.memberLevel = JavadocMemberLevel.PROTECTED
options.author = true
//options.linksOffline('http://d.android.com/reference', System.getenv("ANDROID_HOME") + '/docs/reference')
destinationDir = new File("build/docs/api")
source = sourceSets.main.allJava
classpath += configurations.compile
exclude "org/**"
}
// Java 8 is really strict on the JavaDoc front... We need to turn off the lints
if (JavaVersion.current().isJava8Compatible()) {
allprojects {
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
}
}
}