Support several templates
This commit is contained in:
parent
127e4013e0
commit
e4e6b6fc25
1 changed files with 21 additions and 9 deletions
|
@ -61,8 +61,14 @@ public class TargetGenerator {
|
|||
cfg.setWrapUncheckedExceptions(true);
|
||||
cfg.setFallbackOnNullLoopVariable(false);
|
||||
Template temp = cfg.getTemplate(ENDPOINTS_TEMPLATE_NAME);
|
||||
List<Path> templates = Files
|
||||
.list(this.templatePath)
|
||||
.filter(Files::isRegularFile)
|
||||
.filter(f -> f.getFileName().toString().endsWith(".ftl"))
|
||||
.toList() ;
|
||||
for (Path template : templates) {
|
||||
try (var outputFile = Files.newBufferedWriter(
|
||||
outputPath.resolve("endpoints.scala"),
|
||||
outputName(template),
|
||||
StandardOpenOption.CREATE,
|
||||
StandardOpenOption.TRUNCATE_EXISTING
|
||||
)) {
|
||||
|
@ -71,8 +77,14 @@ public class TargetGenerator {
|
|||
templateData.put("datatypes", dataTypes);
|
||||
temp.process(templateData, outputFile);
|
||||
}
|
||||
}
|
||||
} catch (TemplateException | IOException ex) {
|
||||
throw new TargetGeneratorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
private Path outputName(Path templatePath) {
|
||||
String name = templatePath.getFileName().toString().replace(".ftl", ".scala") ;
|
||||
return this.outputPath.resolve(name) ;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue