This repository was archived by the owner on May 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathbuild.gradle
More file actions
1066 lines (969 loc) · 39.7 KB
/
Copy pathbuild.gradle
File metadata and controls
1066 lines (969 loc) · 39.7 KB
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
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
*/
import org.apache.tools.ant.filters.ReplaceTokens
project.ext {
title = "Apache Zest™ (Java Edition) SDK"
description = "Apache Zest™ (Java Edition) is a framework for domain centric application development, including evolved concepts from AOP, DI and DDD."
testFailures = [ ]
mainClassName = 'org.apache.zest.container.Main'
groovycMain_mx = "700m"
groovycMain_permSize = "512m"
groovycMain_maxPermSize = "512m"
}
buildscript {
repositories {
maven { url "https://plugins.gradle.org/m2/" }
jcenter()
}
dependencies {
classpath 'gradle.plugin.org.nosphere.apache:creadur-rat-gradle:0.2.1'
classpath 'gradle.plugin.org.nosphere.honker:honker-gradle:0.2.2'
classpath 'org.hibernate.build.gradle:gradle-maven-publish-auth:2.0.1'
}
}
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'signing'
apply plugin: 'maven'
apply plugin: 'maven-publish-auth'
apply plugin: 'project-report'
apply from: 'libraries.gradle'
apply plugin: 'org.nosphere.apache.rat'
targetCompatibility = "1.8"
sourceCompatibility = "1.8"
// Collect the modules that fulfills the Release Criteria.
project.ext {
releaseSpec = new org.apache.zest.gradle.plugin.ModuleReleaseSpecification()
releaseApprovedProjects = allprojects.findAll( { p -> rootProject.releaseSpec.satisfiedBy( p ) } )
}
// Toggle signing, used by the source distribution by setting the skipSigning property in gradle.properties
project.ext.skipSigning = rootProject.hasProperty( 'skipSigning' ) ? rootProject.skipSigning : false
rat {
onlyIf { version != '0' }
excludes = [
'**/.DS_Store/**', '**/._*',
// Git Files
'**/.git/**', '**/.gitignore',
// Gradle Files
'gradle/wrapper/**', '**/gradlew', '**/gradlew.bat', '**/.gradle/**',
// Build Output
'**/build/**', '**/derby.log', 'out/**',
// IDE Files
'**/.idea/**', '**/*.iml', '**/*.ipr', '**/*.iws',
'**/.settings/**', '**/.classpath', '**/.project',
'**/.gradletasknamecache', '**/private/cache/**',
'**/.nb-gradle-properties', '**/.nb-gradle/**',
// JSON files are not allowed to have comments, according to http://www.json.org/ and http://www.ietf.org/rfc/rfc4627.txt
'**/*.json',
// Various Text Resources
'**/README.*','**/README*.*', '**/TODO',
'**/src/main/resources/**/*.txt',
'**/src/test/resources/**/*.txt',
'libraries/rest-server/src/main/resources/**/*.htm',
'libraries/rest-server/src/main/resources/**/*.atom',
'tools/qidea/src/main/resources/**/*.ft',
'tools/qidea/src/main/resources/**/*.template',
// Graphic Resources
'**/*.svg', '**/*.gif', '**/*.png', '**/*.jpg', '**/*.psd',
// Keystores
'**/*.jceks',
// Syntax Highlighter - MIT
'manual/**/sh*.css', 'manual/**/sh*.js',
// jQuery & plugins - MIT
'manual/**/jquery*.js',
// W3C XML Schemas - W3C Software License
'samples/rental/src/main/resources/*.xsd',
// templates that will become the user's source files, should not have license headers
'tools/shell/src/dist/etc/templates/**',
]
}
// External tools BEGIN ---------------------------------------------------
// IDEA plugin configuration
idea.project.ipr {
withXml { provider ->
provider.node.component.find { it.@name == 'VcsDirectoryMappings' }.mapping.@vcs = 'Git'
}
}
// External tools END -----------------------------------------------------
// Define repositories URLs here so we can reuse them in the build script
// Needed as Gradle forbid access to declared repositories URLs by design
// Releasable submodules should not declare repositories in their own build files
def repos_urls = [
mavenCentral: "http://repo1.maven.org/maven2/",
ops4j: "http://repository.ops4j.org/maven2/",
restlet: 'http://maven.restlet.org/',
clojars: "http://clojars.org/repo/",
]
allprojects {
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'signing'
apply plugin: 'java'
// apply plugin: 'checkstyle'
apply plugin: 'project-report'
apply plugin: 'maven'
apply plugin: 'org.nosphere.honker'
defaultTasks 'classes', 'test'
group = name == 'org.apache.zest' ? 'org.apache.zest' : name.substring( 0, name.lastIndexOf( '.' ) )
if( version == 'unspecified' ) {
version = System.properties.version ?: "0"
}
// UTF-8 For all compilations and javadocs
// Deprecation warnings for all compilations
// Unchecked warnings for non-test core compilations
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
options.compilerArgs << "-Xlint:deprecation"
}
if("core".equals(group)) {
tasks.matching({ task -> task instanceof JavaCompile && !task.name.contains('test') }).
each({ task -> task.options.compilerArgs << "-Xlint:unchecked" })
}
tasks.withType(Javadoc) {
options.encoding = 'UTF-8'
options.docEncoding = 'UTF-8'
options.charSet = 'UTF-8'
options.noTimestamp = true
options.links = [
'http://docs.oracle.com/javase/8/docs/api/',
'https://stleary.github.io/JSON-java/',
'http://junit.org/junit4/javadoc/latest/'
]
// exclude '**/internal/**'
}
repositories {
mavenCentral()
maven { name 'ops4j-repo'; url repos_urls.ops4j }
maven { name 'restlet-repo'; url repos_urls.restlet }
maven { name 'clojars-repo'; url repos_urls.clojars }
}
// Artifact upload global configuration BEGIN -----------------------------
def uploadSnapshots = version.contains("SNAPSHOT")
def uploadReleases = ! uploadSnapshots
// By default RELEASES are signed, SNAPSHOTS are not
// Signing can be turned on or off by setting the uploadSigned property
def uploadSigned = rootProject.hasProperty('uploadSigned') \
? rootProject.uploadSigned : uploadReleases \
? true : false
// By default RELEASES must satisfy ReleaseSpecification, SNAPSHOT don't
// ReleaseSpecification usage can be turned on or off by setting the uploadReleaseSpec property
def uploadReleaseSpec = rootProject.hasProperty('uploadReleaseSpec') \
? rootProject.uploadReleaseSpec : uploadReleases \
? true : false
// By default RELEASES and SNAPSHOTS are uploaded using HTTP
// Used Wagon can be overriden by setting the uploadWagon property
// def wagonSSH = "org.apache.maven.wagon:wagon-ssh:2.2"
// def wagonWEBDAV = "org.apache.maven.wagon:wagon-webdav:1.0-beta-2"
def wagonHTTP = "org.apache.maven.wagon:wagon-http:2.2"
def uploadWagon = rootProject.hasProperty('uploadWagon') \
? rootProject.uploadWagon : wagonHTTP
// By default RELEASES and SNAPSHOTS are uploaded to Apache Nexus
// Target repository can be overriden by setting the uploadRepository property
def releasesRepositoryName = "apache.releases.https"
def releasesRepository = "https://repository.apache.org/service/local/staging/deploy/maven2"
def snapshotsRepositoryName = "apache.snapshots.https"
def snapshotsRepository = "https://repository.apache.org/content/repositories/snapshots"
def uploadRepositoryName = rootProject.hasProperty('uploadRepositoryName') \
? rootProject.uploadRepositoryName \
: uploadReleases ? releasesRepositoryName : snapshotsRepositoryName
def uploadRepository = rootProject.hasProperty('uploadRepository') \
? rootProject.uploadRepository \
: uploadReleases ? releasesRepository : snapshotsRepository
// No username/password is provided by default
// If needed set them using the uploadUsername and uploadPassword properties
def uploadUsername = rootProject.hasProperty('uploadUsername') ? rootProject.uploadUsername : null
def uploadPassword = rootProject.hasProperty('uploadPassword') ? rootProject.uploadPassword : null
// Artifact upload global configuration END -------------------------------
configurations {
archives
deployerJars
provided
compile.extendsFrom provided
runtime.extendsFrom compile
}
dependencies {
testCompile( libraries.ant )
testCompile( libraries.ant_junit )
testCompile( libraries.junit )
testRuntime( libraries.asm, libraries.asm_commons, libraries.asm_util )
deployerJars( uploadWagon )
}
test.onlyIf { !project.hasProperty( 'skipTests' ) }
test {
testLogging {
info {
exceptionFormat "full"
}
}
}
sourceSets {
main {
output.dir( honkerGenDependencies.outputDir, builtBy: honkerGenDependencies )
output.dir( honkerGenLicense.outputDir, builtBy: honkerGenLicense )
output.dir( honkerGenNotice.outputDir, builtBy: honkerGenNotice )
}
docs {
resources {
srcDir 'src/docs'
}
}
}
honker {
// Project License, applied to all submodules
license 'Apache 2'
// Dependencies (transitive or not) with no license information, overriding them
licenseOverride { candidate ->
if( candidate.group == 'asm' || candidate.module == 'prefuse-core' ) {
candidate.license = 'BSD 3-Clause'
}
if( candidate.group == 'org.apache.httpcomponents'
|| candidate.group == 'net.java.dev.jna'
|| candidate.group == 'lucene'
|| candidate.group == 'jdbm'
|| candidate.group == 'org.osgi'
|| candidate.group.startsWith( 'org.restlet' ) ) {
candidate.license = 'Apache 2'
}
}
}
honkerGenNotice {
header = 'Apache Zest'
footer = 'This product includes software developed at\nThe Apache Software Foundation (http://www.apache.org/).\n'
}
check.dependsOn honkerCheck
project.ext {
javaDir = new File( "$projectDir/src/main/java" )
scalaDir = new File( "$projectDir/src/main/scala" )
groovyDir = new File( "$projectDir/src/main/groovy")
documentationDir = new File( "$projectDir/src/docs" )
testJavaDir = new File( "$projectDir/src/tests/java" )
testScalaDir = new File( "$projectDir/src/tests/scala" )
testGroovyDir = new File( "$projectDir/src/tests/groovy")
}
// Actual code projects BEGIN -------------------------------------------
if( ext.javaDir.isDirectory() || ext.scalaDir.isDirectory() || ext.groovyDir.isDirectory() ||
ext.testJavaDir.isDirectory() || ext.testScalaDir.isDirectory() || ext.testGroovyDir.isDirectory() )
{
apply plugin: 'jacoco'
apply plugin: 'osgi'
apply plugin: VersionClass
apply plugin: AsciidocBuildInfo
// if( name == "org.apache.zest.core.runtime" )
// {
// checkstyleMain {
// configFile = new File( "$rootProject.projectDir.absolutePath/etc/zest-runtime-checkstyle.xml" )
// ignoreFailures = true
// }
// }
// else
// {
// checkstyleMain {
// configFile = new File( rootProject.projectDir.absolutePath.toString() + '/etc/zest-api-checkstyle.xml' )
// ignoreFailures = true
// reporting.baseDir = "$rootProject.reporting.baseDir/checkstyle"
// }
// }
// checkstyleTest {
// configFile = new File( "$rootProject.projectDir.absolutePath/etc/zest-tests-checkstyle.xml" )
// ignoreFailures = true
// }
//
// checkstyleVersion {
// configFile = new File( "$rootProject.projectDir.absolutePath/etc/zest-tests-checkstyle.xml" )
// ignoreFailures = true
// }
jar {
manifest {
license = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
docURL = 'https://zest.apache.org'
description = project.description ?: 'Apache Zest™ (Java Edition) is a platform for Composite Oriented Programming'
vendor = 'The Apache Software Foundation, https://www.apache.org'
instruction '-debug', 'true'
}
}
signing {
required { rootProject.version != '0' && uploadSigned }
sign configurations.archives
}
signArchives.onlyIf { !rootProject.skipSigning }
task sourceJar( type: Jar ) {
classifier = "sources"
from sourceSets.main.allSource
}
task testSourceJar( type: Jar ) {
classifier = "testsources"
from sourceSets.test.allSource
}
task javadocJar( type: Jar ) {
classifier = "javadoc"
from javadoc.destinationDir
dependsOn javadoc
}
artifacts {
archives sourceJar, testSourceJar, javadocJar
}
def testProperties = [
'proxySet': System.properties[ 'proxySet' ],
'proxyHost': System.properties[ 'proxyHost' ],
'proxyPort': System.properties[ 'proxyPort' ] ]
test {
maxHeapSize = "1024m"
systemProperties = testProperties
systemProperties['user.dir'] = workingDir // GRADLE-2859
ignoreFailures = true
reports.html.enabled(true)
afterSuite { descriptor, result ->
if( result.resultType == TestResult.ResultType.FAILURE )
{
rootProject.ext.testFailures << project
}
}
}
jacoco {
toolVersion = '0.7.5.201505241946'
}
// // Create checkstyle report
// task checkstyleReport( type: Xslt, dependsOn: check ) {
// source project.checkstyle.reportsDir
// include '*.xml'
// destDir = file( "build/reports/checkstyle/" )
// extension = 'html'
// stylesheetFile = file( "$rootProject.projectDir/etc/checkstyle-noframes.xsl" )
// }
//
// Dependency Report generate only the runtime configuration
// The report is packaged in the SDK distributions
dependencyReport {
configurations = [ project.configurations.runtime ]
}
task minBuild {
dependsOn classes
dependsOn test
}
}
// Actual code projects END ---------------------------------------------
// Upload Archives - Artifact Deployment
uploadArchives.doFirst {
if( version == "0" )
{
throw new GradleException( "'version' must be given as a system property to perform a release." )
}
}
uploadArchives.onlyIf { ( !uploadReleaseSpec || ( releaseApprovedProjects.contains( project ) || project == rootProject ) ) && !project.hasProperty( 'skipUpload' ) }
uploadArchives {
dependsOn check
repositories.mavenDeployer {
if( uploadSigned )
beforeDeployment { MavenDeployment deployment -> signing.signPom( deployment ) }
configuration = configurations.deployerJars
repository(id: uploadRepositoryName, url: uploadRepository) {
if( uploadUsername )
authentication(userName: uploadUsername, password: uploadPassword)
}
snapshotRepository(id: uploadRepositoryName, url: uploadRepository) {
if( uploadUsername )
authentication(userName: uploadUsername, password: uploadPassword)
}
}
}
apply from: "$rootProject.projectDir/maven-compat.gradle"
apply plugin: 'maven-publish-auth' // Bug in maven-publish-auth require apply after uploadArchives setup
idea.module.iml {
whenMerged { module ->
module.dependencies*.exported = true
}
}
} // allprojects END -------------------------------------------------------
// Allow easy download of all dependencies to go offline
// ./gradlew goOffline
task goOffline {
doLast {
allprojects.configurations.flatten()*.resolvedConfiguration
}
}
gradle.taskGraph.whenReady {taskGraph ->
taskGraph.allTasks.last().doLast {
if( rootProject.ext.testFailures )
{
println "\nTest failures in:"
rootProject.ext.testFailures.unique().each { project -> println " " + project.name }
println ""
throw new RuntimeException( "There was TEST FAILURES!! See list above." )
}
}
}
task globalTestReport( type: TestReport ) {
destinationDir = file("$buildDir/reports/tests")
reportOn subprojects*.test
}
test {
dependsOn subprojects*.test, globalTestReport
reports.html.enabled = false
}
// Jacoco
configurations {
jacoco
}
dependencies {
jacoco 'org.jacoco:org.jacoco.ant:0.7.5.201505241946'
}
// Generate a global code codeverage report
task coverageReport {
dependsOn subprojects*.test
def outputPath = "build/reports/coverage"
inputs.dir subprojects.collect { p -> "${p.buildDir.path}/jacoco" }
outputs.dir outputPath
doLast {
def coveredProjects = subprojects.findAll { p -> new File( "${p.buildDir.path}/jacoco" ).exists() }
def coreProjects = coveredProjects.findAll { p -> p.name.startsWith('org.apache.zest.core' ) }
def libProjects = coveredProjects.findAll { p -> p.name.startsWith( 'org.apache.zest.lib' ) }
def extProjects = coveredProjects.findAll { p -> p.name.startsWith( 'org.apache.zest.ext' ) }
def toolsProjects = coveredProjects.findAll { p -> p.name.startsWith( 'org.apache.zest.tool' ) }
def tutoProjects = coveredProjects.findAll { p -> p.name.startsWith( 'org.apache.zest.tuto' ) }
def samplesProjects = coveredProjects.findAll { p -> p.name.startsWith( 'org.apache.zest.sample' ) }
ant {
taskdef name:'jacocoreport', classname: 'org.jacoco.ant.ReportTask', classpath: configurations.jacoco.asPath
mkdir dir: outputPath
jacocoreport {
executiondata {
coveredProjects.collect { p -> fileset( dir: "${p.buildDir.path}/jacoco" ) { include( name: '*.exec' ) } }
}
structure( name: "Apache Zest™ (Java Edition) SDK" ) {
group( name: "Core" ) {
classfiles { coreProjects.collect { p -> fileset dir: "${p.buildDir.path}/classes/main" } }
sourcefiles { coreProjects.collect { p -> fileset dir: "${p.projectDir.path}/src/main/java" } }
}
group( name: "Libraries" ) {
classfiles { libProjects.collect { p -> fileset dir: "${p.buildDir.path}/classes/main" } }
sourcefiles { libProjects.collect { p -> fileset dir: "${p.projectDir.path}/src/main/java" } }
}
group( name: "Extensions" ) {
classfiles { extProjects.collect { p -> fileset dir: "${p.buildDir.path}/classes/main" } }
sourcefiles { extProjects.collect { p -> fileset dir: "${p.projectDir.path}/src/main/java" } }
}
group( name: "Tools" ) {
classfiles { toolsProjects.collect { p -> fileset dir: "${p.buildDir.path}/classes/main" } }
sourcefiles { toolsProjects.collect { p -> fileset dir: "${p.projectDir.path}/src/main/java" } }
}
group( name: "Tutorials" ) {
classfiles { tutoProjects.collect { p -> fileset dir: "${p.buildDir.path}/classes/main" } }
sourcefiles { tutoProjects.collect { p -> fileset dir: "${p.projectDir.path}/src/main/java" } }
}
group( name: "Samples" ) {
classfiles { samplesProjects.collect { p -> fileset dir: "${p.buildDir.path}/classes/main" } }
sourcefiles { samplesProjects.collect { p -> fileset dir: "${p.projectDir.path}/src/main/java" } }
}
}
csv destfile: "${outputPath}/jacoco.csv", encoding: "UTF-8"
xml destfile: "${outputPath}/jacoco.xml", encoding: "UTF-8"
html destdir: outputPath, encoding: "UTF-8", locale: "en", footer: "Apache Zest™ (Java Edition) SDK"
}
}
}
}
check.dependsOn coverageReport
// Build the whole SDK public Javadoc
task javadocs( type: Javadoc ) {
options.docFilesSubDirs = true
options.encoding = "UTF-8"
options.overview = "${rootProject.projectDir}/src/javadoc/overview.html"
title = "${rootProject.title} ${version}"
def apiSources = releaseApprovedProjects.findAll( { project ->
( project.name.startsWith( 'org.apache.zest.core' ) && !project.name.startsWith( 'org.apache.zest.core.runtime' ) ) ||
project.name.startsWith( 'org.apache.zest.library' ) ||
project.name.startsWith( 'org.apache.zest.extension' ) ||
project.name.startsWith( 'org.apache.zest.tool' )
} )
source apiSources.collect { project ->
project.sourceSets.main.allJava
}
destinationDir = project.file( "$project.docsDir/javadocs" )
// Might need a classpath
classpath = files( apiSources.collect { project ->
project.sourceSets.main.compileClasspath
} )
options.group( [ "Core API": [ "org.apache.zest.api", "org.apache.zest.api.*", "org.apache.zest.io", "org.apache.zest.functional" ],
"Core Bootstrap": [ "org.apache.zest.bootstrap", "org.apache.zest.bootstrap.*" ],
"Core SPI": [ "org.apache.zest.spi", "org.apache.zest.spi.*" ],
"Libraries": [ "org.apache.zest.library.*" ],
"Extensions": [ "org.apache.zest.valueserialization.*", "org.apache.zest.entitystore.*", "org.apache.zest.index.*", "org.apache.zest.metrics.*", "org.apache.zest.cache.*", "org.apache.zest.migration", "org.apache.zest.migration.*" ],
"Tools": [ "org.apache.zest.tools.*", "org.apache.zest.envisage", "org.apache.zest.envisage.*" ],
"Test Support": [ "org.apache.zest.test", "org.apache.zest.test.*" ]
] )
}
task archiveJavadocs(type: Copy ) {
dependsOn javadocs
if( rootProject.version == '0' || rootProject.version.contains( "SNAPSHOT" ) )
{
into( "$rootProject.projectDir/../zest-web/site/content/java/develop/javadocs/" )
}
else
{
into( "$rootProject.projectDir/../zest-web/site/content/java/$version/javadocs/" )
}
from( 'build/docs/javadoc/' )
}
// Build All
task buildAll( dependsOn: [
javadocs,
check,
jar,
subprojects*.dependencyReport,
subprojects*.assemble,
':org.apache.zest.manual:website'
] ) { }
// Generate license headers with comment styles
def licenseHeader_wrap( base, top, left, bottom ) {
( top ? "$top\n" : '' ) + base.readLines().collect{ "${left}${it}" }.join( '\n' ) + '\n' + ( bottom ? "$bottom\n" : '' )
}
def licenseHeader( flavour ) {
def base = project.file( 'etc/header.txt' ).text
def header
switch( flavour ) {
case 'java': case 'groovy': case 'scala': case 'js':
header = licenseHeader_wrap( base, '/*', ' * ', ' */' ) ; break
case 'xml': case 'html':
header = licenseHeader_wrap( base, '<!--', ' ', '-->' ) ; break
case 'txt': case 'shell': case 'python': case 'ruby':
header = licenseHeader_wrap( base, null, '# ', null ) ; break
case 'adoc': case 'asciidoc':
header = licenseHeader_wrap( base, null, '// ', null ) ; break
default:
header = base
}
header
}
task generateBinDistGoOfflineHelpers {
def goOfflineGradleFile = file( 'build/go-offline-helpers/go-offline.gradle' )
def goOfflinePomFile = file( 'build/go-offline-helpers/go-offline.pom')
outputs.file goOfflineGradleFile
outputs.file goOfflinePomFile
doLast {
def goOfflineGradle = licenseHeader( 'java' )
goOfflineGradle += '// This gradle build file has the sole purpose of downloading all dependencies in a directory relative to this file named \'dependencies\'.\n'
goOfflineGradle += '// Use the following command: gradle -b go-offline.gradle download\n'
goOfflineGradle += 'apply plugin: \'java\'\nconfigurations { download }\nrepositories {\n'
def goOfflinePom = licenseHeader( 'xml' )
goOfflinePom += '<project>\n <modelVersion>4.0.0</modelVersion>\n'
goOfflinePom += " <groupId>org.apache.zest</groupId>\n <artifactId>go-offline-helper</artifactId>\n <version>$version</version>\n"
goOfflinePom += ' <packaging>pom</packaging>\n'
goOfflinePom += ' <!--\n This pom has the sole purpose of downloading all dependencies in a directory relative to this file named \'dependencies\'.\n'
goOfflinePom += ' Use the following command:\n\n mvn -f go-offline.pom validate\n -->\n <repositories>\n'
def repoCount = 1
repos_urls.each { repo_url ->
goOfflineGradle += " maven { url '${repo_url.value}' }\n"
goOfflinePom += " <repository><id>go-offline-repo-$repoCount</id><url>${repo_url.value}</url></repository>\n"
repoCount++
}
goOfflineGradle += '}\ndependencies {\n'
goOfflinePom += ' </repositories>\n <dependencies>\n'
// Do the global dependency resolution here so there won't be any suprise when using the helpers
// This also allow to apply the resolution strategy defined in libraries.gradle
// WARN some of our modules depends on != versions of some artifacts, this resolution flatten this using the most up to date
def allRuntimeDeps = releaseApprovedProjects.collect{ it.configurations.runtime.allDependencies }.flatten()
rootProject.configurations.create( 'goOfflineHelpers' )
rootProject.dependencies { allRuntimeDeps.each{ goOfflineHelpers it } }
rootProject.configurations.goOfflineHelpers.incoming.resolutionResult.allComponents.each { comp ->
def depCoords = "${comp.moduleVersion.group}:${comp.moduleVersion.name}:${comp.moduleVersion.version}"
if( !comp.moduleVersion.group.startsWith( 'org.apache.zest' ) ) {
goOfflineGradle += " download( '$depCoords' ) { transitive = false }\n"
goOfflinePom += " <dependency><groupId>${comp.moduleVersion.group}</groupId><artifactId>${comp.moduleVersion.name}</artifactId><version>${comp.moduleVersion.version}</version></dependency>\n"
}
}
goOfflineGradle += """}
task download( type: Copy ) {
def sources = configurations.download.resolvedConfiguration.resolvedArtifacts.collect { artifact ->
project.dependencies.create( [ group: artifact.moduleVersion.id.group, name: artifact.moduleVersion.id.name, version: artifact.moduleVersion.id.version, classifier: 'sources' ] )
}
def javadocs = configurations.download.resolvedConfiguration.resolvedArtifacts.collect { artifact ->
project.dependencies.create( [ group: artifact.moduleVersion.id.group, name: artifact.moduleVersion.id.name, version: artifact.moduleVersion.id.version, classifier: 'javadoc' ] )
}
from configurations.download
from configurations.detachedConfiguration( sources as Dependency[] ).resolvedConfiguration.lenientConfiguration.getFiles( Specs.SATISFIES_ALL )
from configurations.detachedConfiguration( javadocs as Dependency[] ).resolvedConfiguration.lenientConfiguration.getFiles( Specs.SATISFIES_ALL )
into file( 'dependencies/' )
}
"""
goOfflinePom += """ </dependencies>\n <build><plugins><plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>go-offline-jars</id><phase>validate</phase>
<goals><goal>copy-dependencies</goal></goals>
<configuration>
<outputDirectory>\${project.basedir}/dependencies</outputDirectory>
<excludeTransitive>true</excludeTransitive>
</configuration>
</execution>
<execution>
<id>go-offline-sources</id><phase>validate</phase>
<goals><goal>copy-dependencies</goal></goals>
<configuration>
<classifier>sources</classifier><failOnMissingClassifierArtifact>false</failOnMissingClassifierArtifact>
<outputDirectory>\${project.basedir}/dependencies</outputDirectory>
<excludeTransitive>true</excludeTransitive>
</configuration>
</execution>
<execution>
<id>go-offline-javadocs</id><phase>validate</phase>
<goals><goal>copy-dependencies</goal></goals>
<configuration>
<classifier>javadoc</classifier><failOnMissingClassifierArtifact>false</failOnMissingClassifierArtifact>
<outputDirectory>\${project.basedir}/dependencies</outputDirectory>
<excludeTransitive>true</excludeTransitive>
</configuration>
</execution>
</executions>
</plugin></plugins></build>
</project>
"""
goOfflineGradleFile.parentFile.mkdirs()
goOfflinePomFile.parentFile.mkdirs()
goOfflineGradleFile.text = goOfflineGradle
goOfflinePomFile.text = goOfflinePom
}
}
def srcDistFilesImages = copySpec {
from '.'
include '*.txt'
include 'doap.rdf'
include '*.gradle'
include 'gradlew*'
include 'gradle/**'
include 'etc/**'
include 'buildSrc/**'
include 'src/**'
releaseApprovedProjects.each { p ->
def relPath = new File( project.projectDir.toURI().relativize( p.projectDir.toURI() ).toString() )
include "$relPath/**"
}
include 'manual/**'
include 'samples/**'
include 'tests/**'
include 'tutorials/**'
include 'tools/shell/**'
// Filtered, see below
exclude 'settings.gradle'
exclude 'gradle.properties'
// Excludes
exclude '**/build/' // Build output
exclude 'derby.log' // Derby test garbage
exclude '**/*.iml' // IDEA files
exclude '**/*.ipr' // IDEA files
exclude '**/*.iws' // IDEA files
exclude '**/.idea' // IDEA files
exclude '**/out/*' // IDEA build output
exclude '**/.classpath' // Eclipse files
exclude '**/.project' // Eclipse files
exclude '**/.settings' // Eclipse files
exclude '**/.nb-gradle/' // Netbeans files
exclude '**/.nb-gradle*' // Netbeans files
exclude '**/.git/' // Git directories
exclude '**/.git*' // Git files
exclude '**/.gradle/' // Gradle management files
exclude '**/.gradletasknamecache' // Gradle cache
into '.'
}
task srcDistFilteredFiles() {
// Generates various files for the source distribution
// - settings.gradle
// - gradle.properties to set version !
def filteredDir = new File( "$project.buildDir/tmp/srcDistFilteredFiles")
outputs.file filteredDir
doLast {
// Settings
def settingsFile = new File( filteredDir, 'settings.gradle' )
settingsFile.parentFile.mkdirs()
def filteredSettings = ''
project.file( 'settings.gradle' ).readLines().each { line ->
if( line.contains( '\'libraries:' ) || line.contains( '\'extensions:' ) || line.contains( '\'tools:' ) ) {
def accepted = false
releaseApprovedProjects.collect{it.projectDir}.each { acceptedProjectDir ->
if( line.contains( "'${acceptedProjectDir.parentFile.name}:${acceptedProjectDir.name}'" ) ) {
accepted = true
}
}
if( accepted ) {
filteredSettings += "$line\n"
}
} else {
filteredSettings += "$line\n"
}
}
settingsFile.text = filteredSettings
// gradle.properties
def gradlePropsFile = new File( filteredDir, 'gradle.properties' )
gradlePropsFile.parentFile.mkdirs()
gradlePropsFile.text = project.file( 'gradle.properties' ).text + "\nskipSigning=true\nskipAsciidocIfAbsent=true\n\nversion=$version\n"
}
}
def srcDistFilteredFilesImage = copySpec {
from srcDistFilteredFiles
into '.'
}
def srcDistImage = copySpec {
into "apache-zest-java-$version-src"
with srcDistFilesImages
with srcDistFilteredFilesImage
}
def reportsDistImage = copySpec {
from "$buildDir/reports"
into( "docs/reports" )
}
def docsImage = copySpec {
from "build/docs"
from "manual/build/docs/website"
into( "docs" )
}
def runtimeDependenciesListImage = copySpec {
releaseApprovedProjects.collect { p ->
into( "libs/" ) {
from "$p.buildDir/reports/project/dependencies.txt"
rename 'dependencies.txt', "${p.name}-${p.version}-runtime-deps.txt"
}
}
into( '.' ) {
from generateBinDistGoOfflineHelpers.outputs
}
}
def libsImage = copySpec {
releaseApprovedProjects.collect { proj ->
into( "libs/" ) {
from proj.configurations.archives.artifacts.files
exclude '**-testsources.jar'
exclude '**/*.asc'
}
}
}
def extraDistTextImage = copySpec {
releaseApprovedProjects.collect { p ->
from fileTree(dir: "$p.projectDir/src/dist/", include: '**', exclude: "**/*.jar*")
eachFile {
filter(ReplaceTokens, tokens: [version: version])
}
}
into( "." )
}
def extraDistBinImage = copySpec {
releaseApprovedProjects.collect { p ->
from "$p.projectDir/src/dist/"
include "**/*.jar"
include "**/*.jar_"
}
into( "." )
}
def binDistNoticesImage = copySpec {
from( "$projectDir/LICENSE.txt")
from( "$projectDir/src/bin-dist" )
into( "." )
}
def binDistImage = copySpec {
into "apache-zest-java-$version-bin"
with binDistNoticesImage
with docsImage
with reportsDistImage
with runtimeDependenciesListImage
with extraDistTextImage
with extraDistBinImage
with libsImage
}
task zipSources( type: Zip ) {
baseName = 'apache-zest-java'
with srcDistImage
classifier = 'src'
}
task tarSources( type: Tar ) {
baseName = 'apache-zest-java'
with srcDistImage
compression = Compression.GZIP
classifier = 'src'
}
task zipBinaries( type: Zip, dependsOn: buildAll ) {
baseName = 'apache-zest-java'
classifier = 'bin'
with binDistImage
}
task tarBinaries( type: Tar, dependsOn: buildAll ) {
baseName = 'apache-zest-java'
classifier = 'bin'
compression = Compression.GZIP
with binDistImage
}
// Checksum distributions
tasks.withType( Zip ) { task ->
task.doLast {
ant.checksum file: task.archivePath, algorithm: 'MD5'
ant.checksum file: task.archivePath, algorithm: 'SHA-512'
}
}
tasks.withType( Tar ) { task ->
task.doLast {
ant.checksum file: task.archivePath, algorithm: 'MD5'
ant.checksum file: task.archivePath, algorithm: 'SHA-512'
}
}
artifacts {
archives zipSources, tarSources, zipBinaries, tarBinaries
}
signing {
required { rootProject.version != '0' && !rootProject.version.contains( 'SNAPSHOT' ) }
sign configurations.archives
}
signArchives.onlyIf { !rootProject.skipSigning }
task dist( type: Copy, dependsOn: install ) {
description "Unpack the binary distribution"
group = "distributions"
with binDistImage
into "$buildDir/dist"
}
// Tasks for source and binary distributions checks
def unpackedSrcDistDir = file( "build/unpacked-distributions/src/apache-zest-java-$version-src" )
def unpackedBinDistDir = file( "build/unpacked-distributions/bin/apache-zest-java-$version-bin" )
task unpackSrcDist( type: Copy ) {
description "Unpack the source distribution"
group = "distributions"
with srcDistImage
into 'build/unpacked-distributions/src'
}
task checkSrcDist( type: GradleBuild, dependsOn: unpackSrcDist ) {
description = "Check the source distribution by running the 'check' and 'assemble' tasks inside"
group = "distributions"
buildFile = "$unpackedSrcDistDir/build.gradle"
tasks = [ 'check', 'assemble' ]
}
task unpackBinDist( type: Copy, dependsOn: buildAll ) {
description "Unpack the binary distribution"
group = "distributions"
with binDistImage
into 'build/unpacked-distributions/bin'
}
task checkBinDist_rat( type: org.apache.rat.gradle.RatTask, dependsOn: unpackBinDist ) {
description "Check the binary distribution using Apache RAT"
group = "distributions"
inputDir = unpackedBinDistDir
reportDir = file( 'build/reports/rat-bin-dist' )
excludes = []
}
task checkBinDist_goOfflineGradle( type: GradleBuild, dependsOn: unpackBinDist ) {
description "Check the binary distribution Gradle go-offline helper"
group = "distributions"
def dependenciesDir = new File( unpackedBinDistDir, 'dependencies' )
doFirst { dependenciesDir.deleteDir() }
buildFile = "$unpackedBinDistDir/go-offline.gradle"
tasks = [ 'download' ]
doLast {
releaseApprovedProjects*.configurations.runtime.allDependencies.findAll({it.name}).each { dep ->
def jarArtifactId = dep.name instanceof String ? dep.name : dep.name.last()
def jarVersion = dep.version instanceof String ? dep.version : dep.version.last()
if( !jarArtifactId.startsWith( 'org.apache.zest' ) ) {
def jarName = "${jarArtifactId}-${jarVersion}.jar"
if( !new File( dependenciesDir, jarName ).exists() ) {
throw new GradleException( "Binary distribution go-offline.gradle failed! Missing: $jarName" );
}
}
}
}
}
task checkBinDist_goOfflineMaven( type: Exec, dependsOn: unpackBinDist ) {
description "Check the binary distribution Maven go-offline helper"
group = "distributions"
onlyIf {
def pathDirs = System.getenv( 'PATH' ).split( File.pathSeparator )
pathDirs.collect( { new File( it, 'mvn') } ).flatten().findAll( { it.isFile() } )
}
def dependenciesDir = new File( unpackedBinDistDir, 'dependencies' )
doFirst { dependenciesDir.deleteDir() }
workingDir unpackedBinDistDir
commandLine 'mvn', '-e', '-f', 'go-offline.pom', 'validate'
doLast {
releaseApprovedProjects*.configurations.runtime.allDependencies.findAll({it.name}).each { dep ->
def jarArtifactId = dep.name instanceof String ? dep.name : dep.name.last()
def jarVersion = dep.version instanceof String ? dep.version : dep.version.last()
if( !jarArtifactId.startsWith( 'org.apache.zest' ) ) {
def jarName = "${jarArtifactId}-${jarVersion}.jar"
if( !new File( dependenciesDir, jarName ).exists() ) {
throw new GradleException( "Binary distribution go-offline.pom failed! Missing: $jarName" );
}
}