forked from grails/grails-data-mapping
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
580 lines (494 loc) · 20 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
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
buildscript {
repositories {
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
jcenter()
}
dependencies {
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2"
classpath "com.netflix.nebula:gradle-extra-configurations-plugin:2.2.0"
classpath 'com.bmuschko:gradle-nexus-plugin:2.3'
classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.5.3"
classpath "com.github.adrianbk:gradle-travisci-trigger-plugin:1.0.0"
}
}
project.ext {
springBootVersion = '1.3.1.RELEASE'
springVersion = "4.1.7.RELEASE"
grailsVersion = "3.0.12"
grails2Version = '2.5.3'
slf4jVersion = "1.7.10"
junitVersion = "4.12"
groovyVersion = System.getProperty('groovyVersion') ?: '2.4.5'
isTravisBuild = System.getenv().get("TRAVIS") == 'true'
projectMajorVersion = "5"
projectMinorVersion = "0"
projectPatchVersion = "2"
// releaseType = "RELEASE"
// releaseType = "M4"
// releaseType = "RC4"
releaseType = "BUILD-SNAPSHOT"
// overall project version
projectVersion = "${projectMajorVersion}.${projectMinorVersion}.${projectPatchVersion}"
// driver versions
neo4jVersion = '2.3.2'
mongoVersion = '3.2.1'
// plugin versions
hibernateVersion = "4.3.10"
hibernate5Version = "5.0.7"
def defaultPluginVersion = releaseType == 'RELEASE' ? projectVersion : "${projectVersion}.${releaseType}"
hibernatePluginVersion = defaultPluginVersion
mongodbPluginVersion = defaultPluginVersion
neo4jPluginVersion = defaultPluginVersion
cassandraPluginVersion = defaultPluginVersion
redisPluginVersion = defaultPluginVersion
isCiBuild = project.hasProperty("isCiBuild")
isBuildSnapshot = releaseType == "BUILD-SNAPSHOT"
servletApiVersion = "3.0.1"
nexusUsername = System.getenv("SONATYPE_USERNAME") ?: project.hasProperty("sonatypeOssUsername") ? project.sonatypeOssUsername : ''
nexusPassword = System.getenv("SONATYPE_PASSWORD") ?: project.hasProperty("sonatypeOssPassword") ? project.sonatypeOssPassword : ''
}
def groovyMajorVersion = groovyVersion[0..2]
def spockDependency = "org.spockframework:spock-core:1.0-groovy-2.4"
def groovyProjects() {
subprojects.findAll { project -> isGroovyProject(project) }
}
def isGroovyProject(project) {
def isGrailsPlugin = project.name.contains("grails-plugins")
def isDocumentation = project.name.contains("documentation")
!isGrailsPlugin && !isDocumentation
}
configurations {
all*.exclude group: "commons-logging"
}
version = "${projectVersion}.${releaseType}"
group = "org.grails"
apply plugin: 'idea'
apply plugin: 'project-report'
apply plugin: "com.github.adrianbk.tcitrigger"
apply plugin: 'io.codearte.nexus-staging'
nexusStaging {
delayBetweenRetriesInMillis = 5000
}
tciTrigger {
gitHubRepo 'grails/grails-data-mapping-functional-tests'
travisVariable {
name = "GORM_VERSION"
value = "${projectVersion}.${releaseType}"
}
}
ext {
isCiBuild = project.hasProperty("isCiBuild")
}
allprojects {
repositories {
mavenLocal()
if(System.getProperty('useJbossNexus')) {
// jboss-nexus contains Hibernate source code archives which aren't in maven central
// usefull with eclipse and idea tasks, for example
// ./gradlew -PuseJbossNexus cleanEclipse eclipse
maven {
name 'jboss-nexus'
url "https://repository.jboss.org/nexus/content/groups/public/"
}
}
maven { url "https://repo.grails.org/grails/core" }
if(isBuildSnapshot) {
maven { url "https://repo.grails.org/grails/libs-snapshots-local" }
}
}
configurations {
all {
resolutionStrategy {
force "org.codehaus.groovy:groovy:$groovyVersion"
force "org.codehaus.groovy:groovy-xml:$groovyVersion"
// def cacheHours = isCiBuild ? 1 : 24
// cacheDynamicVersionsFor cacheHours, 'hours'
// cacheChangingModulesFor cacheHours, 'hours'
}
}
}
}
task wrapper(type: Wrapper) {
gradleVersion = '2.8'
}
apply from: "gradle/idea.gradle"
subprojects {
configurations {
documentation
}
version = "${projectVersion}.${releaseType}"
group = "org.grails"
if(project.name.endsWith("spring-boot")) return
if(project.name.contains("grails2-plugins")) return
afterEvaluate { project ->
if (isGroovyProject(project)) {
def hasSnapshotVersion = project.version.endsWith("-SNAPSHOT")
if(isBuildSnapshot != hasSnapshotVersion) {
throw new StopExecutionException("${project.name} has version \"${project.version}\" which is${isBuildSnapshot ? 'n\'t' : ''} a snapshot version. Current release type is ${releaseType}")
}
}
}
ext {
pomInfo = {
delegate.name 'Grails GORM'
delegate.description 'GORM - Grails Data Access Framework'
delegate.url 'http://grails.org/'
delegate.licenses {
delegate.license {
delegate.name 'The Apache Software License, Version 2.0'
delegate.url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
delegate.distribution 'repo'
}
}
delegate.scm {
delegate.url 'scm:[email protected]:grails/grails-data-mapping.git'
delegate.connection 'scm:[email protected]:grails/grails-data-mapping.git'
delegate.developerConnection 'scm:[email protected]:grails/grails-data-mapping.git'
}
delegate.developers {
delegate.developer {
delegate.id 'graemerocher'
delegate.name 'Graeme Rocher'
}
delegate.developer {
delegate.id 'jeffscottbrown'
delegate.name 'Jeff Brown'
}
delegate.developer {
delegate.id 'burtbeckwith'
delegate.name 'Burt Beckwith'
}
}
}
}
def isStandardGroovyMavenProject = isGroovyProject(project)
if (isStandardGroovyMavenProject) {
apply plugin: 'groovy'
apply plugin: 'eclipse'
apply plugin: 'com.bmuschko.nexus'
apply plugin: 'maven-publish'
apply plugin: 'idea'
apply plugin: 'provided-base'
apply plugin: 'optional-base'
sourceCompatibility = "1.7"
targetCompatibility = "1.7"
}
def isGormDatasource = project.name.startsWith("grails-datastore-gorm-") &&
!project.name.endsWith("tck") &&
!project.name.endsWith("-support") &&
!project.name.endsWith("-core") &&
project.name != 'grails-datastore-gorm-rest-client'
def isDocumentationProject = project.name.startsWith("grails-documentation")
dependencies {
if (isStandardGroovyMavenProject) {
documentation "org.fusesource.jansi:jansi:1.11"
compile group: 'org.codehaus.groovy', name: 'groovy', version: groovyVersion
testCompile group: 'org.codehaus.groovy', name: 'groovy-test', version: groovyVersion
testCompile "junit:junit:$junitVersion"
testCompile (spockDependency) {
exclude group:'junit',module:'junit-dep'
exclude group:'org.codehaus.groovy',module:'groovy-all'
exclude group:'org.hamcrest',module:'hamcrest-core'
transitive = false
}
}
if (project.name == "grails-datastore-gorm-tck") {
compile spockDependency, {
exclude group:'junit',module:'junit-dep'
exclude group:'org.codehaus.groovy',module:'groovy-all'
exclude group:'org.hamcrest',module:'hamcrest-core'
transitive = false
}
}
}
if (isDocumentationProject) {
dependencies {
documentation group: 'org.grails', name: 'grails-docs', version: grailsVersion
documentation group: 'org.codehaus.groovy', name: 'groovy-all', version: groovyVersion
project(":grails-datastore-core")
documentation "org.slf4j:jcl-over-slf4j:$slf4jVersion"
documentation "org.slf4j:slf4j-api:$slf4jVersion"
documentation "org.slf4j:slf4j-simple:$slf4jVersion"
}
task docs << {
ant.taskdef (name: 'docs', classname : 'grails.doc.ant.DocPublisherTask') {
classpath {
configurations.documentation.resolve().each { f ->
pathelement(location:f)
}
}
}
def props = new Properties()
project.file("src/docs/doc.properties").withReader {
props.load(it)
}
props['version'] = project.version.toString()
def f = new File(File.createTempDir(), "${project.name}-docs.properties")
f.withWriter {
props.store(it, "Generated")
}
f.deleteOnExit()
ant.docs(src:"src/docs", dest:destinationDir, properties:f.canonicalPath)
}
docs.ext.destinationDir = "${buildDir}/docs"
task clean << {
ant.delete(dir:buildDir)
}
}
if (isGormDatasource) {
dependencies {
testCompile project(":grails-datastore-gorm-tck")
}
// We need to test against the TCK. Gradle cannot find/run tests from jars
// without a lot of plumbing, so here we copy the class files from the TCK
// project into this project's test classes dir so Gradle can find the test
// classes and run them. See grails.gorm.tests.GormDatastoreSpec for on the TCK.
// helper, used below.
def toBaseClassRelativePathWithoutExtension = { String base, String classFile ->
if (classFile.startsWith(base)) {
def sansClass = classFile[0 .. classFile.size() - ".class".size() - 1]
def dollarIndex = sansClass.indexOf('$')
def baseClass = dollarIndex > 0 ? sansClass[0..dollarIndex - 1] : sansClass
def relative = baseClass - base - '/'
relative
}
else {
null
}
}
compileTestGroovy {
configure(groovyOptions.forkOptions) {
jvmArgs = [ '-Xmx768m']
}
}
test {
testLogging {
exceptionFormat ='full'
}
if (isTravisBuild) {
maxParallelForks = 2
jvmArgs = ['-server', '-Xmx512M', '-XX:MaxPermSize=128m']
forkEvery = 10
afterSuite {
System.out.print('.')
System.out.flush()
}
} else {
maxParallelForks = 4
forkEvery = 100
jvmArgs = ['-server', '-Xmx2048M', '-XX:MaxPermSize=256m']
}
if(System.getProperty("debug.tests")) {
jvmArgs '-Xmx2g', '-Xdebug', '-Xnoagent', '-Djava.compiler=NONE',
'-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005'
}
}
test.doFirst {
def tckClassesDir = project(":grails-datastore-gorm-tck").sourceSets.main.output.classesDir
def thisProjectsTests = // surely there is a less hardcoded way to do this
copy {
from tckClassesDir
into sourceSets.test.output.classesDir
include "**/*.class"
exclude { details ->
// Do not copy across any TCK class (or nested classes of that class)
// If there is a corresponding source file in the particular modules
// test source tree. Allows a module to override a test/helper.
if (!details.file.isFile()) {
return false
}
def candidatePath = details.file.absolutePath
def relativePath = toBaseClassRelativePathWithoutExtension(tckClassesDir.absolutePath, candidatePath)
if (relativePath == null) {
throw new IllegalStateException("$candidatePath does not appear to be in the TCK")
}
project.file("src/test/groovy/${relativePath}.groovy").exists()
}
}
}
}
if (isStandardGroovyMavenProject) {
configure([javadoc]) {
options.encoding "UTF-8"
options.docEncoding "UTF-8"
options.charSet "UTF-8"
options.jFlags "-Xms64M", "-Xmx512M", "-XX:MaxPermSize=256m"
}
configure([groovydoc]) {
groovyClasspath += configurations.documentation
}
modifyPom {
delegate.project {
def updatePom = pomInfo.clone()
updatePom.delegate = delegate
updatePom()
}
}
publishing {
repositories {
maven {
credentials {
def u = System.getenv("ARTIFACTORY_USERNAME") ?: project.hasProperty("artifactoryPublishUsername") ? project.artifactoryPublishUsername : ''
def p = System.getenv("ARTIFACTORY_PASSWORD") ?: project.hasProperty("artifactoryPublishPassword") ? project.artifactoryPublishPassword : ''
username = u
password = p
}
if(isBuildSnapshot) {
url "https://repo.grails.org/grails/libs-snapshots-local"
}
else {
url "https://repo.grails.org/grails/libs-releases-local"
}
}
}
publications {
maven(MavenPublication) {
from components.java
artifact sourcesJar {
classifier "sources"
}
artifact javadocJar {
classifier "javadoc"
}
pom.withXml {
def xml = asNode()
def dependency = xml.dependencies.find { dep -> dep.artifactId == 'slf4j-simple' }
dependency?.optional = true
xml.children().last() + pomInfo
}
}
}
}
}
}
configurations {
build
}
dependencies {
build "com.cenqua.clover:clover:3.0.2"
build "org.apache.ant:ant-junit:1.8.1"
build "org.apache.ant:ant-nodeps:1.8.1"
}
task install(dependsOn: subprojects*.tasks*.withType(PublishToMavenLocal))
task coreApiDocs(type: Groovydoc) {
def coreDocs = [ 'grails-datastore-core',
'grails-datastore-gorm',
'grails-datastore-gorm-hibernate-core',
'grails-datastore-gorm-hibernate4',
'grails-datastore-simple',
'grails-datastore-web',
'grails-datastore-gorm-test']
def projs = subprojects.findAll { project -> coreDocs.contains(project.name) }
source projs.collect { project -> project.sourceSets.main.allGroovy } + projs.collect { project -> project.sourceSets.main.allJava }
destinationDir = new File(buildDir, 'docs/api')
// Might need a classpath
docTitle = "GORM ${projectVersion}"
classpath = files(projs.collect {project -> project.sourceSets.main.compileClasspath + project.configurations.documentation})
groovyClasspath = files(projs.collect {project -> project.sourceSets.main.compileClasspath + project.configurations.documentation})
}
task allDocs(dependsOn: [getTasksByName("docs", true),coreApiDocs]) << {
def docTasks = getTasksByName("docs", true)
def groovydocTasks = getTasksByName("groovydoc", true)
def allDocsDir = "$buildDir/docs"
mkdir allDocsDir
def stores = []
for(task in docTasks) {
def dir = task.destinationDir
def projectName = task.project.name
if (projectName.endsWith("-core")) {
mkdir "$allDocsDir/manual"
copy {
from dir
into "$allDocsDir/manual"
}
}
else {
def storeName = projectName["grails-documentation-".size()..-1]
// for the moment skip REST client
if(storeName != 'rest-client') {
stores << storeName
def docsDir = "$allDocsDir/$storeName"
mkdir docsDir
def groovydocTask = groovydocTasks.find { it.project.name == "grails-datastore-$storeName" }
if (groovydocTask == null) groovydocTask = groovydocTasks.find { it.project.name == "grails-datastore-gorm-$storeName" }
if (groovydocTask != null) {
mkdir "$docsDir/api"
groovydocTask.actions.each { it.execute(groovydocTask) }
copy {
from groovydocTask.destinationDir
into "$docsDir/api"
}
}
mkdir "$docsDir/manual"
copy {
from dir
into "$docsDir/manual"
}
}
}
def engine = new groovy.text.SimpleTemplateEngine()
def binding = [
datastores:stores.collect { "<li><a href=\"$it/index.html\">GORM for ${it[0].toUpperCase()}${it[1..-1]}</a></li>" }.join(System.getProperty("line.separator"))
]
def template = engine.createTemplate(new File("src/docs/resources/core.template")).make(binding)
new File("$allDocsDir/index.html").text = template.toString()
copy {
from "src/docs/resources/assets"
into allDocsDir
}
for(store in stores) {
def index = "$allDocsDir/$store/index.html"
def storeName = "${store[0].toUpperCase()}${store[1..-1]}".toString()
binding = [
datastore:storeName
]
template = engine.createTemplate(new File("src/docs/resources/datastore.template")).make( binding )
new File(index).text = template.toString()
}
}
}
task test(dependsOn: getTasksByName("test", true)) << {
def reportsDir = "${buildDir}/reports"
// Aggregate the test results
ant.taskdef(
name: 'junitreport2',
classname: "org.apache.tools.ant.taskdefs.optional.junit.XMLResultAggregator",
classpath: configurations.build.asPath
)
def testReportsDir = new File("${reportsDir}/tests")
if (testReportsDir.exists()) {
testReportsDir.deleteDir()
}
testReportsDir.mkdirs()
ant.junitreport2(todir: testReportsDir) {
subprojects.each {
def testResultsDir = "${it.buildDir}/test-results"
if (new File(testResultsDir).exists()) {
fileset(dir: testResultsDir) {
include(name: "TEST-*.xml")
}
}
}
report(todir: testReportsDir)
}
// Aggregate the coverage results
if (project.hasProperty("withClover")) {
def db = "clover/clover.db"
def mergedDb = "${buildDir}/${db}"
def cloverReportsDir = "${reportsDir}/clover"
ant.taskdef(resource: "cloverlib.xml", classpath: configurations.build.asPath)
ant."clover-merge"(initstring: mergedDb) {
subprojects.each {
def projectCloverDb = "${it.buildDir}/${db}"
if (new File(projectCloverDb).exists()) {
cloverdb(initstring: projectCloverDb)
}
}
}
ant."clover-report"(initstring: mergedDb) {
current(outfile:"${cloverReportsDir}/clover.xml")
}
ant."clover-html-report"(initstring: mergedDb, outdir:"${cloverReportsDir}/html")
}
}