Skip to content

Commit 69e69f5

Browse files
committed
Fix cases where we would unintentionally tar the entire build workspace (#49130)
Fix cases where we would unintentionally tar the entire build workspace
1 parent de8107e commit 69e69f5

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

gradle/build-complete.gradle

+19-11
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,26 @@ if (buildNumber) {
1313
try {
1414
ant.tar(destfile: uploadFile, compression: "bzip2", longfile: "gnu") {
1515
fileset(dir: projectDir) {
16-
fileTree(projectDir)
17-
.include("**/*.hprof")
18-
.include("**/reaper.log")
19-
.include("**/build/testclusters/**")
20-
.exclude("**/build/testclusters/**/data/**")
21-
.exclude("**/build/testclusters/**/distro/**")
22-
.exclude("**/build/testclusters/**/repo/**")
23-
.exclude("**/build/testclusters/**/extract/**")
24-
.filter { Files.isRegularFile(it.toPath()) }
25-
.each {
26-
include(name: projectDir.toPath().relativize(it.toPath()))
16+
Set<File> fileSet = fileTree(projectDir) {
17+
include("**/*.hprof")
18+
include("**/reaper.log")
19+
include("**/build/testclusters/**")
20+
exclude("**/build/testclusters/**/data/**")
21+
exclude("**/build/testclusters/**/distro/**")
22+
exclude("**/build/testclusters/**/repo/**")
23+
exclude("**/build/testclusters/**/extract/**")
24+
}
25+
.files
26+
.findAll { Files.isRegularFile(it.toPath()) }
27+
28+
if (fileSet.empty) {
29+
// In cases where we don't match any workspace files, exclude everything
30+
ant.exclude(name: "**/*")
31+
} else {
32+
fileSet.each {
33+
ant.include(name: projectDir.toPath().relativize(it.toPath()))
2734
}
35+
}
2836
}
2937

3038
fileset(dir: "${gradle.gradleUserHomeDir}/daemon/${gradle.gradleVersion}", followsymlinks: false) {

0 commit comments

Comments
 (0)