Class Sources

java.lang.Object
org.apache.maven.api.services.Sources

@Experimental public final class Sources extends Object
Factory methods for creating different types of sources.

This class provides specialized source implementations for different use cases:

  • Path sources - simple access to file content
  • Build sources - POM files being actively built by Maven
  • Resolved sources - POMs resolved from repositories
Since:
4.0.0
  • Method Details

    • fromPath

      @Nonnull public static Source fromPath(@Nonnull Path path)
      Creates a new source for the specified path.
      Parameters:
      path - the path to the file
      Returns:
      a new Source instance
      Throws:
      NullPointerException - if path is null
    • buildSource

      @Nonnull public static ModelSource buildSource(@Nonnull Path path)
      Creates a new build source for the specified path. Build sources are used for POM files of projects being built by Maven in the filesystem and support resolving related POMs.
      Parameters:
      path - the path to the POM file or project directory
      Returns:
      a new ModelSource instance configured as a build source
      Throws:
      NullPointerException - if path is null
    • resolvedSource

      @Nonnull public static ModelSource resolvedSource(@Nonnull Path path, @Nullable String location)
      Creates a new resolved source for the specified path and location. Resolved sources are used for artifacts that have been resolved by Maven from repositories (using groupId:artifactId:version coordinates) and downloaded to the local repository. These sources do not support resolving other sources.
      Parameters:
      path - the path to the POM file or project directory
      location - optional logical location of the source, used for reporting purposes
      Returns:
      a new ModelSource instance configured as a resolved source
      Throws:
      NullPointerException - if path is null