Idea plugin for marking source directories, and omitting gradle wrapper (#12711)

* Idea plugin for marking source directories, and omitting gradle wrapper for creating sub projects

* Register the omitGradleWrapper option

* Added missing idea option
This commit is contained in:
anttikarhu
2022-06-28 18:06:10 +03:00
committed by GitHub
parent 5cb66a8ab0
commit 05ae49698f
3 changed files with 20 additions and 0 deletions

View File

@@ -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|<dl><dt>**jvm-ktor**</dt><dd>Platform: Java Virtual Machine. HTTP client: Ktor 1.6.7. JSON processing: Gson, Jackson (default).</dd><dt>**jvm-okhttp4**</dt><dd>[DEFAULT] Platform: Java Virtual Machine. HTTP client: OkHttp 4.2.0 (Android 5.0+ and Java 8+). JSON processing: Moshi 1.8.0.</dd><dt>**jvm-okhttp3**</dt><dd>Platform: Java Virtual Machine. HTTP client: OkHttp 3.12.4 (Android 2.3+ and Java 7+). JSON processing: Moshi 1.8.0.</dd><dt>**jvm-retrofit2**</dt><dd>Platform: Java Virtual Machine. HTTP client: Retrofit 2.6.2.</dd><dt>**multiplatform**</dt><dd>Platform: Kotlin multiplatform. HTTP client: Ktor 1.6.7. JSON processing: Kotlinx Serialization: 1.2.1.</dd><dt>**jvm-volley**</dt><dd>Platform: JVM for Android. HTTP client: Volley 1.2.1. JSON processing: gson 2.8.9</dd></dl>|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 &quot;@Parcelize&quot; 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)|<dl><dt>**toJson**</dt><dd>[DEFAULT] Date formatter option using a json converter.</dd><dt>**toString**</dt><dd>Use the 'toString'-method of the date-time object to retrieve the related string representation.</dd></dl>|toJson|

View File

@@ -72,6 +72,8 @@ 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 IDEA = "idea";
public static final String DATE_LIBRARY = "dateLibrary";
public static final String REQUEST_DATE_CONVERTER = "requestDateConverter";
@@ -233,6 +235,8 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
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(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."));

View File

@@ -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" }
@@ -53,6 +58,15 @@ repositories {
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"