Skip to content

Commit

Permalink
Ensure that build directory exists before writing
Browse files Browse the repository at this point in the history
This commit ensures that the build directory exists before writing the
build scan URL to it. This is useful when the `clean` task is executed
and the build folder is gone by the time the execution is done.

See spring-projectsgh-22490
  • Loading branch information
bclozel committed Apr 29, 2020
1 parent 7bd524e commit 95f76af
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,13 @@ settings.gradle.projectsLoaded {
if (settings.gradle.rootProject.hasProperty('customJavaSourceVersion')) {
value("Custom Java Source Version", settings.gradle.rootProject.getProperty('customJavaSourceVersion'))
}
settings.gradle.rootProject.getBuildDir().mkdirs()
new File(settings.gradle.rootProject.getBuildDir(), "build-scan-uri.txt").text = "(build scan not generated)"
File buildDir = settings.gradle.rootProject.getBuildDir()
buildDir.mkdirs()
new File(buildDir, "build-scan-uri.txt").text = "(build scan not generated)"
buildScanPublished { scan ->
new File(settings.gradle.rootProject.getBuildDir(), "build-scan-uri.txt").text = "${scan.buildScanUri}\n"
if (buildDir.exists()) {
new File(buildDir, "build-scan-uri.txt").text = "${scan.buildScanUri}\n"
}
}
}
}
Expand Down

0 comments on commit 95f76af

Please sign in to comment.