Minor improvements to Gradle plugin (#14097)

* minor improvements to gradle plugin, test

* update gradle plugin doc

* fix out
This commit is contained in:
William Cheng 2022-11-23 20:31:13 +08:00 committed by GitHub
parent d74cefba83
commit 743d2cde7f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 2 deletions

View File

@ -378,6 +378,11 @@ apply plugin: 'org.openapi.generator'
|String |String
|mustache |mustache
|Templating engine: "mustache" (default) or "handlebars" (beta) |Templating engine: "mustache" (default) or "handlebars" (beta)
|cleanupOutput
|Boolean
|false
|Defines whether the output directory should be cleaned up before generating the output.
|=== |===
[NOTE] [NOTE]

View File

@ -523,6 +523,9 @@ open class GenerateTask : DefaultTask() {
cleanupOutput.ifNotEmpty { cleanup -> cleanupOutput.ifNotEmpty { cleanup ->
if (cleanup) { if (cleanup) {
project.delete(outputDir) project.delete(outputDir)
val out = services.get(StyledTextOutputFactory::class.java).create("openapi")
out.withStyle(StyledTextOutput.Style.Success)
out.println("Cleaned up output directory ${outputDir.get()} before code generation (cleanupOutput set to true).")
} }
} }

View File

@ -136,7 +136,7 @@ class GenerateTaskDslTest : TestBase() {
) )
withProject(defaultBuildGradle, projectFiles) withProject(defaultBuildGradle, projectFiles)
val oldFile = File(temp, "build/kotlin/should-be-removed") val oldFile = File(temp, "build/kotlin/should-not-be-removed")
oldFile.mkdirs() oldFile.mkdirs()
oldFile.createNewFile() oldFile.createNewFile()
@ -153,7 +153,7 @@ class GenerateTaskDslTest : TestBase() {
"User friendly generate notice is missing." "User friendly generate notice is missing."
) )
assertTrue(oldFile.exists(), "Old files should have been removed") assertTrue(oldFile.exists(), "Old files should NOT have been removed")
assertEquals( assertEquals(
TaskOutcome.SUCCESS, result.task(":openApiGenerate")?.outcome, TaskOutcome.SUCCESS, result.task(":openApiGenerate")?.outcome,