Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refs #1319 - add configFiles list #1321

Merged
merged 1 commit into from
Nov 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading