Skip to content

Commit 0f75561

Browse files
msridharsmillstcoderabbitai[bot]
authored
build(gradle): defer cfWebsite/destDir resolution to execution time (#7262)
Co-authored-by: Suzanne Millstein <smillst@cs.washington.edu> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent 3fc5f9e commit 0f75561

File tree

2 files changed

+27
-12
lines changed

2 files changed

+27
-12
lines changed

checker/bin-devel/test-misc.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,6 @@ git diff --exit-code docs/manual/contributors.tex \
6262
&& echo " https://github.com/plume-lib/git-scripts/blob/master/git-authors.sed" \
6363
&& echo " and remake contributors.tex after that pull request is merged." \
6464
&& false)
65+
66+
## Listing tasks should succeed; this helps ensure importing Checker Framework into IDEs like IntelliJ works.
67+
./gradlew tasks --all --console=plain --warning-mode=all

release.gradle

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ tasks.register('updateVersionNumbersInDocs', Copy) {
9797
tasks.register('zipMavenExamples', Zip) {
9898
description = 'Creates a zip archive for the Maven examples.'
9999
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'))
101102
from ('docs/examples/MavenExample')
102103
}
103104

@@ -106,9 +107,15 @@ tasks.register('copyToWebsite', Copy) {
106107
description = 'Copy files to location set in the property cfWebsite.'
107108
dependsOn(':allJavadoc',':manual', ':zip', 'zipMavenExamples')
108109

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+
}
112119
from tasks.named('zip', Zip).get().archiveFile.get().toString()
113120
from ('docs') {
114121
include('checker-framework-webpage.html', 'CHANGELOG.md')
@@ -176,22 +183,27 @@ tasks.register('copyToWebsite', Copy) {
176183
}
177184

178185
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'))
181189

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'))
184192

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'))
187195
}
188196
}
189197

190198
tasks.register('updateCopyMavenExample', Copy) {
191199
// This task is used during the release in "sanity_checks.py" to check that the Maven artifacts were uploaded correctly.
192200
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+
}
195207
from 'docs/examples/MavenExample'
196208
filter { String line ->
197209
line.replaceAll("<!-- checker-framework-version -->(.*)<!-- /checker-framework-version -->", "<!-- checker-framework-version -->${releaseVersion}<!-- /checker-framework-version -->")

0 commit comments

Comments
 (0)