Package org.apache.maven.api.spi
Interface ModelParser
The
ModelParser interface is used to locate and read Models from the file system.
This allows plugging in additional syntaxes for the main model read by Maven when building a project.-
Method Summary
Modifier and TypeMethodDescriptionLocates the pom in the given directory.locateAndParse(Path dir, Map<String, ?> options) Locate and parse the model in the specified directory.Parse the model obtained previously by a previous call tolocate(Path).
-
Method Details
-
locate
Locates the pom in the given directory.- Parameters:
dir- the directory to locate the pom for, nevernull- Returns:
- a
Sourcepointing to the located pom or an emptyOptionalif none was found by this parser
-
parse
@Nonnull Model parse(@Nonnull Source source, @Nullable Map<String, ?> options) throws ModelParserExceptionParse the model obtained previously by a previous call tolocate(Path).- Parameters:
source- the source to parse, nevernulloptions- possible parsing options, may benull- Returns:
- the parsed
Model, nevernull - Throws:
ModelParserException- if the model cannot be parsed
-
locateAndParse
default Optional<Model> locateAndParse(@Nonnull Path dir, @Nullable Map<String, ?> options) throws ModelParserExceptionLocate and parse the model in the specified directory. This is equivalent tolocate(dir).map(s -> parse(s, options)).- Parameters:
dir- the directory to locate the pom for, nevernulloptions- possible parsing options, may benull- Returns:
- an optional parsed
Modelornullif none could be found - Throws:
ModelParserException- if the located model cannot be parsed
-