Class PomParentSupport
java.lang.Object
network.ike.plugin.ws.PomParentSupport
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordParsed parent block from a POM file. -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanhasEmptyRelativePath(Path pomFile) Check whether a POM's<parent>block declares an empty<relativePath/>(self-closing or empty content).static booleanhasEmptyRelativePathInContent(String pomContent) Same ashasEmptyRelativePath(Path)but operating on raw POM content.static PomParentSupport.ParentInforeadParent(Path pomFile) Read the parent block from a POM file using the Maven 4 model API.static StringupdateParentVersion(String pomContent, String parentGroupId, String parentArtifactId, String newVersion) Update the parent version for a matchinggroupId:artifactId.
-
Method Details
-
readParent
Read the parent block from a POM file using the Maven 4 model API.- Parameters:
pomFile- path to pom.xml- Returns:
- the parent info, or null if no parent block
- Throws:
IOException- if the file cannot be read or parsed
-
updateParentVersion
public static String updateParentVersion(String pomContent, String parentGroupId, String parentArtifactId, String newVersion) Update the parent version for a matchinggroupId:artifactId. Delegates toPomRewriterfor AST-aware manipulation.Matching requires both groupId and artifactId to match — see issue #241.
- Parameters:
pomContent- POM XML as a stringparentGroupId- the groupId to match in the parent blockparentArtifactId- the artifactId to match in the parent blocknewVersion- the new version to set- Returns:
- updated POM content (unchanged if no match)
-
hasEmptyRelativePath
Check whether a POM's<parent>block declares an empty<relativePath/>(self-closing or empty content).An empty
relativePathdisables Maven's filesystem lookup for the parent — required to prevent the parent-cycle model-builder error when a subproject's<parent>GA matches the workspace aggregator's own parent GA (ike-issues#324).Detection is text-based rather than model-based: Maven 4's Parent model assigns a default value (typically
"../pom.xml") to absentrelativePathelements, so the parsed model cannot reliably distinguish "absent" from "default" from "explicit empty". The raw XML preserves that information.- Parameters:
pomFile- path to pom.xml- Returns:
truewhen the POM's<parent>block contains an empty<relativePath/>;falsewhen absent, non-empty, or the parent block itself is missing- Throws:
IOException- if the file cannot be read
-
hasEmptyRelativePathInContent
Same ashasEmptyRelativePath(Path)but operating on raw POM content. Used directly by tests and any caller that already has the content in memory.- Parameters:
pomContent- raw POM XML- Returns:
truewhen the<parent>block contains an empty<relativePath/>
-