@@ -97,7 +97,8 @@ tasks.register('updateVersionNumbersInDocs', Copy) {
97
97
tasks. register(' zipMavenExamples' , Zip ) {
98
98
description = ' Creates a zip archive for the Maven examples.'
99
99
archiveFileName = " mvn-examples.zip"
100
- destinationDirectory = file(project. property(' cfWebsite' ))
100
+ // Defer reading of cfWebsite until execution time to avoid configuration failures.
101
+ destinationDirectory = layout. projectDirectory. dir(providers. gradleProperty(' cfWebsite' ))
101
102
from (' docs/examples/MavenExample' )
102
103
}
103
104
@@ -106,9 +107,15 @@ tasks.register('copyToWebsite', Copy) {
106
107
description = ' Copy files to location set in the property cfWebsite.'
107
108
dependsOn(' :allJavadoc' ,' :manual' , ' :zip' , ' zipMavenExamples' )
108
109
109
- String destDir = project. property(' cfWebsite' )
110
- destinationDir = file(destDir) // destinationDir affects all `into` clauses
111
-
110
+ // Defer reading of cfWebsite until execution time and set the task's
111
+ // destination directory so it affects all subsequent `into` clauses.
112
+ def cfWebsite = providers. gradleProperty(' cfWebsite' )
113
+ doFirst {
114
+ if (! cfWebsite. isPresent()) {
115
+ throw new GradleException (" Property 'cfWebsite' is required. Pass -PcfWebsite=/abs/or/relative/path" )
116
+ }
117
+ destinationDir = file(cfWebsite. get())
118
+ }
112
119
from tasks. named(' zip' , Zip ). get(). archiveFile. get(). toString()
113
120
from (' docs' ) {
114
121
include(' checker-framework-webpage.html' , ' CHANGELOG.md' )
@@ -176,22 +183,27 @@ tasks.register('copyToWebsite', Copy) {
176
183
}
177
184
178
185
doLast {
179
- delete(file(" ${ destDir} /index.html" ))
180
- Files . createSymbolicLink(file(" ${ destDir} /index.html" ). toPath(), Paths . get(' checker-framework-webpage.html' ))
186
+ def dest = cfWebsite. get()
187
+ delete(file(" ${ dest} /index.html" ))
188
+ Files . createSymbolicLink(file(" ${ dest} /index.html" ). toPath(), Paths . get(' checker-framework-webpage.html' ))
181
189
182
- delete(file(" ${ destDir } /manual/index.html" ))
183
- Files . createSymbolicLink(file(" ${ destDir } /manual/index.html" ). toPath(), Paths . get(' manual.html' ))
190
+ delete(file(" ${ dest } /manual/index.html" ))
191
+ Files . createSymbolicLink(file(" ${ dest } /manual/index.html" ). toPath(), Paths . get(' manual.html' ))
184
192
185
- delete " ${ destDir } /annotation-file-utilities/index.html"
186
- Files . createSymbolicLink(file(" ${ destDir } /annotation-file-utilities/index.html" ). toPath(), Paths . get(' annotation-file-utilities.html' ))
193
+ delete " ${ dest } /annotation-file-utilities/index.html"
194
+ Files . createSymbolicLink(file(" ${ dest } /annotation-file-utilities/index.html" ). toPath(), Paths . get(' annotation-file-utilities.html' ))
187
195
}
188
196
}
189
197
190
198
tasks. register(' updateCopyMavenExample' , Copy ) {
191
199
// This task is used during the release in "sanity_checks.py" to check that the Maven artifacts were uploaded correctly.
192
200
description = ' Copies the Maven example to the location in property destDir.'
193
- String destDir = project. property(' destDir' ) + ' /MavenExample'
194
- destinationDir = file(destDir)
201
+ // Defer reading of destDir until execution time and set the task's
202
+ // destination directory so it affects all subsequent `into` clauses.
203
+ def destDir = providers. gradleProperty(' destDir' ). map { it + ' /MavenExample' }
204
+ doFirst {
205
+ destinationDir = file(destDir. get())
206
+ }
195
207
from ' docs/examples/MavenExample'
196
208
filter { String line ->
197
209
line. replaceAll(" <!-- checker-framework-version -->(.*)<!-- /checker-framework-version -->" , " <!-- checker-framework-version -->${ releaseVersion} <!-- /checker-framework-version -->" )
0 commit comments