[kotlin] fixed support of source folder (#6133) (#6134)

This commit is contained in:
CappCorp 2017-07-23 05:34:02 +02:00 committed by wing328
parent b54bd0581a
commit a2a7ffe2bd
3 changed files with 11 additions and 0 deletions

View File

@ -149,6 +149,7 @@ public class KotlinClientCodegen extends DefaultCodegen implements CodegenConfig
importMapping.put("LocalTime", "java.time.LocalTime");
cliOptions.clear();
cliOptions.add(new CliOption(CodegenConstants.SOURCE_FOLDER, CodegenConstants.SOURCE_FOLDER_DESC).defaultValue(sourceFolder));
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_NAME, "Client package name (e.g. io.swagger).").defaultValue(this.packageName));
cliOptions.add(new CliOption(CodegenConstants.GROUP_ID, "Client package's organization (i.e. maven groupId).").defaultValue(groupId));
cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_ID, "Client artifact id (name of generated jar).").defaultValue(artifactId));
@ -191,6 +192,12 @@ public class KotlinClientCodegen extends DefaultCodegen implements CodegenConfig
public void processOpts() {
super.processOpts();
if (additionalProperties.containsKey(CodegenConstants.SOURCE_FOLDER)) {
this.setSourceFolder((String) additionalProperties.get(CodegenConstants.SOURCE_FOLDER));
} else {
additionalProperties.put(CodegenConstants.SOURCE_FOLDER, sourceFolder);
}
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) {
this.setPackageName((String) additionalProperties.get(CodegenConstants.PACKAGE_NAME));
} else {

View File

@ -34,6 +34,8 @@ public class KotlinClientCodegenOptionsTest extends AbstractOptionsTest {
times = 1;
codegen.setGroupId(KotlinClientCodegenOptionsProvider.GROUP_ID);
times = 1;
codegen.setSourceFolder(KotlinClientCodegenOptionsProvider.SOURCE_FOLDER);
times = 1;
}};
}
}

View File

@ -11,6 +11,7 @@ public class KotlinClientCodegenOptionsProvider implements OptionsProvider {
public static final String ARTIFACT_VERSION_VALUE = "0.0.1-SNAPSHOT";
public static final String ARTIFACT_ID = "swagger-kotlin-test";
public static final String GROUP_ID = "io.swagger.tests";
public static final String SOURCE_FOLDER = "./generated/kotlin";
@Override
public String getLanguage() {
@ -25,6 +26,7 @@ public class KotlinClientCodegenOptionsProvider implements OptionsProvider {
.put(CodegenConstants.ARTIFACT_VERSION, ARTIFACT_VERSION_VALUE)
.put(CodegenConstants.ARTIFACT_ID, ARTIFACT_ID)
.put(CodegenConstants.GROUP_ID, GROUP_ID)
.put(CodegenConstants.SOURCE_FOLDER, SOURCE_FOLDER)
.build();
}