Skip to content

Commit

Permalink
chore: use type-safe DSL instead of direct XML manipulation for pom.xml
Browse files Browse the repository at this point in the history
Dedicated DSL usage should be safer in order to detect typos.

This has the side effect of changing the order of the XML elements, but
this is more canonical this way.

https://docs.gradle.org/4.8/release-notes.html#customizing-the-generated-pom
https://docs.gradle.org/current/userguide/publishing_maven.html#sec:modifying_the_generated_pom
  • Loading branch information
Fiouz authored and remkop committed Feb 21, 2021
1 parent c353a28 commit 686c6dc
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 58 deletions.
35 changes: 17 additions & 18 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -166,26 +166,26 @@ allprojects {
mavenOssUser = System.getenv('MAVEN_OSS_USER')
mavenOssPassword = System.getenv('MAVEN_OSS_PASSWORD')

// pom configuration for MavenPublication
// pom configuration for MavenPublication, as per https://docs.gradle.org/current/userguide/publishing_maven.html#sec:modifying_the_generated_pom
pomConfig = {
licenses {
license {
name "The Apache Software License, version 2.0"
url "http://www.apache.org/licenses/LICENSE-2.0.txt"
distribution "repo"
name = "The Apache Software License, version 2.0"
url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
distribution = "repo"
}
}
developers {
developer {
id "rpopma"
name "Remko Popma"
email "rpopma@apache.org"
id = "rpopma"
name = "Remko Popma"
email = "rpopma@apache.org"
}
}
scm {
url "https://github.com/remkop/picocli/tree/master"
connection 'scm:git:https://github.com/remkop/picocli.git'
developerConnection 'scm:git:ssh://github.com:remkop/picocli.git'
url = "https://github.com/remkop/picocli/tree/master"
connection = 'scm:git:https://github.com/remkop/picocli.git'
developerConnection = 'scm:git:ssh://github.com:remkop/picocli.git'
}
}
}
Expand Down Expand Up @@ -442,15 +442,14 @@ publishing {
groupId 'info.picocli'
artifactId bintrayPackage
version "$projectVersion"
pom.withXml {
def root = asNode()
root.appendNode('packaging', 'jar')
root.appendNode('name', 'picocli - a mighty tiny Command Line Interface')
root.appendNode('description', description)
root.appendNode('url', 'http://picocli.info')
root.appendNode('inceptionYear', '2017')
root.children().last() + pomConfig
pom {
packaging = 'jar'
name = 'picocli - a mighty tiny Command Line Interface'
description = project.description
url = 'http://picocli.info'
inceptionYear = '2017'
}
pom pomConfig
}
}
}
Expand Down
15 changes: 7 additions & 8 deletions picocli-codegen/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,14 @@ publishing {
groupId 'info.picocli'
artifactId bintrayPackage
version "$projectVersion"
pom.withXml {
def root = asNode()
root.appendNode('packaging', 'jar')
root.appendNode('name', bintrayPackage)
root.appendNode('description', description)
root.appendNode('url', 'http://picocli.info')
root.appendNode('inceptionYear', '2018')
root.children().last() + pomConfig
pom {
packaging = 'jar'
name = bintrayPackage
description = project.description
url = 'http://picocli.info'
inceptionYear = '2018'
}
pom pomConfig
}
}
}
Expand Down
15 changes: 7 additions & 8 deletions picocli-groovy/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,14 @@ publishing {
groupId 'info.picocli'
artifactId bintrayPackage
version "$projectVersion"
pom.withXml {
def root = asNode()
root.appendNode('packaging', 'jar')
root.appendNode('name', bintrayPackage)
root.appendNode('description', description)
root.appendNode('url', 'http://picocli.info')
root.appendNode('inceptionYear', '2018')
root.children().last() + pomConfig
pom {
packaging = 'jar'
name = bintrayPackage
description = project.description
url = 'http://picocli.info'
inceptionYear = '2018'
}
pom pomConfig
}
}
}
15 changes: 7 additions & 8 deletions picocli-shell-jline2/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,14 @@ publishing {
groupId 'info.picocli'
artifactId bintrayPackage
version "$projectVersion"
pom.withXml {
def root = asNode()
root.appendNode('packaging', 'jar')
root.appendNode('name', bintrayPackage)
root.appendNode('description', description)
root.appendNode('url', 'http://picocli.info')
root.appendNode('inceptionYear', '2018')
root.children().last() + pomConfig
pom {
packaging = 'jar'
name = bintrayPackage
description = project.description
url = 'http://picocli.info'
inceptionYear = '2018'
}
pom pomConfig
}
}
}
15 changes: 7 additions & 8 deletions picocli-shell-jline3/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,14 @@ publishing {
groupId 'info.picocli'
artifactId bintrayPackage
version "$projectVersion"
pom.withXml {
def root = asNode()
root.appendNode('packaging', 'jar')
root.appendNode('name', bintrayPackage)
root.appendNode('description', description)
root.appendNode('url', 'http://picocli.info')
root.appendNode('inceptionYear', '2018')
root.children().last() + pomConfig
pom {
packaging = 'jar'
name = bintrayPackage
description = project.description
url = 'http://picocli.info'
inceptionYear = '2018'
}
pom pomConfig
}
}
}
15 changes: 7 additions & 8 deletions picocli-spring-boot-starter/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,14 @@ publishing {
groupId 'info.picocli'
artifactId bintrayPackage
version "$projectVersion"
pom.withXml {
def root = asNode()
root.appendNode('packaging', 'jar')
root.appendNode('name', bintrayPackage)
root.appendNode('description', description)
root.appendNode('url', 'http://picocli.info')
root.appendNode('inceptionYear', '2019')
root.children().last() + pomConfig
pom {
packaging = 'jar'
name = bintrayPackage
description = project.description
url = 'http://picocli.info'
inceptionYear = '2019'
}
pom pomConfig
}
}
}

0 comments on commit 686c6dc

Please sign in to comment.