[Gradle] BuildKotlinToolingMetadataTask: Ensure clean output directory
This is done to prevent unwanted files from also being located in the output directory. If the task is executed it is expected that the output directory only contains this one file. This is necessary, since *everything* located in the output directory will potentially be bundled into release apks. ^KT-48019
This commit is contained in:
committed by
Space
parent
e897c60ef1
commit
ee0b64cb29
+4
-1
@@ -57,7 +57,7 @@ abstract class BuildKotlinToolingMetadataTask : DefaultTask() {
|
||||
@get:OutputDirectory
|
||||
val outputDirectory: File = project.buildDir.resolve("kotlinToolingMetadata")
|
||||
|
||||
@get:OutputFile
|
||||
@get:Internal /* Covered by 'outputDirectory' */
|
||||
val outputFile: File = outputDirectory.resolve("kotlin-tooling-metadata.json")
|
||||
|
||||
@get:Internal
|
||||
@@ -71,7 +71,10 @@ abstract class BuildKotlinToolingMetadataTask : DefaultTask() {
|
||||
|
||||
@TaskAction
|
||||
internal fun createToolingMetadataFile() {
|
||||
/* Ensure output directory exists and is empty */
|
||||
outputDirectory.mkdirs()
|
||||
outputDirectory.listFiles().orEmpty().forEach { file -> file.deleteRecursively() }
|
||||
|
||||
outputFile.writeText(kotlinToolingMetadataJson)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user