Skip to content

Commit 60bbfa5

Browse files
authored
Use tasks.register
1 parent ebff228 commit 60bbfa5

File tree

7 files changed

+169
-95
lines changed

7 files changed

+169
-95
lines changed

annotation-file-utilities/build.gradle

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ shadowJar {
4848
// Shadowing Test Sources and Dependencies
4949
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
5050

51-
task skinnyJar(type: ShadowJar, dependsOn: compileJava) {
51+
tasks.register('skinnyJar', ShadowJar) {
52+
dependsOn compileJava
5253
description = 'Builds annotation-file-utilities.jar with only scene-lib and annotation-file-utilities classes.'
5354
includeEmptyDirs = false
5455
destinationDirectory = file("${projectDir}/dist")
@@ -58,7 +59,9 @@ task skinnyJar(type: ShadowJar, dependsOn: compileJava) {
5859
}
5960

6061
import java.nio.file.Files
61-
task testExample(type: JavaExec, dependsOn: compileTestJava, group: 'Verification') {
62+
63+
tasks.register('testExample', JavaExec) {
64+
dependsOn compileTestJava
6265
description = 'Run the scene-lib example test.'
6366

6467
String outputDir = "${layout.buildDirectory.get()}/example-test/"
@@ -96,13 +99,15 @@ task testExample(type: JavaExec, dependsOn: compileTestJava, group: 'Verificatio
9699
}
97100
}
98101

99-
task testAnnotator(type: Exec, dependsOn: shadowJar, group: 'Verification') {
102+
tasks.register('testAnnotator', Exec) {
103+
dependsOn shadowJar
100104
description = 'Run the annotator test.'
105+
group = 'Verification'
101106
workingDir "${projectDir}/tests/"
102107
executable 'make'
103108
}
104109

105-
task cleanTestAnnotator(type: Exec) {
110+
tasks.register('cleanTestAnnotator', Exec) {
106111
description = "Clean the annotator test."
107112
workingDir 'tests/'
108113
executable 'make'
@@ -114,7 +119,7 @@ clean {
114119
delete('dist/annotation-file-utilities.jar','dist/annotation-file-utilities-all.jar', 'annotation-tools.zip')
115120
}
116121

117-
task htmlValidate(type: Exec) {
122+
tasks.register('htmlValidate', Exec) {
118123
description = 'Validate that HTML files are well-formed.'
119124
workingDir '../'
120125
executable 'html5validator'
@@ -134,12 +139,15 @@ task htmlValidate(type: Exec) {
134139
test.dependsOn testExample
135140
test.dependsOn testAnnotator
136141

137-
task updateUserOptions(dependsOn: [
138-
'updateUserOptionsJavadoc',
139-
'updateUserOptionsHtml'
140-
]) {}
142+
tasks.register('updateUserOptions') {
143+
dependsOn(
144+
'updateUserOptionsJavadoc',
145+
'updateUserOptionsHtml'
146+
)
147+
}
141148

142-
task updateUserOptionsJavadoc(type: Javadoc, dependsOn: 'assemble') {
149+
tasks.register('updateUserOptionsJavadoc', Javadoc) {
150+
dependsOn 'assemble'
143151
description = "Updates documentation of command-line arguments in Javadoc."
144152

145153
// Include only sources from annotation-file-utilities, not from scene-lib.
@@ -157,7 +165,8 @@ task updateUserOptionsJavadoc(type: Javadoc, dependsOn: 'assemble') {
157165
title = ""
158166
}
159167

160-
task updateUserOptionsHtml(type: Javadoc, dependsOn: 'assemble') {
168+
tasks.register('updateUserOptionsHtml', Javadoc) {
169+
dependsOn 'assemble'
161170
description = "Updates documentation of command-line arguments in the manual."
162171

163172
// Include only sources from annotation-file-utilities, not from scene-lib.

build.gradle

Lines changed: 49 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ ext {
9898
]
9999
}
100100

101-
task setLocalRepo(type:Exec) {
101+
tasks.register('setLocalRepo', Exec) {
102102
commandLine 'git', 'worktree', 'list'
103103
standardOutput = new ByteArrayOutputStream()
104104

@@ -109,7 +109,8 @@ task setLocalRepo(type:Exec) {
109109
}
110110

111111
// No group so it does not show up in the output of `gradlew tasks`
112-
task installGitHooks(type: Copy, dependsOn: 'setLocalRepo') {
112+
tasks.register('installGitHooks', Copy) {
113+
dependsOn ('setLocalRepo')
113114
description = 'Copies git hooks to .git directory'
114115
from files('checker/bin-devel/git.post-merge', 'checker/bin-devel/git.pre-commit')
115116
rename('git\\.(.*)', '$1')
@@ -406,15 +407,15 @@ allprojects { currentProj ->
406407
// Add the fat checker.jar to the classpath of every Javadoc task. This allows Javadoc in
407408
// any module to reference classes in any other module.
408409
// Also, build and use ManualTaglet as a taglet.
409-
tasks.withType(Javadoc) {
410+
tasks.withType(Javadoc).configureEach {
410411
dependsOn(':checker:shadowJar')
411412
dependsOn(":framework-test:tagletClasses")
412413
doFirst {
413414
options.encoding = 'UTF-8'
414415
if (!name.equals('javadocDoclintAll')) {
415416
options.memberLevel = javadocMemberLevel
416417
}
417-
classpath += configurations.getByName('checkerFatJar').asFileTree
418+
classpath += configurations.named('checkerFatJar').get().asFileTree
418419
options.taglets 'org.checkerframework.taglet.ManualTaglet'
419420
options.tagletPath(project(':framework-test').sourceSets.taglet.output.classesDirs.getFiles() as File[])
420421

@@ -587,8 +588,9 @@ allprojects { currentProj ->
587588
} // end afterEvaluate
588589
} // end allProjects
589590

590-
task version(group: 'Documentation') {
591+
tasks.register('version') {
591592
description = 'Print Checker Framework version'
593+
group = 'Documentation'
592594
doLast {
593595
println version
594596
}
@@ -604,9 +606,10 @@ task version(group: 'Documentation') {
604606
* @param args list of arguments to pass to the checker
605607
*/
606608
def createCheckTypeTask(projectName, taskName, checker, args = []) {
607-
project("${projectName}").tasks.create(name: "check${taskName}", type: JavaCompile, dependsOn: ':checker:shadowJar') {
609+
project("${projectName}").tasks.register("check${taskName}", JavaCompile) {
608610
description = "Run the ${taskName} Checker on the main sources."
609611
group = 'Verification'
612+
dependsOn(':checker:shadowJar')
610613
// Always run the task.
611614
outputs.upToDateWhen { false }
612615
source = project("${projectName}").sourceSets.main.java
@@ -635,8 +638,9 @@ def createCheckTypeTask(projectName, taskName, checker, args = []) {
635638
}
636639
}
637640

638-
task htmlValidate(type: Exec, group: 'Format') {
641+
tasks.register('htmlValidate', Exec) {
639642
description = 'Validate that HTML files are well-formed'
643+
group = 'Format'
640644
// This is the Nu Html Checker (v.Nu): https://github.com/validator/validator
641645
executable 'html5validator'
642646
args = [
@@ -649,7 +653,7 @@ task htmlValidate(type: Exec, group: 'Format') {
649653
]
650654
}
651655

652-
task addFavicon(type: Exec) {
656+
tasks.register('addFavicon', Exec) {
653657
dependsOn 'allJavadoc'
654658

655659
doFirst {
@@ -674,8 +678,9 @@ task addFavicon(type: Exec) {
674678
// It's needed to create the Javadoc jars that we release in Maven Central.
675679
// To make javadoc for only one subproject, run `./gradlew javadoc`
676680
// in the subproject or `./gradlew :checker:javadoc` at the top level.
677-
task allJavadoc(type: Javadoc, group: 'Documentation') {
681+
tasks.register('allJavadoc', Javadoc) {
678682
description = 'Generates API documentation that includes all the modules.'
683+
group = 'Documentation'
679684
dependsOn(':checker:shadowJar', 'getPlumeScripts', 'getHtmlTools', ':checker-qual:jar')
680685

681686
doFirst {
@@ -820,8 +825,9 @@ configurations {
820825
dependencies {
821826
requireJavadoc 'org.plumelib:require-javadoc:2.0.0'
822827
}
823-
task requireJavadoc(type: JavaExec, group: 'Documentation') {
828+
tasks.register('requireJavadoc', JavaExec) {
824829
description = 'Ensures that Javadoc documentation exists in source code.'
830+
group = 'Documentation'
825831
mainClass = 'org.plumelib.javadoc.RequireJavadoc'
826832
classpath = configurations.requireJavadoc
827833
args '--exclude=module-info.java', 'checker/src/main/java', 'checker-qual/src/main/java', 'checker-util/src/main/java', 'dataflow/src/main/java', 'framework/src/main/java', 'framework-test/src/main/java', 'javacutil/src/main/java'
@@ -847,7 +853,7 @@ task requireJavadoc(type: JavaExec, group: 'Documentation') {
847853
* @return the new task
848854
*/
849855
def createJavadocTask(taskName, taskDescription, memberLevel) {
850-
tasks.create(name: taskName, type: Javadoc) {
856+
tasks.register(taskName, Javadoc) {
851857
description = taskDescription
852858
destinationDir = file("${rootDir}/docs/tmpapi")
853859
destinationDir.mkdirs()
@@ -923,19 +929,21 @@ tasks.register('getDoLikeJavac', CloneTask) {
923929
}
924930

925931
// No group so it does not show up in the output of `gradlew tasks`
926-
task pythonIsInstalled(type: Exec) {
932+
tasks.register('pythonIsInstalled', Exec) {
927933
description = 'Check that the python3 executable is installed.'
928934
executable = 'python3'
929935
args '--version'
930936
}
931937

932-
task docTags(type: Exec, group: 'Emacs') {
938+
tasks.register('docTags', Exec) {
939+
group = 'Emacs'
933940
commandLine 'make', '-C', 'docs/manual/', 'tags'
934941
}
935942

936-
task tags(type: Exec, group: 'Emacs') {
943+
tasks.register('tags', Exec) {
937944
dependsOn docTags
938945
description = 'Create Emacs TAGS table'
946+
group = 'Emacs'
939947
// running this task will also run the tags task in the subprojects, which is defined later in this file.
940948
commandLine 'etags', '-i', 'annotation-file-utilities/TAGS', '-i', 'checker/TAGS', '-i', 'checker-qual/TAGS', '-i', 'checker-util/TAGS', '-i', 'dataflow/TAGS', '-i', 'framework/TAGS', '-i', 'framework-test/TAGS', '-i', 'javacutil/TAGS', '-i', 'docs/manual/TAGS'
941949
}
@@ -978,7 +986,7 @@ subprojects {
978986
}
979987

980988
if (!project.name.startsWith('checker-qual-android')) {
981-
task tags(type: Exec) {
989+
tasks.register('tags', Exec) {
982990
description = 'Create Emacs TAGS table'
983991
// `ctags -e -f TAGS` used to work in place of `etags`, but apparently no longer.
984992
commandLine 'bash', '-c', "find . \\( -name build -o -name jtreg -o -name tests \\) -prune -o -name '*.java' -print | sort-directory-order | xargs etags"
@@ -994,7 +1002,7 @@ subprojects {
9941002
// until the project is evaluated.
9951003
afterEvaluate {
9961004
// Adds manifest to all Jar files
997-
tasks.withType(Jar) {
1005+
tasks.withType(Jar).configureEach {
9981006
includeEmptyDirs = false
9991007
if (archiveFileName.get().startsWith('checker-qual') || archiveFileName.get().startsWith('checker-util')) {
10001008
metaInf {
@@ -1008,7 +1016,7 @@ subprojects {
10081016
manifest {
10091017
attributes('Implementation-Version': "${project.version}")
10101018
attributes('Implementation-URL': 'https://checkerframework.org')
1011-
if (! archiveFileName.get().endsWith('source.jar') && ! archiveFileName.get().startsWith('checker-qual')) {
1019+
if (!archiveFileName.get().endsWith('source.jar') && !archiveFileName.get().startsWith('checker-qual')) {
10121020
attributes('Automatic-Module-Name': 'org.checkerframework.' + project.name.replaceAll('-', '.'))
10131021
}
10141022
if (archiveFileName.get().startsWith('checker-qual') || archiveFileName.get().startsWith('checker-util')) {
@@ -1079,8 +1087,9 @@ subprojects {
10791087

10801088
// Add jtregTests to framework and checker modules
10811089
if (project.name.is('framework') || project.name.is('checker')) {
1082-
tasks.create(name: 'jtregTests', type: Exec, group: 'Verification') {
1090+
tasks.register('jtregTests', Exec) {
10831091
description = 'Run the jtreg tests. Requires jtreg to be installed.'
1092+
group = 'Verification'
10841093
dependsOn('compileJava')
10851094
dependsOn('compileTestJava')
10861095
dependsOn('shadowJar')
@@ -1137,7 +1146,7 @@ subprojects {
11371146
// Create a task for each JUnit test class whose name is the same as the JUnit class name.
11381147
sourceSets.test.allJava.filter { it.path.contains('test/junit') }.forEach { file ->
11391148
String junitClassName = file.name.replaceAll('.java', '')
1140-
tasks.create(name: "${junitClassName}", type: Test) {
1149+
tasks.register("${junitClassName}", Test) {
11411150
description = "Run ${junitClassName} tests."
11421151
include "**/${name}.class"
11431152
testClassesDirs = testing.suites.test.sources.output.classesDirs
@@ -1166,7 +1175,7 @@ subprojects {
11661175

11671176
// Fork the test to try to improve performance.
11681177
// https://docs.gradle.org/current/userguide/performance.html#fork_tests_into_multiple_processes
1169-
tasks.withType(Test).configureEach {
1178+
tasks.withType(Test) {
11701179
forkEvery = 25
11711180
}
11721181
}
@@ -1194,8 +1203,9 @@ subprojects {
11941203
}
11951204

11961205
// Create a nonJunitTests task per project
1197-
tasks.create(name: 'nonJunitTests', group: 'Verification') {
1206+
tasks.register('nonJunitTests') {
11981207
description = 'Run all Checker Framework tests except for the Junit tests and inference tests.'
1208+
group = 'Verification'
11991209
if (project.name.is('framework') || project.name.is('checker')) {
12001210
dependsOn('jtregTests')
12011211
}
@@ -1213,20 +1223,23 @@ subprojects {
12131223
}
12141224

12151225
// Create an inferenceTests task per project
1216-
tasks.create(name: 'inferenceTests', group: 'Verification') {
1226+
tasks.register('inferenceTests') {
12171227
description = 'Run inference tests.'
1228+
group = 'Verification'
12181229
if (project.name.is('checker')) {
12191230
dependsOn('inferenceTests-part1', 'inferenceTests-part1')
12201231
}
12211232
}
1222-
tasks.create(name: 'inferenceTests-part1', group: 'Verification') {
1233+
tasks.register('inferenceTests-part1') {
12231234
description = 'Run inference tests (part 1).'
1235+
group = 'Verification'
12241236
if (project.name.is('checker')) {
12251237
dependsOn('ainferTest', 'wpiManyTest')
12261238
}
12271239
}
1228-
tasks.create(name: 'inferenceTests-part2', group: 'Verification') {
1240+
tasks.register('inferenceTests-part2') {
12291241
description = 'Run inference tests (part 2).'
1242+
group = 'Verification'
12301243
if (project.name.is('checker')) {
12311244
dependsOn('wpiPlumeLibTest')
12321245
}
@@ -1235,16 +1248,19 @@ subprojects {
12351248
// Create a typecheck task per project (dogfooding the Checker Framework on itself).
12361249
// This isn't a test of the Checker Framework as the test and nonJunitTests tasks are.
12371250
// Tasks such as 'checkInterning' are constructed by createCheckTypeTask.
1238-
tasks.create(name: 'typecheck', group: 'Verification') {
1251+
tasks.register('typecheck') {
12391252
description = 'Run the Checker Framework on itself'
1253+
group = 'Verification'
12401254
dependsOn('typecheck-part1', 'typecheck-part2')
12411255
}
1242-
tasks.create(name: 'typecheck-part1', group: 'Verification') {
1256+
tasks.register('typecheck-part1') {
12431257
description = 'Run the Checker Framework on itself (part 1)'
1258+
group = 'Verification'
12441259
dependsOn('checkCompilerMessages', 'checkFormatter', 'checkInterning', 'checkOptional', 'checkPurity')
12451260
}
1246-
tasks.create(name: 'typecheck-part2', group: 'Verification') {
1261+
tasks.register('typecheck-part2') {
12471262
description = 'Run the Checker Framework on itself (part 2)'
1263+
group = 'Verification'
12481264
dependsOn('checkResourceLeak', 'checkSignature')
12491265
if (!(project.name.is('framework') || project.name.is('checker'))) {
12501266
dependsOn('checkNullness')
@@ -1253,13 +1269,15 @@ subprojects {
12531269

12541270
// Create an allTests task per project.
12551271
// allTests = test + nonJunitTests + inferenceTests + typecheck
1256-
tasks.create(name: 'allTests', group: 'Verification') {
1272+
tasks.register('allTests') {
12571273
description = 'Run all Checker Framework tests'
1274+
group = 'Verification'
12581275
// The 'test' target is just the JUnit tests.
12591276
dependsOn('test', 'nonJunitTests', 'inferenceTests', 'typecheck')
12601277
}
12611278

1262-
task javadocPrivate(dependsOn: javadoc) {
1279+
tasks.register('javadocPrivate'){
1280+
dependsOn(javadoc)
12631281
doFirst {
12641282
javadocMemberLevel = JavadocMemberLevel.PRIVATE
12651283
}
@@ -1279,8 +1297,9 @@ assemble.dependsOn(':checker:assembleForJavac')
12791297

12801298
assemble.mustRunAfter(clean)
12811299

1282-
task buildAll(group: 'Build') {
1300+
tasks.register('buildAll') {
12831301
description = 'Build all jar files and the manuals, including source and javadoc jars'
1302+
group = 'Build'
12841303
dependsOn(allJavadoc)
12851304
subprojects { Project subproject ->
12861305
dependsOn("${subproject.name}:assemble")

checker-qual-android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
evaluationDependsOn(':checker-qual')
22

3-
task copySources(type: Copy) {
3+
tasks.register('copySources', Copy) {
44
description = 'Copy checker-qual source to checker-qual-android'
55
includeEmptyDirs = false
66
from files(project(':checker-qual').sourceSets.main.java)

checker-qual/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jar {
2929
}
3030
}
3131

32-
task compileJava9(type: JavaCompile) {
32+
tasks.register('compileJava9', JavaCompile) {
3333
source = sourceSets.module_info.java
3434
destinationDirectory = sourceSets.main.output.classesDirs[0]
3535
classpath = configurations.allProjects

0 commit comments

Comments
 (0)