mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-05-12 20:50:55 +00:00
add omitGradleWrapper option to kotlin-server code generator (#16528)
The added option removes the wrapper part of build.gradle, enabling the generated project to be used as a sub project. The same option from kotlin client was used as reference for this change.
This commit is contained in:
parent
c614b9d9b1
commit
75c2e934da
@ -34,6 +34,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|interfaceOnly|Whether to generate only API interface stubs without the server files. This option is currently supported only when using jaxrs-spec library.| |false|
|
||||
|library|library template (sub-template)|<dl><dt>**ktor**</dt><dd>ktor framework</dd><dt>**jaxrs-spec**</dt><dd>JAX-RS spec only</dd></dl>|ktor|
|
||||
|modelMutable|Create mutable models| |false|
|
||||
|omitGradleWrapper|Whether to omit Gradle wrapper for creating a sub project.| |false|
|
||||
|packageName|Generated artifact package name.| |org.openapitools.server|
|
||||
|parcelizeModels|toggle "@Parcelize" for generated models| |null|
|
||||
|returnResponse|Whether generate API interface should return javax.ws.rs.core.Response instead of a deserialized entity. Only useful if interfaceOnly is true. This option is currently supported only when using jaxrs-spec library.| |false|
|
||||
|
@ -50,6 +50,7 @@ public class KotlinServerCodegen extends AbstractKotlinCodegen implements BeanVa
|
||||
private boolean useCoroutines = false;
|
||||
private boolean useMutiny = false;
|
||||
private boolean returnResponse = false;
|
||||
private boolean omitGradleWrapper = false;
|
||||
|
||||
// This is here to potentially warn the user when an option is not supported by the target framework.
|
||||
private Map<String, List<String>> optionsSupportedPerFramework = new ImmutableMap.Builder<String, List<String>>()
|
||||
@ -60,7 +61,8 @@ public class KotlinServerCodegen extends AbstractKotlinCodegen implements BeanVa
|
||||
Constants.CORS,
|
||||
Constants.COMPRESSION,
|
||||
Constants.RESOURCES,
|
||||
Constants.METRICS
|
||||
Constants.METRICS,
|
||||
Constants.OMIT_GRADLE_WRAPPER
|
||||
))
|
||||
.put(Constants.JAXRS_SPEC, Arrays.asList(
|
||||
USE_BEANVALIDATION,
|
||||
@ -132,6 +134,7 @@ public class KotlinServerCodegen extends AbstractKotlinCodegen implements BeanVa
|
||||
addSwitch(Constants.USE_COROUTINES, Constants.USE_COROUTINES_DESC, useCoroutines);
|
||||
addSwitch(Constants.USE_MUTINY, Constants.USE_MUTINY_DESC, useMutiny);
|
||||
addSwitch(Constants.RETURN_RESPONSE, Constants.RETURN_RESPONSE_DESC, returnResponse);
|
||||
addSwitch(Constants.OMIT_GRADLE_WRAPPER, Constants.OMIT_GRADLE_WRAPPER_DESC, omitGradleWrapper);
|
||||
addSwitch(USE_JAKARTA_EE, Constants.USE_JAKARTA_EE_DESC, useJakartaEe);
|
||||
}
|
||||
|
||||
@ -183,6 +186,14 @@ public class KotlinServerCodegen extends AbstractKotlinCodegen implements BeanVa
|
||||
return resourcesFeatureEnabled;
|
||||
}
|
||||
|
||||
public boolean getOmitGradleWrapper() {
|
||||
return omitGradleWrapper;
|
||||
}
|
||||
|
||||
public void setOmitGradleWrapper(boolean omitGradleWrapper) {
|
||||
this.omitGradleWrapper = omitGradleWrapper;
|
||||
}
|
||||
|
||||
public void setResourcesFeatureEnabled(Boolean resourcesFeatureEnabled) {
|
||||
this.resourcesFeatureEnabled = resourcesFeatureEnabled;
|
||||
}
|
||||
@ -247,6 +258,10 @@ public class KotlinServerCodegen extends AbstractKotlinCodegen implements BeanVa
|
||||
setUseBeanValidation(convertPropertyToBoolean(USE_BEANVALIDATION));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(Constants.OMIT_GRADLE_WRAPPER)) {
|
||||
setOmitGradleWrapper(Boolean.parseBoolean(additionalProperties.get(Constants.OMIT_GRADLE_WRAPPER).toString()));
|
||||
}
|
||||
|
||||
writePropertyBack(USE_BEANVALIDATION, useBeanValidation);
|
||||
|
||||
// set default library to "ktor"
|
||||
@ -360,6 +375,8 @@ public class KotlinServerCodegen extends AbstractKotlinCodegen implements BeanVa
|
||||
public static final String USE_JAKARTA_EE_DESC = "whether to use Jakarta EE namespace instead of javax";
|
||||
public static final String USE_MUTINY = "useMutiny";
|
||||
public static final String USE_MUTINY_DESC = "Whether to use Mutiny (should not be used with useCoroutines). This option is currently supported only when using jaxrs-spec library.";
|
||||
public static final String OMIT_GRADLE_WRAPPER = "omitGradleWrapper";
|
||||
public static final String OMIT_GRADLE_WRAPPER_DESC = "Whether to omit Gradle wrapper for creating a sub project.";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2,7 +2,7 @@ group "{{groupId}}"
|
||||
version "{{artifactVersion}}"
|
||||
|
||||
wrapper {
|
||||
gradleVersion = "6.9"
|
||||
gradleVersion = '6.9'
|
||||
distributionUrl = "https://services.gradle.org/distributions/gradle-$gradleVersion-all.zip"
|
||||
}
|
||||
|
||||
@ -67,4 +67,4 @@ dependencies {
|
||||
implementation("io.smallrye.reactive:mutiny-kotlin:$mutiny_version")
|
||||
{{/useMutiny}}
|
||||
testImplementation("junit:junit:4.13.2")
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,12 @@
|
||||
group "{{groupId}}"
|
||||
version "{{artifactVersion}}"
|
||||
{{^omitGradleWrapper}}
|
||||
|
||||
wrapper {
|
||||
gradleVersion = "7.4.2"
|
||||
distributionUrl = "https://services.gradle.org/distributions/gradle-$gradleVersion-all.zip"
|
||||
}
|
||||
{{/omitGradleWrapper}}
|
||||
|
||||
buildscript {
|
||||
ext.kotlin_version = "1.7.20"
|
||||
|
@ -2,7 +2,7 @@ group "org.openapitools"
|
||||
version "1.0.0"
|
||||
|
||||
wrapper {
|
||||
gradleVersion = "7.4.2"
|
||||
gradleVersion = '7.5'
|
||||
distributionUrl = "https://services.gradle.org/distributions/gradle-$gradleVersion-all.zip"
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user