Skip to content

Commit d2e73d2

Browse files
authored
Add support for template files with ".xml-tmpl" suffix (#35)
Keep support for ".xml.tmpl" template file suffixes for backwards compatibility. Fixes #33
1 parent 0435d36 commit d2e73d2

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

pom/pom.go

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,18 +108,26 @@ func SetDependencyVersion(module p.Module, groupId string, artifactId string, ne
108108
}
109109
}
110110

111+
var templateFileSuffixes = map[string]string{
112+
".xml.tmpl": ".xml",
113+
".xml-tmpl": ".xml",
114+
}
115+
111116
func WriteTemplates(config c.Config, project p.Project) {
112-
// Scan project directory for all .xml.tmpl templates and generate the actual files
117+
// Scan project directory for all supported templates and generate the actual files
113118
err := filepath.Walk(utils.GetCwd(), func(path string, info os.FileInfo, err error) error {
114119
if err != nil {
115120
return err
116121
}
117122

118-
if strings.HasSuffix(path, ".xml.tmpl") {
119-
templateFile := utils.GetRelativePath(path)
120-
outputFile := strings.TrimSuffix(templateFile, filepath.Ext(templateFile))
121-
xmltemplate.WriteXmlFile(config, project, templateFile, outputFile)
123+
for templateSuffix, outputSuffix := range templateFileSuffixes {
124+
if strings.HasSuffix(path, templateSuffix) {
125+
templateFile := utils.GetRelativePath(path)
126+
outputFile := strings.TrimSuffix(templateFile, templateSuffix) + outputSuffix
127+
xmltemplate.WriteXmlFile(config, project, templateFile, outputFile)
128+
}
122129
}
130+
123131
return nil
124132
})
125133

0 commit comments

Comments
 (0)