Interface ModelParser

All Superinterfaces:
SpiService

@Experimental @Consumer public interface ModelParser extends SpiService
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.
Since:
4.0.0
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Option that can be specified in the options map.
  • Method Summary

    Modifier and Type
    Method
    Description
    locate(Path dir)
    Locates the pom in the given directory.
    default Optional<Model>
    locateAndParse(Path dir, Map<String,?> options)
    Locate and parse the model in the specified directory.
    parse(Source source, Map<String,?> options)
    Parse the model obtained previously by a previous call to locate(Path).
  • Field Details

    • STRICT

      static final String STRICT
      Option that can be specified in the options map. The value should be a Boolean.
      See Also:
  • 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

      @Nonnull 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