forked from loafle/openapi-generator-original
[gradle plugin] Support Gradle 4.10 (#1011)
* Support Gradle 4.10 Gradle 4.10 is bundled with Kotlin 1.60 and Kotlin DSL 1.0-rc1. The new Kotlin DSL isn't binary compatible with the `tasks` registration used in this plugin. Updating to Kotlin DSL 1.0-rc1 with no other changes would require users to update to Gradle 4.10. As a workaround, I've modified the tasks registration being done in OpenApiGeneratorPlugin.kt, so rather than using the Kotlin DSL's invoke, it creates tasks manually against the TasksContainer. This works locally with Gradle 4.7+ for all scenarios in the sample (samples/local-spec). There may be edge cases that I'm unaware of, and we may want to consider defining the minimum supported Gradle version of 4.10 in the next major version of openapi-generator-gradle-plugin if we experience those cases. * Uncomment snapshots repo (commented it during local testing) * update pom.xml for exec gradle plugin
This commit is contained in:
parent
f29ba97e8b
commit
131cf94fe4
@ -1,5 +1,5 @@
|
||||
buildscript {
|
||||
ext.kotlin_version = '1.2.41'
|
||||
ext.kotlin_version = '1.2.60'
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven {
|
||||
@ -14,7 +14,7 @@ buildscript {
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath "gradle.plugin.org.gradle.kotlin:gradle-kotlin-dsl-plugins:0.17.5"
|
||||
classpath "gradle.plugin.org.gradle.kotlin:gradle-kotlin-dsl-plugins:1.0-rc-3"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.7-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-rc-1-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
@ -54,7 +54,7 @@
|
||||
<artifactId>gradle-maven-plugin</artifactId>
|
||||
<version>1.0.8</version>
|
||||
<configuration>
|
||||
<gradleVersion>4.7</gradleVersion>
|
||||
<gradleVersion>4.10-rc-1</gradleVersion>
|
||||
<args>
|
||||
<arg>-P openApiGeneratorVersion=${project.version}</arg>
|
||||
</args>
|
||||
|
@ -17,5 +17,5 @@ gradle generateGoWithInvalidSpec
|
||||
The samples can be tested against other versions of the plugin using the `openApiGeneratorVersion` property. For example:
|
||||
|
||||
```bash
|
||||
gradle -PopenApiGeneratorVersion=3.2.3 openApiValidate
|
||||
gradle -PopenApiGeneratorVersion=3.3.0 openApiValidate
|
||||
```
|
||||
|
@ -18,7 +18,6 @@ package org.openapitools.generator.gradle.plugin
|
||||
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.kotlin.dsl.invoke
|
||||
import org.openapitools.generator.gradle.plugin.extensions.OpenApiGeneratorGenerateExtension
|
||||
import org.openapitools.generator.gradle.plugin.extensions.OpenApiGeneratorMetaExtension
|
||||
import org.openapitools.generator.gradle.plugin.extensions.OpenApiGeneratorValidateExtension
|
||||
@ -56,12 +55,13 @@ class OpenApiGeneratorPlugin : Plugin<Project> {
|
||||
|
||||
generate.outputDir.set("$buildDir/generate-resources/main")
|
||||
|
||||
tasks {
|
||||
"openApiGenerators"(GeneratorsTask::class) {
|
||||
tasks.apply {
|
||||
create("openApiGenerators", GeneratorsTask::class.java) {
|
||||
group = pluginGroup
|
||||
description = "Lists generators available via Open API Generators."
|
||||
}
|
||||
"openApiMeta"(MetaTask::class) {
|
||||
|
||||
create("openApiMeta", MetaTask::class.java) {
|
||||
group = pluginGroup
|
||||
description = "Generates a new generator to be consumed via Open API Generator."
|
||||
|
||||
@ -69,13 +69,15 @@ class OpenApiGeneratorPlugin : Plugin<Project> {
|
||||
packageName.set(meta.packageName)
|
||||
outputFolder.set(meta.outputFolder)
|
||||
}
|
||||
"openApiValidate"(ValidateTask::class) {
|
||||
|
||||
create("openApiValidate", ValidateTask::class.java) {
|
||||
group = pluginGroup
|
||||
description = "Validates an Open API 2.0 or 3.x specification document."
|
||||
|
||||
inputSpec.set(validate.inputSpec)
|
||||
}
|
||||
"openApiGenerate"(GenerateTask::class) {
|
||||
|
||||
create("openApiGenerate", GenerateTask::class.java) {
|
||||
group = pluginGroup
|
||||
description = "Generate code via Open API Tools Generator for Open API 2.0 or 3.x specification documents."
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user