Skip to content

Commit

Permalink
mention automatic de-duplication performed by pomXml closure (in cont…
Browse files Browse the repository at this point in the history
…rast to static model)
  • Loading branch information
xvik committed Mar 12, 2024
1 parent 7188494 commit 2afe74a
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 0 deletions.
78 changes: 78 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
<developers>
<developer>
<id>test</id>
<name>Test Test</name>
</developer>
<developer>
<id>test</id>
<name>Test Test</name>
</developer>
</developers>
```

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
<developers>
<developer>
<id>test</id>
<name>Test Test</name>
</developer>
</developers>
```

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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ class PomExtension {
* be specified like this.
* <p>
* ATTENTION: All properties assignment must be done as "method" - does not contain '='!
* <p>
* NOTE: Duplicate sections would be detected and merged automatically (like developers).
*
* @param config user pom
*/
Expand Down

0 comments on commit 2afe74a

Please sign in to comment.