Jim Schubert c8cd255ad3
[gradle] Add recommendations to validate task (#5183)
* [gradle] Add recommendations to validate task

* Use current version of Gradle Plugin in build checks.

* Fix gradle project build version confusion in CI

* [gradle] Bump samples to 5.2.1 wrapper

Previously, the Gradle plugin was building in CI against
openapi-generator 4.2.0 and Gradle version 4.10.2. At some point, a
contribution was made with an API which is incomatible at 4.10.2 and due
to a release script error which pinned the local-spec version to release
4.2.0, we didn't notice this inconsistency.

This bumps the project to build against Gradle 5.2.1.
2020-02-01 04:03:34 -05:00

105 lines
3.2 KiB
Groovy

buildscript {
repositories {
mavenLocal()
maven { url "https://repo1.maven.org/maven2" }
maven {
url "https://plugins.gradle.org/m2/"
}
maven {
url "https://oss.sonatype.org/content/repositories/releases/"
}
maven {
url "https://oss.sonatype.org/content/repositories/snapshots/"
}
}
dependencies {
// Updated version can be passed via command line arg as -PopenApiGeneratorVersion=VERSION
classpath "org.openapitools:openapi-generator-gradle-plugin:$openApiGeneratorVersion"
}
}
apply plugin: 'org.openapi.generator'
openApiMeta {
generatorName = "Sample"
packageName = "org.openapitools.example"
outputFolder = "$buildDir/meta".toString()
}
openApiValidate {
inputSpec = "$rootDir/petstore-v3.0-invalid.yaml".toString()
recommend = true
}
// Builds a Kotlin client by default.
openApiGenerate {
generatorName = "kotlin"
inputSpec = "$rootDir/petstore-v3.0.yaml".toString()
outputDir = "$buildDir/kotlin".toString()
apiPackage = "org.openapitools.example.api"
invokerPackage = "org.openapitools.example.invoker"
modelPackage = "org.openapitools.example.model"
configOptions = [
dateLibrary: "java8"
]
systemProperties = [
modelDocs: "false"
]
skipValidateSpec = true
logToStderr = true
generateAliasAsModel = false
// set to true and set environment variable {LANG}_POST_PROCESS_FILE
// (e.g. SCALA_POST_PROCESS_FILE) to the linter/formatter to be processed.
// This command will be passed one file at a time for most supported post processors.
enablePostProcessFile = false
}
task buildGoSdk(type: org.openapitools.generator.gradle.plugin.tasks.GenerateTask){
generatorName = "go"
inputSpec = "$rootDir/petstore-v3.0.yaml".toString()
additionalProperties = [
packageName: "petstore"
]
outputDir = "$buildDir/go".toString()
configOptions = [
dateLibrary: "threetenp"
]
}
task buildDotnetSdk(type: org.openapitools.generator.gradle.plugin.tasks.GenerateTask){
generatorName = "csharp-netcore"
inputSpec = "$rootDir/petstore-v3.0.yaml".toString()
additionalProperties = [
packageGuid: "{321C8C3F-0156-40C1-AE42-D59761FB9B6C}",
useCompareNetObjects: "true"
]
outputDir = "$buildDir/csharp-netcore".toString()
systemProperties = [
models: "",
apis : "",
]
}
task generateGoWithInvalidSpec(type: org.openapitools.generator.gradle.plugin.tasks.GenerateTask){
validateSpec = true
generatorName = "go"
inputSpec = "$rootDir/petstore-v3.0-invalid.yaml".toString()
additionalProperties = [
packageName: "petstore"
]
outputDir = "$buildDir/go".toString()
configOptions = [
dateLibrary: "threetenp"
]
}
task validateGoodSpec(type: org.openapitools.generator.gradle.plugin.tasks.ValidateTask){
inputSpec = "$rootDir/petstore-v3.0.yaml".toString()
}
task validateBadSpec(type: org.openapitools.generator.gradle.plugin.tasks.ValidateTask){
inputSpec = "$rootDir/petstore-v3.0-invalid.yaml".toString()
}
task validateSpecs(dependsOn: ['validateGoodSpec', 'validateBadSpec'])