Skip to content

Commit 97c8009

Browse files
authored
[gradle] Clarify defining multiple tasks (#5167)
1 parent 845acce commit 97c8009

2 files changed

Lines changed: 34 additions & 1 deletion

File tree

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

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ These map almost fully 1:1 with the options you'd pass to the CLI or Maven plugi
99

1010
Tasks are listed under the "OpenAPI Tools" tasks heading.
1111

12-
1312
.OpenAPI Tools Tasks
1413
|===
1514
|task name |description
@@ -38,6 +37,30 @@ compileJava.dependsOn tasks.openApiGenerate
3837
```
3938
====
4039

40+
All extensions can be rewritten as tasks. Where you can have only a single extension defined in your gradle file, you may have multiple tasks.
41+
42+
.One Extension, multiple tasks
43+
[source,groovy]
44+
----
45+
// Validating a single specification
46+
openApiValidate {
47+
inputSpec = "$rootDir/petstore-v3.0-invalid.yaml".toString()
48+
}
49+
50+
// Define a task for validating one specification
51+
task validateGoodSpec(type: org.openapitools.generator.gradle.plugin.tasks.ValidateTask){
52+
inputSpec = "$rootDir/petstore-v3.0.yaml".toString()
53+
}
54+
55+
// Define a task for validating another specification
56+
task validateBadSpec(type: org.openapitools.generator.gradle.plugin.tasks.ValidateTask){
57+
inputSpec = "$rootDir/petstore-v3.0-invalid.yaml".toString()
58+
}
59+
60+
// Define a task for batch validations
61+
task validateSpecs(dependsOn: ['validateGoodSpec', 'validateBadSpec'])
62+
----
63+
4164
== Plugin Setup
4265

4366
//# RELEASE_VERSION

modules/openapi-generator-gradle-plugin/samples/local-spec/build.gradle

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,13 @@ task generateGoWithInvalidSpec(type: org.openapitools.generator.gradle.plugin.ta
9191
dateLibrary: "threetenp"
9292
]
9393
}
94+
95+
task validateGoodSpec(type: org.openapitools.generator.gradle.plugin.tasks.ValidateTask){
96+
inputSpec = "$rootDir/petstore-v3.0.yaml".toString()
97+
}
98+
99+
task validateBadSpec(type: org.openapitools.generator.gradle.plugin.tasks.ValidateTask){
100+
inputSpec = "$rootDir/petstore-v3.0-invalid.yaml".toString()
101+
}
102+
103+
task validateSpecs(dependsOn: ['validateGoodSpec', 'validateBadSpec'])

0 commit comments

Comments
 (0)