diff --git a/center.js b/center.js
index 9e3a2dd..eb23744 100644
--- a/center.js
+++ b/center.js
@@ -63,9 +63,9 @@ function generateParentTemplate(parentPom) {
let template = parentPom.replace('.xml', '.template.xml')
if (ops.exists(template)) {
let content = ops.read(template)
- .replace('G', parentGroup())
- .replace('A', parentArtifact(parentPom))
- .replace('V', parentVersion())
+ .replace(/G/g, parentGroup())
+ .replace(/A/g, parentArtifact(parentPom))
+ .replace(/V/g, parentVersion())
.replace('', artifactModules.map(m => `
${m.path}`).join(''))
@@ -76,11 +76,28 @@ function generateParentTemplate(parentPom) {
function generatePom(module, rule, parentPom) {
let coords = mvn.coords(jarOf(rule))
// for each
- let relativePath = '../' + parentPom
+ let parentPath = '../' + parentPom
for (let ch of module.path) {
- if (ch === '/') relativePath = '../' + relativePath
+ if (ch === '/') parentPath = '../' + parentPath
}
- let content = `
+
+ let pom = paths.join(module.path, 'pom.xml')
+ let template = paths.join(module.path, 'pom.template.xml')
+ let content
+
+ if (ops.exists(template)) {
+ content = ops.read(template)
+ .replace(/G/g, coords.group)
+ .replace(/A/g, coords.artifact)
+ .replace(/V/g, coords.version)
+ .replace(/G/g, parentGroup())
+ .replace(/A/g, parentArtifact(parentPom))
+ .replace(/V/g, parentVersion())
+ .replace(/P/g, parentPath)
+ .replace('', pomDependencies(module))
+
+ } else {
+ content = `
4.0.0
${coords.group}
@@ -92,13 +109,14 @@ function generatePom(module, rule, parentPom) {
${parentGroup()}
${parentArtifact(parentPom)}
${parentVersion()}
- ${relativePath}
+ ${parentPath}
${pomDependencies(module)}
`
- ops.write(paths.join(module.path, 'pom.xml'), content)
+ }
+ ops.write(pom, content)
}
function pomDependencies(module) {