Class PomParser
java.lang.Object
fr.paris.lutece.plugins.releaser.util.pom.PomParser
PomParser.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringType given to Maven build plugins extracted as dependencies. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets the dependencies.getProperties(fr.paris.lutece.plugins.releaser.business.jaxb.maven.Model model) Returns the properties declared in the pom, plus the implicitproject.versionandproject.parent.version.static DocumentBuilderFactoryReturns a DOM builder factory that never resolves external entities nor external DTDs.static SAXParserFactoryReturns a SAX parser factory that refuses DOCTYPE declarations and never resolves external entities : the POMs read come from repositories and Nexus, an external entity could read a file of the server or call any URL.voidparse(Component component, InputStream inputStream) Parses the.voidParses the.voidParses the.parseModules(String strPOM) Returns the modules declared by a pom, in declaration order.parseParent(String strPOM) Returns the parent of a pom as a dependency : groupId, artifactId and version.voidparsePomPath(Component component, String pomPath) Parses the pom path.parseProperty(String strPOM, String strName) Returns the value of a property of a pom, resolved against the other properties.parseReferencedArtifacts(String strPOM, String strGroupIdPrefix) Extracts every artifact referenced by a pom : dependencies, managed dependencies, build plugins and managed plugins.parseVersion(String strPOM) Returns the version of a pom, inherited from its parent when the project declares none.parseVersionProperties(String strPOM, String strPropertyPrefix, String strPropertySuffix, String strBomPOM) Extracts the artifacts whose version is driven by a naming convention on the pom properties, such aslutece.<artifactId>.version.static StringresolveValue(String strValue, Map<String, String> mapProperties) Resolves the Maven property placeholders (${name}) of a value, recursively.static <T> Tunmarshal(Class<T> docClass, InputSource inputSource) Unmarshal.
-
Field Details
-
TYPE_MAVEN_PLUGIN
Type given to Maven build plugins extracted as dependencies.- See Also:
-
-
Constructor Details
-
PomParser
public PomParser()
-
-
Method Details
-
getDependencies
Gets the dependencies.- Returns:
- the dependencies
-
parse
Parses the.- Parameters:
site- the sitestrPOM- the str POM
-
parsePomPath
Parses the pom path.- Parameters:
component- the componentpomPath- the pom path
-
parse
Parses the.- Parameters:
component- the componentstrPOM- the str POM
-
parse
Parses the.- Parameters:
component- the componentinputStream- the input stream
-
getProperties
public static Map<String,String> getProperties(fr.paris.lutece.plugins.releaser.business.jaxb.maven.Model model) Returns the properties declared in the pom, plus the implicitproject.versionandproject.parent.version.- Parameters:
model- the JAXB model of the pom- Returns:
- the properties (never null)
-
resolveValue
Resolves the Maven property placeholders (${name}) of a value, recursively. Unknown placeholders are left as is.- Parameters:
strValue- the value, possibly nullmapProperties- the properties- Returns:
- the resolved value
-
parseVersion
Returns the version of a pom, inherited from its parent when the project declares none.- Parameters:
strPOM- the pom content- Returns:
- the version, null if absent or if the pom cannot be parsed
-
parseParent
Returns the parent of a pom as a dependency : groupId, artifactId and version.- Parameters:
strPOM- the pom content- Returns:
- the parent, null if the pom has none or cannot be parsed
-
parseModules
Returns the modules declared by a pom, in declaration order.- Parameters:
strPOM- the pom content- Returns:
- the module names (empty if the pom has none or cannot be parsed)
-
parseProperty
Returns the value of a property of a pom, resolved against the other properties.- Parameters:
strPOM- the pom contentstrName- the property name- Returns:
- the value, null if the property is absent or the pom cannot be parsed
-
parseReferencedArtifacts
Extracts every artifact referenced by a pom : dependencies, managed dependencies, build plugins and managed plugins. Versions are resolved against the pom properties. Artifacts are deduplicated on groupId:artifactId (first declaration wins) and optionally filtered on a groupId prefix.- Parameters:
strPOM- the pom contentstrGroupIdPrefix- the groupId prefix to keep, or null to keep every artifact- Returns:
- the artifacts, in declaration order (empty if the pom cannot be parsed)
-
parseVersionProperties
public List<Dependency> parseVersionProperties(String strPOM, String strPropertyPrefix, String strPropertySuffix, String strBomPOM) Extracts the artifacts whose version is driven by a naming convention on the pom properties, such aslutece.<artifactId>.version. The groupId of each artifact is looked up in the managed dependencies of an optional bill of materials, resolved with the same properties.- Parameters:
strPOM- the pom holding the version propertiesstrPropertyPrefix- the property prefix (ex :lutece.)strPropertySuffix- the property suffix (ex :.version)strBomPOM- the bill of materials pom, or null- Returns:
- the artifacts, in property declaration order (groupId null when unknown ; empty if the pom cannot be parsed)
-
unmarshal
public static <T> T unmarshal(Class<T> docClass, InputSource inputSource) throws javax.xml.bind.JAXBException Unmarshal.- Type Parameters:
T- the generic type- Parameters:
docClass- the doc classinputSource- the input source- Returns:
- the t
- Throws:
javax.xml.bind.JAXBException- the JAXB exception
-
newSaxParserFactory
Returns a SAX parser factory that refuses DOCTYPE declarations and never resolves external entities : the POMs read come from repositories and Nexus, an external entity could read a file of the server or call any URL.- Returns:
- the namespace aware factory
- Throws:
ParserConfigurationException- if the parser cannot be secured
-
newDocumentBuilderFactory
public static DocumentBuilderFactory newDocumentBuilderFactory() throws ParserConfigurationExceptionReturns a DOM builder factory that never resolves external entities nor external DTDs. A DOCTYPE stays allowed : old plugin.xml descriptors may declare one.- Returns:
- the factory
- Throws:
ParserConfigurationException- if the parser cannot be secured
-