Skip to content

Commit 2769edc

Browse files
authored
Gradle cache config: fossa (#15412)
1 parent a12bd24 commit 2769edc

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

build.gradle.kts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -128,23 +128,29 @@ tasks {
128128
group = "Help"
129129
description = "Generate .fossa.yml configuration file"
130130

131+
// Capture the project paths at configuration time to avoid serializing Gradle script objects
132+
val projectPaths = rootProject.subprojects
133+
.sortedBy { it.findProperty("archivesName") as String? }
134+
.filter { !it.name.startsWith("bom") }
135+
.filter { it.plugins.hasPlugin("maven-publish") }
136+
.map { it.path }
137+
138+
val outputFile = layout.projectDirectory.file(".fossa.yml")
139+
outputs.file(outputFile)
140+
131141
doLast {
132-
File(".fossa.yml").printWriter().use { writer ->
142+
outputFile.asFile.printWriter().use { writer ->
133143
writer.println("version: 3")
134144
writer.println()
135145
writer.println("targets:")
136146
writer.println(" only:")
137147
writer.println(" # only scanning the modules which are published")
138148
writer.println(" # (as opposed to internal testing modules")
139-
rootProject.subprojects
140-
.sortedBy { it.findProperty("archivesName") as String? }
141-
.filter { !it.name.startsWith("bom") }
142-
.filter { it.plugins.hasPlugin("maven-publish") }
143-
.forEach {
144-
writer.println(" - type: gradle")
145-
writer.println(" path: ./")
146-
writer.println(" target: '${it.path}'")
147-
}
149+
projectPaths.forEach { path ->
150+
writer.println(" - type: gradle")
151+
writer.println(" path: ./")
152+
writer.println(" target: '$path'")
153+
}
148154
writer.println()
149155
writer.println("experimental:")
150156
writer.println(" gradle:")

0 commit comments

Comments
 (0)