Package de.oktoflow.platform.cmdTools
Class PomReader
java.lang.Object
de.oktoflow.platform.cmdTools.PomReader
Implements some functions regarding pom files. Taken over from Qualimaster.
- Author:
- Patu
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static interfaceA simplified POM reading handler.static classSimple wrapper class for extracted information.static enum -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanequalsSafe(String s1, String s2) Checks the given strings for equality but only if none is null.static PomReader.PomInfoReturns the full classpath from a pom file.static PomReader.PomInfoReturns the full classpath from a POM file.private static voidparseParent(Node node, PomReader.PomHandler handler) Parses a POM parent information.private static voidparseProperties(Node node, PomReader.PomHandler handler) Parses a POM property information.private static voidreadPom(File file, PomReader.PomHandler handler) Reads a POM file and informs the handler.static PomReader.ResultreplaceVersion(File file, String oldPomVersion, String newPomVersion, String oldParentPomVersion, String newParentPomVersion, Set<String> properties) Replaces POM versions.static PomReader.ResultreplaceVersion(File file, String oldPomVersion, String newPomVersion, String oldParentPomVersion, String newParentPomVersion, Set<String> properties, Predicate<String> groupIdPattern) Replaces POM versions.private static booleanstartsWithSafe(String s1, String s2) Checks whethers1starts withs2but only if none is null.private static PomReader.ResulttoResult(PomReader.PomHandler handler) Turns handler results to a result constant.
-
Constructor Details
-
PomReader
public PomReader()
-
-
Method Details
-
getInfo
Returns the full classpath from a pom file.- Parameters:
file- The pom file to read from.- Returns:
- The full classpath or NULL if no classpath was available.
-
getInfo
Returns the full classpath from a POM file.- Parameters:
file- The pom file to read from.errorConsumer- consumes fatal errors, may be null for none- Returns:
- The full classpath or null if no classpath was available.
-
equalsSafe
Checks the given strings for equality but only if none is null.- Parameters:
s1- the first strings2- the second string- Returns:
trueif both are equal,falseelse
-
startsWithSafe
Checks whethers1starts withs2but only if none is null.- Parameters:
s1- the containing strings2- the prefix string- Returns:
trueifs1starts withs2,falseelse
-
readPom
Reads a POM file and informs the handler. Writes back the POM tofileifhandlerindicates a modification.- Parameters:
file- the file to readhandler- the handler- Throws:
IOException- if reading fails
-
parseParent
Parses a POM parent information.- Parameters:
node- the node identified as parenthandler- the POM handler
-
parseProperties
Parses a POM property information.- Parameters:
node- the node identified as parenthandler- the POM handler
-
replaceVersion
public static PomReader.Result replaceVersion(File file, String oldPomVersion, String newPomVersion, String oldParentPomVersion, String newParentPomVersion, Set<String> properties) throws IOException Replaces POM versions.- Parameters:
file- the POM fileoldPomVersion- the old POM version (may be null to ignore)newPomVersion- the new POM version (may be null to ignore)oldParentPomVersion- the old parent POM version (may be null to ignore)newParentPomVersion- the new parent POM version (may be null to ignore)properties- set of properties to be considered for POM version replacement- Returns:
- whether/how
filewas modified - Throws:
IOException- if reading/writing fails
-
replaceVersion
public static PomReader.Result replaceVersion(File file, String oldPomVersion, String newPomVersion, String oldParentPomVersion, String newParentPomVersion, Set<String> properties, Predicate<String> groupIdPattern) throws IOException Replaces POM versions.- Parameters:
file- the POM fileoldPomVersion- the old POM version (may be null to ignore)newPomVersion- the new POM version (may be null to ignore)oldParentPomVersion- the old parent POM version (may be null to ignore)newParentPomVersion- the new parent POM version (may be null to ignore)properties- set of properties to be considered for POM version replacementgroupIdPattern- optional pattern to match the group id (may be null to ignore)- Returns:
- whether/how
filewas modified - Throws:
IOException- if reading/writing fails
-
toResult
Turns handler results to a result constant.- Parameters:
handler- the handler- Returns:
- the result
-