forked from graniteds/graniteds
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
408 lines (339 loc) · 12 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
397
398
399
400
401
402
403
404
405
406
407
408
import org.apache.tools.ant.filters.ReplaceTokens
buildscript {
repositories {
mavenCentral()
maven {
name 'Bintray Asciidoctor repo'
url 'http://dl.bintray.com/content/aalmiray/asciidoctor'
}
maven {
name 'Bintray JCenter'
url 'http://jcenter.bintray.com'
}
}
dependencies {
classpath 'nl.javadude.gradle.plugins:license-gradle-plugin:0.10.0'
classpath 'net.saliman:gradle-cobertura-plugin:1.1.2'
classpath group: 'org.gradlefx', name: 'gradlefx', version: '0.8.1'
classpath 'org.asciidoctor:asciidoctor-gradle-plugin:0.5.0'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:0.3'
}
}
group = 'org.graniteds'
version = granitedsVersion
ext.jetty8Version = '8.1.15.v20140411'
ext.jetty9Version = '9.1.2.v20140210'
// https://gist.github.com/JonasGroeger/7620911
def timestamp = new Date().format('yyyyMMddHHmmss')
try {
// Try to get timestamp of last git commit
def gitFolder = "$projectDir/.git/"
def takeFromHash = 12
def head = new File(gitFolder + 'HEAD').text.split(':') // .git/HEAD
def isCommit = head.length == 1 // e5a7c79edabbf7dd39888442df081b1c9d8e88fd
def refHead = new File(gitFolder + (isCommit ? 'HEAD' : head[1].trim())) // .git/refs/heads/master
timestamp = new Date(refHead.lastModified()).format('yyyyMMddHHmmss')
}
catch (Exception e) {
// Ignore
}
if (granitedsVersion.indexOf('-SNAPSHOT') > 0)
ext.pluginVersion = granitedsVersion.replace('-SNAPSHOT', '.v' + timestamp)
else
ext.pluginVersion = granitedsVersion.substring(0, granitedsVersion.lastIndexOf('.')) + '.v' + timestamp
ext.javadocLinks = [
"http://docs.oracle.com/javase/7/docs/api/",
"http://docs.oracle.com/javaee/7/api/",
]
// Main tasks for eclipse
task buildServer {
dependsOn ':granite-server:buildDependents', ':granite-server:buildNeeded'
}
task buildJavaClient {
dependsOn ':granite-client-java-advanced:buildDependents', ':granite-client-java-advanced:buildNeeded',
':granite-client-javafx:buildDependents', ':granite-client-javafx:buildNeeded',
':granite-client-android:buildDependents', ':granite-client-android:buildNeeded'
}
task buildFlexClient {
dependsOn ':granite-client-flex:build', 'granite-client-flex-advanced:build', 'granite-client-flex45-advanced:build'
}
task build {
dependsOn 'buildServer', 'buildJavaClient', 'buildFlexClient'
}
configure(subprojects) {
repositories {
mavenCentral()
maven {
name 'JBoss Nexus'
url 'https://repository.jboss.org/nexus/content/groups/public'
}
mavenLocal()
}
}
// Add Java plugin for all non-Flex subprojects
configure(subprojects.findAll { it.name.startsWith('granite') && !it.name.startsWith('granite-client-flex') && it.name != 'granite-server' && it.name != 'granite-generator-share' }) { subproject ->
apply plugin: 'java'
apply plugin: 'eclipse'
compileJava {
sourceCompatibility=1.6
targetCompatibility=1.6
}
if (subproject.name.startsWith('granite-server')) {
compileTestJava {
sourceCompatibility=1.6
targetCompatibility=1.6
}
}
else {
compileTestJava {
sourceCompatibility=1.7
targetCompatibility=1.7
}
}
[compileJava, compileTestJava]*.options*.compilerArgs = [
"-Xlint:varargs",
"-Xlint:cast",
"-Xlint:classfile",
"-Xlint:dep-ann",
"-Xlint:divzero",
"-Xlint:empty",
"-Xlint:finally",
"-Xlint:overrides",
"-Xlint:path",
"-Xlint:processing",
"-Xlint:static",
"-Xlint:try",
"-Xlint:serial",
"-Xlint:-options",
"-Xlint:-fallthrough",
"-Xlint:-rawtypes",
"-Xlint:-deprecation",
"-Xlint:-unchecked"
]
configurations {
create('javadoc')
}
task sourcesJar(type: Jar, dependsOn: 'classes') {
classifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: 'javadoc') {
classifier = 'javadoc'
from javadoc.destinationDir
}
jar {
metaInf {
from 'LICENSE.txt'
}
}
artifacts {
archives sourcesJar
archives javadocJar
}
dependencies {
javadoc 'log4j:log4j:1.2.17'
testCompile 'junit:junit:4.11'
}
test {
workingDir = subproject.rootDir
ignoreFailures = true // Don't break the build on test failures so bamboo can get the test results
}
javadoc {
title 'GraniteDS API Documentation'
classpath.add(configurations.javadoc)
configure(options) {
version = true
author = true
use = true
windowTitle = 'GraniteDS API Documentation'
docTitle = 'GraniteDS API Documentation - ' + granitedsVersion
links = rootProject.ext.javadocLinks
}
}
}
// Add GradleFX plugin for all Flex subprojects
configure(subprojects.findAll { it.name.startsWith('granite-client-flex') }) { subproject ->
apply plugin: 'gradlefx'
apply plugin: 'flashbuilder'
output = 'libs/' + subproject.name + '-' + granitedsVersion
}
// Add license plugin for all subprojects
// Use a modified version of the license plugin to be compatible with GradleFX
configure(subprojects.findAll { it.name != 'granite-server' && it.name != 'granite-generator-share' && it.name != 'reference-docs' }) { subproject ->
apply plugin: ExtLicensePlugin
license {
header rootProject.file('HEADER-' + subproject.moduleLicense + '.txt')
strictCheck true
ext.year = Calendar.getInstance().get(Calendar.YEAR)
mapping('as', 'SLASHSTAR_STYLE')
}
}
import nl.javadude.gradle.plugins.license.License
import nl.javadude.gradle.plugins.license.LicensePlugin
class ExtLicensePlugin extends LicensePlugin {
private static Logger logger = Logging.getLogger(ExtLicensePlugin);
void apply(Project project) {
this.project = project
extension = createExtension()
configureExtensionRule()
project.plugins.withType(JavaBasePlugin) {
extension.sourceSets.all { SourceSet sourceSet ->
def sourceSetTaskName = sourceSet.getTaskName(taskBaseName, null)
logger.info("Adding license tasks for sourceSet ${sourceSetTaskName}");
License checkTask = project.tasks.create(sourceSetTaskName, License)
checkTask.check = true
configureForSourceSet(sourceSet, checkTask)
// Add license checking into check lifecycle, since its a type of code quality plugin
project.tasks[JavaBasePlugin.CHECK_TASK_NAME].dependsOn checkTask
// Add independent license task, which will perform format
def sourceSetFormatTaskName = sourceSet.getTaskName(taskBaseName + 'Format', null)
License formatTask = project.tasks.create(sourceSetFormatTaskName, License)
formatTask.check = false
configureForSourceSet(sourceSet, formatTask)
}
}
project.plugins.withType(org.gradlefx.plugins.GradleFxPlugin) {
logger.info("Adding license tasks for Flex");
License checkTask = project.tasks.create('licenseFlex', License)
checkTask.check = true
checkTask.description = 'Scanning license on Flex files'
checkTask.source = [ 'src/main/flex', 'src/test/flex' ]
// Add license checking into check lifecycle, since its a type of code quality plugin
project.tasks['compileFlex'].dependsOn checkTask
// Add independent license task, which will perform format
License formatTask = project.tasks.create('licenseFormatFlex', License)
formatTask.check = false
formatTask.description = 'Scanning license on Flex files'
formatTask.source = [ 'src/main/flex', 'src/test/flex' ]
}
configureTaskRule()
}
protected void configureForSourceSet(SourceSet sourceSet, nl.javadude.gradle.plugins.license.License task) {
super.configureForSourceSet(sourceSet, task)
// Override default allSource and apply only to all Java source files from SourceSet (excluding resources)
task.source = sourceSet.allJava
}
}
// Common configuration for all subprojects
// signing + maven deployment
configure(subprojects.findAll { it.name != 'reference-docs' && !it.name.endsWith('-eclipse') && !it.name.endsWith('-tests') &&
!it.name.startsWith('granite-common') && it.name != 'granite-amf' && it.name != 'granite-jmf' }) { subproject ->
apply plugin: 'maven'
apply plugin: 'signing'
group = 'org.graniteds'
version = granitedsVersion
configurations {
deployerJars
}
dependencies {
deployerJars 'org.apache.maven.wagon:wagon-http:2.2'
}
signing {
required {
gradle.taskGraph.hasTask(':dist:uploadArchives') || gradle.taskGraph.hasTask(':dist:bintrayUpload')
}
sign configurations.archives
}
// Adds an install task for Flex projects because maven plugin does not add it for GradleFx projects
if (subproject.name.startsWith('granite-client-flex')) {
task install(type: Upload, dependsOn: 'build') {
configuration = subproject.configurations.archives
description = 'Installs the \'archives\' artifacts into the local Maven repository.'
repositories.mavenInstaller()
}
}
if (subproject.tasks.findByName('install') != null) {
install {
repositories {
mavenInstaller {
// Generated dependencies are not suitable for maven pom, remove everything for now
pom.whenConfigured { pom -> pom.dependencies.clear() }
}
}
}
}
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment {
MavenDeployment deployment -> signing.signPom(deployment)
}
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: sonatypeOssUserName, password: sonatypeOssPassword)
}
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
authentication(userName: sonatypeOssUserName, password: sonatypeOssPassword)
}
pom.project {
name subproject.description
packaging 'swc'
description subproject.description
url 'http://www.graniteds.org'
scm {
url 'scm:[email protected]:graniteds/graniteds.git'
connection 'scm:[email protected]:graniteds/graniteds.git'
developerConnection 'scm:[email protected]:graniteds/graniteds.git'
}
licenses {
if (subproject.moduleLicense == 'lgpl') {
license {
name 'GNU LIBRARY GENERAL PUBLIC LICENSE, Version 2.1, February 1999'
url 'http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt'
distribution 'repo'
}
}
if (subproject.moduleLicense == 'gpl') {
license {
name 'GNU General Public License, Version 3, 29 June 2007'
url 'http://www.gnu.org/licenses/gpl-3.0.en.html'
distribution 'repo'
}
}
}
developers {
developer {
id 'fwolff'
name 'Franck Wolff'
}
developer {
id 'wdrai'
name 'William Drai'
}
}
}
// Generated dependencies are not suitable for maven pom, remove everything for now
pom.whenConfigured { pom -> pom.dependencies.clear() }
}
}
}
}
ext.coreProjects = [
':granite-server-core',
':granite-server-servlet3',
':granite-server-tomcat6',
':granite-server-tomcat7',
':granite-server-jetty6',
':granite-server-jetty8',
':granite-server-jetty9',
':granite-server-jboss',
':granite-server-wildfly',
':granite-server-glassfishv2',
':granite-server-glassfishv3',
':granite-server-weblogic',
':granite-server-activemq'
]
ext.allProjects = coreProjects + [
':granite-server-cdi',
':granite-server-ejb',
':granite-server-spring',
':granite-server-spring2',
':granite-server-seam',
':granite-server-hibernate',
':granite-server-hibernate4',
':granite-server-datanucleus',
':granite-server-eclipselink',
':granite-server-openjpa',
':granite-server-toplink',
':granite-server-beanvalidation',
':granite-server-appengine'
]