Interface ModelParser


@Experimental public 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 Details

    • locate

      Locates the pom in the given directory.
      Parameters:
      dir - the directory to locate the pom for, never null
      Returns:
      a Source pointing to the located pom or an empty Optional if none was found by this parser
    • parse

      Parse the model obtained previously by a previous call to locate(Path).
      Parameters:
      source - the source to parse, never null
      options - possible parsing options, may be null
      Returns:
      the parsed Model, never null
      Throws:
      ModelParserException - if the model cannot be parsed
    • locateAndParse

      default Optional<Model> locateAndParse(@Nonnull Path dir, @Nullable Map<String,?> options) throws ModelParserException
      Locate and parse the model in the specified directory. This is equivalent to locate(dir).map(s -> parse(s, options)).
      Parameters:
      dir - the directory to locate the pom for, never null
      options - possible parsing options, may be null
      Returns:
      an optional parsed Model or null if none could be found
      Throws:
      ModelParserException - if the located model cannot be parsed