Skip to content

Commit

Permalink
refs #1319 - add configFiles list
Browse files Browse the repository at this point in the history
  • Loading branch information
frantuma committed Nov 4, 2024
1 parent 63714c6 commit af82239
Showing 1 changed file with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,11 @@ public abstract class DefaultCodegenConfig implements CodegenConfig {
protected String templateVersion;
protected String embeddedTemplateDir;
protected String commonTemplateDir = "_common";
protected Map<String, Object> additionalProperties = new HashMap<String, Object>();
protected Map<String, Object> additionalProperties = new HashMap<>();
protected Map<String, Object> vendorExtensions = new HashMap<String, Object>();
protected List<SupportingFile> supportingFiles = new ArrayList<SupportingFile>();
protected List<CliOption> cliOptions = new ArrayList<CliOption>();
protected List<SupportingFile> supportingFiles = new ArrayList<>();
protected List<SupportingFile> configFiles = new ArrayList<>();
protected List<CliOption> cliOptions = new ArrayList<>();
protected List<CodegenArgument> languageArguments;
protected boolean skipOverwrite;
protected boolean removeOperationIdPrefix;
Expand Down Expand Up @@ -664,6 +665,10 @@ public List<SupportingFile> supportingFiles() {
return supportingFiles;
}

public List<SupportingFile> configFiles() {
return configFiles;
}

public String outputFolder() {
return outputFolder;
}
Expand Down Expand Up @@ -3807,13 +3812,16 @@ protected String getOptionValue(String optionName) {
return codegenArgumentOptional.get().getValue();
}

public void writeOptional(String outputFolder, SupportingFile supportingFile) {
writeOptional(outputFolder, supportingFile, false);
}
/**
* Only write if the file doesn't exist
*
* @param outputFolder Output folder
* @param supportingFile Supporting file
*/
public void writeOptional(String outputFolder, SupportingFile supportingFile) {
public void writeOptional(String outputFolder, SupportingFile supportingFile, boolean configFile) {
String folder = "";

if(outputFolder != null && !"".equals(outputFolder)) {
Expand All @@ -3826,8 +3834,9 @@ public void writeOptional(String outputFolder, SupportingFile supportingFile) {
else {
folder = supportingFile.destinationFilename;
}
List<SupportingFile> targetFiles = configFile ? this.configFiles : this.supportingFiles;
if(!new File(folder).exists()) {
supportingFiles.add(supportingFile);
targetFiles.add(supportingFile);
} else {
LOGGER.info("Skipped overwriting " + supportingFile.destinationFilename + " as the file already exists in " + folder);
}
Expand Down

0 comments on commit af82239

Please sign in to comment.