forked from loafle/openapi-generator-original
* [gradle-plugin] Initial commit * Clarify comments on file constraints When a user sets the models, apis, or supportingFiles environment variables, any one of these being set disables generation for the other two. This could be confusing to users, so I've added some clarification text in the comments for these properties. In addition, I've cleaned up the extension on Property.ifNotEmpty, to avoid using Suppress annotations where it's not necessary. The change creates a local variable of type T?, allowing Kotlin to track the variable's nullable state at compile time. * Move gradle plugin under modules * Move kt files under kotlin source set. Add sample. * [gradle] map-like options as maps * Add tests for gradle validate task * Apply gradle plugin to mvn install phase * [gradle] Testing remaining gradle tasks * Add gradle plugin to the integration doc * Update gradle plugin README with task options * Gradle readme formatting
89 lines
2.5 KiB
Groovy
89 lines
2.5 KiB
Groovy
buildscript {
|
|
ext.kotlin_version = '1.2.41'
|
|
repositories {
|
|
mavenCentral()
|
|
maven {
|
|
url "https://plugins.gradle.org/m2/"
|
|
}
|
|
}
|
|
dependencies {
|
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
classpath "gradle.plugin.org.gradle.kotlin:gradle-kotlin-dsl-plugins:0.17.5"
|
|
}
|
|
}
|
|
|
|
group 'org.openapitools'
|
|
// Shared OpenAPI Generator version be passed via command line arg as -PopenApiGeneratorVersion=VERSION
|
|
version "$openApiGeneratorVersion"
|
|
description = """
|
|
This plugin supports common functionality found in Open API Generator CLI as a gradle plugin.
|
|
|
|
This gives you the ability to generate client SDKs, documentation, new generators, and to validate Open API 2.0 and 3.x
|
|
specifications as part of your build. Other tasks are available as command line tasks.
|
|
"""
|
|
|
|
apply plugin: 'java-gradle-plugin'
|
|
apply plugin: 'maven-publish'
|
|
apply plugin: 'kotlin'
|
|
apply plugin: "org.gradle.kotlin.kotlin-dsl"
|
|
|
|
sourceCompatibility = 1.8
|
|
targetCompatibility = 1.8
|
|
|
|
repositories {
|
|
mavenCentral()
|
|
mavenLocal()
|
|
}
|
|
|
|
dependencies {
|
|
compile gradleApi()
|
|
// Shared OpenAPI Generator version be passed via command line arg as -PopenApiGeneratorVersion=VERSION
|
|
compile "org.openapitools:openapi-generator:$openApiGeneratorVersion"
|
|
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
|
|
|
testCompile 'org.testng:testng:6.9.6',
|
|
"org.jetbrains.kotlin:kotlin-test:$kotlin_version"
|
|
|
|
testCompile "org.jetbrains.kotlin:kotlin-compiler-embeddable:$kotlin_version"
|
|
}
|
|
|
|
test {
|
|
useTestNG()
|
|
testClassesDirs = files(project.tasks.compileTestKotlin.destinationDir)
|
|
testLogging.showStandardStreams = false
|
|
|
|
beforeTest { descriptor ->
|
|
logger.lifecycle("Running test: " + descriptor)
|
|
}
|
|
|
|
failFast = true
|
|
|
|
onOutput { descriptor, event ->
|
|
// SLF4J may complain about multiple bindings dependign on how this is run.
|
|
// This is just a warning, but can make test output less readable. So we ignore it specifically.
|
|
if (!event.message.contains("SLF4J:")) {
|
|
logger.lifecycle("Test: " + descriptor + " produced standard out/err: " + event.message)
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
gradlePlugin {
|
|
plugins {
|
|
openApiGenerator {
|
|
id = 'org.openapi.generator'
|
|
implementationClass = 'org.openapitools.generator.gradle.plugin.OpenApiGeneratorPlugin'
|
|
}
|
|
}
|
|
}
|
|
|
|
compileKotlin {
|
|
kotlinOptions {
|
|
jvmTarget = "1.8"
|
|
}
|
|
}
|
|
compileTestKotlin {
|
|
kotlinOptions {
|
|
jvmTarget = "1.8"
|
|
}
|
|
} |