Skip to content

Commit 743d2cd

Browse files
authored
Minor improvements to Gradle plugin (#14097)
* minor improvements to gradle plugin, test * update gradle plugin doc * fix out
1 parent d74cefb commit 743d2cd

3 files changed

Lines changed: 10 additions & 2 deletions

File tree

modules/openapi-generator-gradle-plugin/README.adoc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,11 @@ apply plugin: 'org.openapi.generator'
378378
|String
379379
|mustache
380380
|Templating engine: "mustache" (default) or "handlebars" (beta)
381+
382+
|cleanupOutput
383+
|Boolean
384+
|false
385+
|Defines whether the output directory should be cleaned up before generating the output.
381386
|===
382387

383388
[NOTE]

modules/openapi-generator-gradle-plugin/src/main/kotlin/org/openapitools/generator/gradle/plugin/tasks/GenerateTask.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,9 @@ open class GenerateTask : DefaultTask() {
523523
cleanupOutput.ifNotEmpty { cleanup ->
524524
if (cleanup) {
525525
project.delete(outputDir)
526+
val out = services.get(StyledTextOutputFactory::class.java).create("openapi")
527+
out.withStyle(StyledTextOutput.Style.Success)
528+
out.println("Cleaned up output directory ${outputDir.get()} before code generation (cleanupOutput set to true).")
526529
}
527530
}
528531

modules/openapi-generator-gradle-plugin/src/test/kotlin/GenerateTaskDslTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ class GenerateTaskDslTest : TestBase() {
136136
)
137137
withProject(defaultBuildGradle, projectFiles)
138138

139-
val oldFile = File(temp, "build/kotlin/should-be-removed")
139+
val oldFile = File(temp, "build/kotlin/should-not-be-removed")
140140
oldFile.mkdirs()
141141
oldFile.createNewFile()
142142

@@ -153,7 +153,7 @@ class GenerateTaskDslTest : TestBase() {
153153
"User friendly generate notice is missing."
154154
)
155155

156-
assertTrue(oldFile.exists(), "Old files should have been removed")
156+
assertTrue(oldFile.exists(), "Old files should NOT have been removed")
157157

158158
assertEquals(
159159
TaskOutcome.SUCCESS, result.task(":openApiGenerate")?.outcome,

0 commit comments

Comments
 (0)