-
Notifications
You must be signed in to change notification settings - Fork 96
Expand file tree
/
Copy pathbuild.gradle
More file actions
executable file
·579 lines (477 loc) · 18.9 KB
/
build.gradle
File metadata and controls
executable file
·579 lines (477 loc) · 18.9 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
import t5build.GenerateChecksums
import t5build.TapestryBuildLogic
import org.apache.tools.ant.filters.ReplaceTokens
plugins {
id 'base'
id 'maven-publish'
}
description = 'Apache Tapestry 5 Project'
ext {
tapestryMajorVersion = '5.10.0'
tapestryMinorVersion = '' // Use for release suffixes like '-alpha-1'
artifactSuffix = '-jakarta'
// Artifacts that have both an unsuffixed artifact from the javax branch
// and a suffixed one from the master branch
suffixedArtifactNames = [
'tapestry-beanvalidator',
'tapestry-cdi',
'tapestry-clojure',
'tapestry-hibernate-core',
'tapestry-hibernate',
'tapestry-http',
'tapestry-ioc-jcache',
'tapestry-ioc-junit',
'tapestry-ioc',
'tapestry-jmx',
'tapestry-jpa',
'tapestry-kaptcha',
'tapestry-latest-java-tests',
'tapestry-mongodb',
'tapestry-openapi-viewer',
'tapestry-rest-jackson',
'tapestry-runner',
'tapestry-spock',
'tapestry-spring',
'tapestry-test',
'tapestry-upload',
'tapestry-webresources',
'tapestry-core',
]
continuousIntegrationBuild = Boolean.getBoolean('ci')
stagingUrl = 'https://repository.apache.org/service/local/staging/deploy/maven2/'
snapshotUrl = 'https://repository.apache.org/content/repositories/snapshots'
doSign = !project.hasProperty('noSign') && project.hasProperty('signing.keyId')
// apacheDeployUserName and apacheDeployPassword should be specified in ~/.gradle/gradle.properties
def deployFlavor = TapestryBuildLogic.isSnapshot(project) ? 'snapshot' : 'apache'
deployUsername = providers.gradleProperty("${deployFlavor}DeployUserName")
deployPassword = providers.gradleProperty("${deployFlavor}DeployPassword")
archiveDeployFolder = providers.gradleProperty('apacheArchivesFolder')
canDeploy = [
deployUsername,
deployPassword,
archiveDeployFolder
].every { it.present }
}
// Provided so that the CI server can override the normal version number for nightly builds.
version = TapestryBuildLogic.tapestryVersion(project)
// Specific to top-level build, not set for subprojects:
configurations {
javadoc
published.extendsFrom archives, meta
if (doSign) {
published.extendsFrom signatures
}
binaries // additional dependencies included in the binary archive
}
dependencies {
javadoc project(':tapestry-javadoc')
meta providers.provider {
tasks.named('aggregateJavadoc').get().outputs.files
}
// From tapestry-ioc:
binaries libs.jakarta.inject.api
binaries libs.slf4j.api
binaries libs.commons.codec
binaries libs.antlr.runtime, {
transitive = false
}
}
subprojects {
plugins.apply 'tapestry.java-convention'
plugins.apply 'maven-publish'
plugins.apply 'project-report'
plugins.apply 'jacoco'
plugins.apply 'groovy'
jacoco {
toolVersion = '0.8.7'
}
dependencies {
implementation libs.slf4j.api
implementation libs.bundles.groovy
}
tasks.withType(GroovyCompile).configureEach {
if (name == 'compileTestGroovy') {
options.fork = true
options.forkOptions.memoryMaximumSize = '1g'
options.forkOptions.jvmArgs = ['-Xms512m', '-Xmx1g']
}
}
tasks.named('assemble') {
dependsOn processResources, compileJava, jar
}
artifacts {
archives sourcesJar
meta sourcesJar
}
configurations {
// published -- what gets uploaded to the Nexus repository
published.extendsFrom archives, meta
if (rootProject.doSign) {
published.extendsFrom signatures
}
}
publishing {
publications {
mavenJava(MavenPublication) {
version = parent.version
groupId = 'org.apache.tapestry'
if (suffixedArtifactNames.contains(project.name)) {
artifactId = project.name + artifactSuffix
}
from components.java
pom {
name = project.name
// TODO: find some way to get the subproject description here.
// description =
url = 'https://tapestry.apache.org/'
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
scm {
connection = 'scm:git:https://gitbox.apache.org/repos/asf/tapestry-5.git'
developerConnection = 'scm:git://gitbox.apache.org/repos/asf/tapestry-5.git'
url = 'https://git-wip-us.apache.org/repos/asf?p=tapestry-5.git;a=summary'
}
// Changes the generated pom.xml so its dependencies on suffixed artifacts
// get properly updated with suffixed artifact ids
withXml {
def artifactIdQName = new groovy.namespace.QName(
'http://maven.apache.org/POM/4.0.0', 'artifactId')
def node = asNode()
def dependencies = node.get('dependencies')[0]
if (dependencies != null) {
dependencies.'*'.forEach {
def artifactIdNode = it.getAt(artifactIdQName)[0]
if (suffixedArtifactNames.contains(artifactIdNode.text())) {
artifactIdNode.value = artifactIdNode.text() + artifactSuffix
}
}
}
}
}
}
}
if (canDeploy) {
repositories {
mavenLocal()
def repoUrl = continuousIntegrationBuild ? snapshotUrl : stagingUrl
def repoName = continuousIntegrationBuild ? 'apacheSnapshots' : 'apacheStaging'
maven {
name = repoName
url = repoUrl
credentials {
username = deployUsername.get()
password = deployPassword.get()
}
}
}
}
}
if (doSign) {
apply plugin: 'signing'
signing {
sign publishing.publications.mavenJava
}
}
def actuallyPublish = !artifactSuffix.isEmpty() || suffixedArtifactNames.contains(project.name)
// println 'XXXXXX Actually publish? ' + actuallyPublish + ' project ' + project.name + ' ' + '!artifactSuffix.isEmpty() ' + !artifactSuffix.isEmpty()
if (!actuallyPublish) {
tasks.withType(PublishToMavenRepository).configureEach {
it.enabled = false
}
tasks.withType(PublishToMavenLocal).configureEach {
it.enabled = false
}
}
tasks.register('uploadPublished') {
doFirst {
if (!canDeploy) {
throw new InvalidUserDataException("Missing upload credentials. Set '${deployUsernameProperty}' and '${deployPasswordProperty}' root project properties.")
}
}
}
}
// Cribbed from https://github.com/hibernate/hibernate-core/blob/master/release/release.gradle#L19
tasks.register('aggregateJavadoc', Javadoc) {
group = 'Documentation'
description = 'Build the aggregated JavaDocs for all modules'
dependsOn configurations.javadoc
maxMemory = '512m'
destinationDir = layout.buildDirectory.dir('documentation/javadocs').get().asFile
def tapestryStylesheet = file('src/javadoc/stylesheet7.css')
int thisYear = java.time.Year.now().getValue()
def allMainSourceSets = subprojects*.sourceSets*.main.flatten()
def allMainJavaFiles = allMainSourceSets*.java
def allMainJavaSrcDirs = allMainJavaFiles*.srcDirs
if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_17)) {
exclude 'org/apache/tapestry5/spring/**'
}
exclude 'org/apache/tapestry5/internal/plastic/asm/**'
exclude 'org/apache/tapestry5/internal/webresources/**'
exclude 'org/apache/tapestry5/webresources/modules/**'
source allMainJavaFiles
classpath += files(allMainSourceSets*.compileClasspath)
inputs.files allMainJavaSrcDirs
options {
splitIndex true
linkSource true
stylesheetFile tapestryStylesheet
windowTitle "Tapestry API - ${project.version}"
header "Tapestry API - ${project.version}"
docTitle "Tapestry API - ($project.version)"
bottom "${project.version} - Copyright © 2003-${thisYear} <a href=\"http://tapestry.apache.org/\">The Apache Software Foundation</a>."
setUse(use)
links 'https://docs.oracle.com/javase/8/docs/api/'
if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_11)) {
tagletPath Collections.unmodifiableList(new ArrayList<>((Set) configurations.javadoc.files))
}
// Uncomment jFlags to debug `./gradlew aggregateJavadoc`
// jFlags '-Xdebug', '-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005'
addStringOption '-source-path', files(allMainJavaSrcDirs.flatten()).asPath
addStringOption 'source', '8'
taglets 'org.apache.tapestry5.javadoc.TapestryDocTaglet'
// Javadoc became stricer, so lets do this to actually build for now
if (JavaVersion.current().isJava9Compatible()) {
addBooleanOption('html5', true)
addStringOption('Xdoclint:none', '-quiet')
}
}
// As part of generating the documentation, ALSO copy any related files:
// Any extra images (Tapestry logo)
// Any images stored under src/main/java ... everything but .java, .xdoc and package.html
doLast {
copy {
from allMainJavaSrcDirs
into aggregateJavadoc.destinationDir
exclude '**/*.java'
exclude '**/*.xdoc'
exclude '**/package.html'
}
copy {
from file('src/javadoc/images')
into aggregateJavadoc.destinationDir
}
}
}
tasks.register('typeScriptDocs') {
group = 'Documentation'
description = 'Builds typedoc documentation for all TypeScript sources'
dependsOn(':tapestry-core:generateTypeScriptDocs')
}
tasks.register('combinedJacocoReport', JacocoReport) {
group = 'Verification'
description = 'Generates combined JaCoCo coverage report for all subprojects'
def excludedProjects = [
'quickstart',
'beanmodel',
'commons',
'genericsresolver-guava',
'tapestry5-annotations',
'tapestry-internal-test',
'tapestry-runner',
'tapestry-test-constants',
'tapestry-test-data',
'tapestry-ioc-jcache'
]
def subprojectsToConsider = subprojects.findAll {
!excludedProjects.contains(it.name)
}
dependsOn subprojectsToConsider.test
def classFiles = files(subprojectsToConsider.sourceSets.main.output).asFileTree.matching {
exclude 'org/apache/tapestry5/internal/plastic/asm/**'
}
classDirectories.from(classFiles)
additionalSourceDirs.from(files(subprojectsToConsider.sourceSets.main.allSource.srcDirs))
sourceDirectories.from(files(subprojectsToConsider.sourceSets.main.allSource.srcDirs))
executionData.from(files(subprojectsToConsider.jacocoTestReport.executionData).filter {
it.exists()
})
jacocoClasspath = files(subprojectsToConsider.jacocoTestReport.jacocoClasspath)
reports {
html {
required = true
outputLocation = layout.buildDirectory.dir('reports/jacoco/html')
}
xml {
required = true
outputLocation = layout.buildDirectory.file('reports/jacoco/jacoco.xml')
}
csv.required = false
}
}
tasks.register('continuousIntegration') {
group = 'Verification'
description = 'Runs a full CI build: assembles all artifacts, runs all checks, and generates aggregate reports.'
def dependants = [
'tapestry-core:testWithPrototypeAndRequireJsDisabled',
'tapestry-core:testWithJqueryAndRequireJsDisabled',
'tapestry-core:testWithPrototypeAndRequireJsEnabled',
subprojects.check, // jQuery and Require.js enabled
combinedJacocoReport
]
// tapestry-javadoc doesn't work with Java 8 anymore. That's why it's only added if != 8.
if (JavaVersion.current() != JavaVersion.VERSION_1_8) {
dependants << aggregateJavadoc
}
dependsOn(dependants)
}
tasks.register('zippedSources', Zip) {
group = 'Release artifact'
description = "Creates a combined Zip file of all sub-project's sources"
dependsOn 'tapestry-core:compileTypeScript'
destinationDirectory = layout.buildDirectory
archiveBaseName = 'apache-tapestry'
version project.version
archiveClassifier = 'sources'
from project.projectDir
exclude 'out/**'
exclude '**/*.iml'
exclude '**/*.ipr'
exclude '**/*.iws'
exclude '**/.*/**'
exclude '**/bin/**'
exclude '**/target/**'
exclude '**/build/**'
exclude '**/test-output/**' // Left around by TestNG sometime
exclude '**/modules/***.js'
exclude '**/es-modules/***.js'
}
tasks.register('zippedApidoc', Zip) {
group = 'Release artifact'
description = "Zip archive of the project's aggregate JavaDoc and TypeScript documentation"
dependsOn typeScriptDocs
dependsOn aggregateJavadoc
destinationDirectory = layout.buildDirectory
archiveBaseName = 'apache-tapestry'
version project.version
archiveClassifier = 'apidocs'
from(file('src/docroot-template')) {
filter ReplaceTokens, tokens: [version: project.version]
include '*.html'
}
from(file('src/docroot-template')) {
exclude '*.html'
}
into('apidocs') {
from aggregateJavadoc.outputs.files
}
into('typescript') {
from typeScriptDocs.outputs.files
}
}
tasks.register('zippedBinaries', Zip) {
group 'Release artifact'
description 'Zip archive of binaries of each sub-project'
// TODO: Plus dependencies?
// This may create a few unwanted dependencies, but does
// seem to ensure that the subprojects are created
inputs.files subprojects*.configurations*.archives.artifacts.files
destinationDirectory = layout.buildDirectory
archiveBaseName = 'apache-tapestry'
version project.version
archiveClassifier = 'bin'
// This is via some experimentation
from subprojects*.configurations*.archives.artifacts*.file*.findAll {
!(it.name.endsWith('.asc') || it.name.startsWith('quickstart'))
}
from configurations.binaries
// Pick up various licenses and notices
from(projectDir) {
include '*.txt'
}
subprojects.each { sub ->
from(sub.projectDir) {
include '*.txt'
into sub.name
}
}
}
if (canDeploy) {
configurations {
archives
uploads.extendsFrom archives, signatures
}
artifacts {
archives zippedApidoc, zippedSources, zippedBinaries
}
configurations {
upload.extendsFrom archives, signatures
}
tasks.register('generateChecksums', GenerateChecksums) {
group 'Release artifact'
description 'Creates MD5/SHA256 checksums for archives of source and JavaDoc'
source tasks.withType(Zip)
outputDir = layout.buildDirectory.dir('checksums').get().getAsFile()
}
// This requires that you have the apacheArchivesFolder property configured in your
// ~/.gradle/gradle.properties. The folder should be a Subversion workspace for
// https://dist.apache.org/repos/dist/dev/tapestry
// after the build, you must manually add the new files to the workspace (using 'svn add')
// then commit ('svn commit').
// The files will be visible in https://dist.apache.org/repos/dist/dev/tapestry/, allowing
// committers to download and verify them.
// After a successful release vote, the files can be moved to a second Subversion workspace
// for https://dist.apache.org/repos/dist/release/tapestry. Adding the files and committing
// there will publish them to http://www.apache.org/dist/tapestry ... and from there
// to all Apache mirrors (after about a 24 hour delay).
tasks.register('copyArchives', Copy) {
group 'Release artifact'
description 'Copies build archives (source, bin, docs) to a configured deployment folder, along with MD5 and SHA-256 checksums and PGP signatures (if signing is enabled)'
destinationDir = file(archiveDeployFolder.get())
from tasks.generateChecksums
from configurations.uploads.allArtifacts.files
}
tasks.register('generateRelease') {
group 'Release artifact'
description 'Generates and uploads a final release to Apache Nexus and copies archives for deployment'
dependsOn subprojects.assemble, subprojects.uploadPublished, subprojects.publish, copyArchives
}
}
tasks.register('updateBootstrap') {
group = 'Maintenance'
description = 'Updates the included Bootstrap dependencies from GitHub'
doLast {
def bootstrapVersion = '3.3.7'
def target = new File(temporaryDir, 'bootstrap.zip')
ant.get(src: "https://github.com/twbs/bootstrap/archive/v${bootstrapVersion}.zip", dest: target)
def adjustDirectory = {
def relativePath = it.relativePath
if (relativePath.pathString.contains('/dist/')){
relativePath = new RelativePath(!it.file.isDirectory(), relativePath.segments[2..-1] as String[])
} else {
relativePath = new RelativePath(!it.file.isDirectory(), relativePath.segments[1..-1] as String[])
}
println "copying ${it.relativePath} to ${relativePath}"
it.relativePath = relativePath
}
copy {
from(zipTree(target)){
include('*/js/*.js')
include('*/dist/fonts/*')
eachFile adjustDirectory
}
from(zipTree(target)){
include('*/dist/css/bootstrap.css')
include('*/dist/css/bootstrap-theme.css')
eachFile adjustDirectory
// TAP5-2351: remove source map reference from css files
filter({
(it ==~ /\/\*\s*# sourceMappingURL=[\S]+\s*\*\//) ? '' : it
})
}
into('tapestry-core/src/main/resources/META-INF/assets/tapestry5/bootstrap/')
}
copy {
from(zipTree(target)){
include('*/js/*.js')
include('*/dist/fonts/*')
include('*/less/**/*.less')
eachFile adjustDirectory
}
into('tapestry-webresources/src/test/webapp/bootstrap/')
}
}
}