diff --git a/README.md b/README.md index 040df54..837d04a 100644 --- a/README.md +++ b/README.md @@ -485,6 +485,84 @@ INFO: `pomXml` option is a legacy plugin mechanism (developed in times when mave provide anything except direct pom modification). Before pom plugin version 3.0 this was the main configuration (applied with `pom` convention) +###### Duplicate xml sections detection + +Groovy closure (`pomXml`) could also be useful when you want to avoid duplicates. + +For example, static model would always apply specified sections: + +```groovy +maven.pom { + developers { + developer { + id = 'test' + name = 'Test Test' + } + } +} + +maven.pom { + developers { + developer { + id = 'test' + name = 'Test Test' + } + } +} +``` + +This would produce duplicate in the resulted xml: + + +```xml + + + test + Test Test + + + test + Test Test + + +``` + +Whereas groovy closure: + +```groovy +maven.pomXml { + developers { + developer { + id 'test' + name 'Test Test' + } + } +} + +maven.pomXml { + developers { + developer { + id 'test' + name 'Test Test' + } + } +} +``` + +Would correctly detect duplication and the resulted xml would be: + +```xml + + + test + Test Test + + +``` + +It is a very rare requirement to avoid duplications (appeared when pom is configured from multiple places), +but still could appear, and, in this case, groovy closue (`pomXml`) could be very useful. + ###### Clashed tag names As `pomXml` closure is normal groovy closure, you may face situations when tag name clash with some method in your gradle project. diff --git a/src/main/groovy/ru/vyarus/gradle/plugin/pom/PomExtension.groovy b/src/main/groovy/ru/vyarus/gradle/plugin/pom/PomExtension.groovy index d6d3c1f..808498b 100644 --- a/src/main/groovy/ru/vyarus/gradle/plugin/pom/PomExtension.groovy +++ b/src/main/groovy/ru/vyarus/gradle/plugin/pom/PomExtension.groovy @@ -152,6 +152,8 @@ class PomExtension { * be specified like this. *

* ATTENTION: All properties assignment must be done as "method" - does not contain '='! + *

+ * NOTE: Duplicate sections would be detected and merged automatically (like developers). * * @param config user pom */