Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions build-logic/src/main/kotlin/publishing/configurePom.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package publishing

import groovy.namespace.QName
import groovy.util.Node
import org.gradle.api.Project
import org.gradle.api.Task
Expand Down Expand Up @@ -58,7 +59,23 @@ internal fun configurePom(project: Project, mavenPublication: MavenPublication,
val projectNode = asNode()

val parentNode = projectNode.appendNode("parent")
// Guarantee that the <parent> element is at a deterministic location.
// This is important for reproducible builds!
projectNode.remove(parentNode)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why append on line 61 and immediately remove here?

for ((index, any) in projectNode.children().withIndex()) {
if (any is Node) {
val qName = any.name() as QName
if (qName.localPart == "groupId") {
// In theory, we could also replace the groupId element, as the group ID is
// currently the same.
// But this would break once another group ID is built.
projectNode.children().add(index, parentNode)
break
}
}
}
val parent = project.parent!!
// Add GAV to <parent> element
parentNode.appendNode("groupId", parent.group)
parentNode.appendNode("artifactId", parent.name)
parentNode.appendNode("version", parent.version)
Expand Down