From a471d1ddcba637189818cabd70d2bd4867d085a2 Mon Sep 17 00:00:00 2001 From: Antti Karhu Date: Wed, 1 Jun 2022 08:05:17 +0300 Subject: [PATCH 1/3] Idea plugin for marking source directories, and omitting gradle wrapper for creating sub projects --- docs/generators/kotlin.md | 2 ++ .../resources/kotlin-client/build.gradle.mustache | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/docs/generators/kotlin.md b/docs/generators/kotlin.md index 02289613d8a1..473ee4ec3ddf 100644 --- a/docs/generators/kotlin.md +++ b/docs/generators/kotlin.md @@ -26,10 +26,12 @@ These options may be applied as additional-properties (cli) or configOptions (pl |enumPropertyNaming|Naming convention for enum properties: 'camelCase', 'PascalCase', 'snake_case', 'UPPERCASE', and 'original'| |camelCase| |generateRoomModels|Generate Android Room database models in addition to API models (JVM Volley library only)| |false| |groupId|Generated artifact package's organization (i.e. maven groupId).| |org.openapitools| +|idea|Add IntellJ Idea plugin and mark Kotlin main and test folders as source folders.| |false| |library|Library template (sub-template) to use|
**jvm-ktor**
Platform: Java Virtual Machine. HTTP client: Ktor 1.6.7. JSON processing: Gson, Jackson (default).
**jvm-okhttp4**
[DEFAULT] Platform: Java Virtual Machine. HTTP client: OkHttp 4.2.0 (Android 5.0+ and Java 8+). JSON processing: Moshi 1.8.0.
**jvm-okhttp3**
Platform: Java Virtual Machine. HTTP client: OkHttp 3.12.4 (Android 2.3+ and Java 7+). JSON processing: Moshi 1.8.0.
**jvm-retrofit2**
Platform: Java Virtual Machine. HTTP client: Retrofit 2.6.2.
**multiplatform**
Platform: Kotlin multiplatform. HTTP client: Ktor 1.6.7. JSON processing: Kotlinx Serialization: 1.2.1.
**jvm-volley**
Platform: JVM for Android. HTTP client: Volley 1.2.1. JSON processing: gson 2.8.9
|jvm-okhttp4| |modelMutable|Create mutable models| |false| |moshiCodeGen|Whether to enable codegen with the Moshi library. Refer to the [official Moshi doc](https://github.com/square/moshi#codegen) for more info.| |false| |omitGradlePluginVersions|Whether to declare Gradle plugin versions in build files.| |false| +|omitGradleWrapper|Whether to omit Gradle wrapper for creating a sub project.| |false| |packageName|Generated artifact package name.| |org.openapitools.client| |parcelizeModels|toggle "@Parcelize" for generated models| |null| |requestDateConverter|JVM-Option. Defines in how to handle date-time objects that are used for a request (as query or parameter)|
**toJson**
[DEFAULT] Date formatter option using a json converter.
**toString**
Use the 'toString'-method of the date-time object to retrieve the related string representation.
|toJson| diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/build.gradle.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/build.gradle.mustache index f4b36562dfa2..535e54eb63b8 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-client/build.gradle.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-client/build.gradle.mustache @@ -1,10 +1,12 @@ group '{{groupId}}' version '{{artifactVersion}}' +{{^omitGradleWrapper}} wrapper { gradleVersion = '6.8.3' distributionUrl = "https://services.gradle.org/distributions/gradle-$gradleVersion-all.zip" } +{{/omitGradleWrapper}} buildscript { ext.kotlin_version = '1.5.10' @@ -45,6 +47,9 @@ apply plugin: 'kotlin-parcelize' {{#kotlinx_serialization}} apply plugin: 'kotlinx-serialization' {{/kotlinx_serialization}} +{{#idea}} +apply plugin: 'idea' +{{/idea}} repositories { maven { url "https://repo1.maven.org/maven2" } @@ -54,6 +59,15 @@ test { useJUnitPlatform() } +{{#idea}} +idea { + module { + sourceDirs += file('src/main/kotlin') + testSourceDirs += file('src/test/kotlin') + } +} +{{/idea}} + dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" {{^doNotUseRxAndCoroutines}} From cb702bdee690930c4f328cecc53ed71e5b98fe1d Mon Sep 17 00:00:00 2001 From: Antti Karhu Date: Tue, 28 Jun 2022 13:49:50 +0300 Subject: [PATCH 2/3] Register the omitGradleWrapper option --- docs/generators/kotlin.md | 1 - .../org/openapitools/codegen/languages/KotlinClientCodegen.java | 2 ++ .../src/main/resources/kotlin-client/build.gradle.mustache | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/generators/kotlin.md b/docs/generators/kotlin.md index 473ee4ec3ddf..ffe337e428f1 100644 --- a/docs/generators/kotlin.md +++ b/docs/generators/kotlin.md @@ -26,7 +26,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl |enumPropertyNaming|Naming convention for enum properties: 'camelCase', 'PascalCase', 'snake_case', 'UPPERCASE', and 'original'| |camelCase| |generateRoomModels|Generate Android Room database models in addition to API models (JVM Volley library only)| |false| |groupId|Generated artifact package's organization (i.e. maven groupId).| |org.openapitools| -|idea|Add IntellJ Idea plugin and mark Kotlin main and test folders as source folders.| |false| |library|Library template (sub-template) to use|
**jvm-ktor**
Platform: Java Virtual Machine. HTTP client: Ktor 1.6.7. JSON processing: Gson, Jackson (default).
**jvm-okhttp4**
[DEFAULT] Platform: Java Virtual Machine. HTTP client: OkHttp 4.2.0 (Android 5.0+ and Java 8+). JSON processing: Moshi 1.8.0.
**jvm-okhttp3**
Platform: Java Virtual Machine. HTTP client: OkHttp 3.12.4 (Android 2.3+ and Java 7+). JSON processing: Moshi 1.8.0.
**jvm-retrofit2**
Platform: Java Virtual Machine. HTTP client: Retrofit 2.6.2.
**multiplatform**
Platform: Kotlin multiplatform. HTTP client: Ktor 1.6.7. JSON processing: Kotlinx Serialization: 1.2.1.
**jvm-volley**
Platform: JVM for Android. HTTP client: Volley 1.2.1. JSON processing: gson 2.8.9
|jvm-okhttp4| |modelMutable|Create mutable models| |false| |moshiCodeGen|Whether to enable codegen with the Moshi library. Refer to the [official Moshi doc](https://github.com/square/moshi#codegen) for more info.| |false| diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinClientCodegen.java index b3ddfbaef4be..93a62b76ec4a 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinClientCodegen.java @@ -72,6 +72,7 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen { public static final String GENERATE_ROOM_MODELS = "generateRoomModels"; public static final String ROOM_MODEL_PACKAGE = "roomModelPackage"; public static final String OMIT_GRADLE_PLUGIN_VERSIONS = "omitGradlePluginVersions"; + public static final String OMIT_GRADLE_WRAPPER = "omitGradleWrapper"; public static final String DATE_LIBRARY = "dateLibrary"; public static final String REQUEST_DATE_CONVERTER = "requestDateConverter"; @@ -233,6 +234,7 @@ public KotlinClientCodegen() { cliOptions.add(CliOption.newBoolean(USE_RX_JAVA3, "Whether to use the RxJava3 adapter with the retrofit2 library.")); cliOptions.add(CliOption.newBoolean(USE_COROUTINES, "Whether to use the Coroutines adapter with the retrofit2 library.")); cliOptions.add(CliOption.newBoolean(OMIT_GRADLE_PLUGIN_VERSIONS, "Whether to declare Gradle plugin versions in build files.")); + cliOptions.add(CliOption.newBoolean(OMIT_GRADLE_WRAPPER, "Whether to omit Gradle wrapper for creating a sub project.")); cliOptions.add(CliOption.newBoolean(MOSHI_CODE_GEN, "Whether to enable codegen with the Moshi library. Refer to the [official Moshi doc](https://github.com/square/moshi#codegen) for more info.")); diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/build.gradle.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/build.gradle.mustache index 535e54eb63b8..ef2426d83371 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-client/build.gradle.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-client/build.gradle.mustache @@ -58,8 +58,8 @@ repositories { test { useJUnitPlatform() } - {{#idea}} + idea { module { sourceDirs += file('src/main/kotlin') From 2da8169264c40689edf7d9753d05cb1d090f3545 Mon Sep 17 00:00:00 2001 From: Antti Karhu Date: Tue, 28 Jun 2022 14:37:01 +0300 Subject: [PATCH 3/3] Added missing idea option --- docs/generators/kotlin.md | 1 + .../org/openapitools/codegen/languages/KotlinClientCodegen.java | 2 ++ 2 files changed, 3 insertions(+) diff --git a/docs/generators/kotlin.md b/docs/generators/kotlin.md index ffe337e428f1..473ee4ec3ddf 100644 --- a/docs/generators/kotlin.md +++ b/docs/generators/kotlin.md @@ -26,6 +26,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |enumPropertyNaming|Naming convention for enum properties: 'camelCase', 'PascalCase', 'snake_case', 'UPPERCASE', and 'original'| |camelCase| |generateRoomModels|Generate Android Room database models in addition to API models (JVM Volley library only)| |false| |groupId|Generated artifact package's organization (i.e. maven groupId).| |org.openapitools| +|idea|Add IntellJ Idea plugin and mark Kotlin main and test folders as source folders.| |false| |library|Library template (sub-template) to use|
**jvm-ktor**
Platform: Java Virtual Machine. HTTP client: Ktor 1.6.7. JSON processing: Gson, Jackson (default).
**jvm-okhttp4**
[DEFAULT] Platform: Java Virtual Machine. HTTP client: OkHttp 4.2.0 (Android 5.0+ and Java 8+). JSON processing: Moshi 1.8.0.
**jvm-okhttp3**
Platform: Java Virtual Machine. HTTP client: OkHttp 3.12.4 (Android 2.3+ and Java 7+). JSON processing: Moshi 1.8.0.
**jvm-retrofit2**
Platform: Java Virtual Machine. HTTP client: Retrofit 2.6.2.
**multiplatform**
Platform: Kotlin multiplatform. HTTP client: Ktor 1.6.7. JSON processing: Kotlinx Serialization: 1.2.1.
**jvm-volley**
Platform: JVM for Android. HTTP client: Volley 1.2.1. JSON processing: gson 2.8.9
|jvm-okhttp4| |modelMutable|Create mutable models| |false| |moshiCodeGen|Whether to enable codegen with the Moshi library. Refer to the [official Moshi doc](https://github.com/square/moshi#codegen) for more info.| |false| diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinClientCodegen.java index 93a62b76ec4a..bcdc4f9eef73 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinClientCodegen.java @@ -73,6 +73,7 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen { public static final String ROOM_MODEL_PACKAGE = "roomModelPackage"; public static final String OMIT_GRADLE_PLUGIN_VERSIONS = "omitGradlePluginVersions"; public static final String OMIT_GRADLE_WRAPPER = "omitGradleWrapper"; + public static final String IDEA = "idea"; public static final String DATE_LIBRARY = "dateLibrary"; public static final String REQUEST_DATE_CONVERTER = "requestDateConverter"; @@ -235,6 +236,7 @@ public KotlinClientCodegen() { cliOptions.add(CliOption.newBoolean(USE_COROUTINES, "Whether to use the Coroutines adapter with the retrofit2 library.")); cliOptions.add(CliOption.newBoolean(OMIT_GRADLE_PLUGIN_VERSIONS, "Whether to declare Gradle plugin versions in build files.")); cliOptions.add(CliOption.newBoolean(OMIT_GRADLE_WRAPPER, "Whether to omit Gradle wrapper for creating a sub project.")); + cliOptions.add(CliOption.newBoolean(IDEA, "Add IntellJ Idea plugin and mark Kotlin main and test folders as source folders.")); cliOptions.add(CliOption.newBoolean(MOSHI_CODE_GEN, "Whether to enable codegen with the Moshi library. Refer to the [official Moshi doc](https://github.com/square/moshi#codegen) for more info."));