Package org.apache.maven.api.services
Interface ModelSource
- All Superinterfaces:
Source
Represents a source for loading Maven Project Object Model (POM) files. This interface
extends the basic
Source
interface with specific functionality for handling
Maven POM files and resolving related project POMs.
The interface provides two types of sources:
- Build sources: Used for POM files of projects being built by Maven in the filesystem.
These sources support resolving related POMs using the
ModelSource.ModelLocator
. - Resolved sources: 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.
- Since:
- 4.0.0
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface
Interface for locating POM files within a project structure. -
Method Summary
Modifier and TypeMethodDescriptionresolve
(ModelSource.ModelLocator modelLocator, String relative) Resolves a relative path to another POM file using the provided model locator.Methods inherited from interface org.apache.maven.api.services.Source
getLocation, getPath, openStream, resolve
-
Method Details
-
resolve
@Nullable ModelSource resolve(@Nonnull ModelSource.ModelLocator modelLocator, @Nonnull String relative) Resolves a relative path to another POM file using the provided model locator. This method is specifically used to locate POM files for subprojects or related projects referenced from the current POM.The resolution process typically involves:
- Normalizing the relative path for the current platform
- Resolving the path against the current POM's location
- Using the model locator to find an existing POM at the resolved location
- Parameters:
modelLocator
- the locator to use for finding the related POM filerelative
- the relative path to resolve- Returns:
- a new ModelSource for the resolved POM, or null if:
- This is not a build source
- No POM can be found at the resolved location
- Throws:
NullPointerException
- if modelLocator or relative is null
-