Class ProjectWorkspaceReader
java.lang.Object
org.apache.maven.resolver.internal.ant.ProjectWorkspaceReader
- All Implemented Interfaces:
org.eclipse.aether.repository.WorkspaceReader
public class ProjectWorkspaceReader
extends Object
implements org.eclipse.aether.repository.WorkspaceReader
Workspace reader caching available POMs and artifacts for ant builds.
This reader helps Maven Resolver resolve artifacts and POMs from the build workspace without accessing a remote or local repository, useful during dependency resolution and POM inheritance scenarios where temporary or generated models are involved.
<pom> elements are cached if they are defined by the 'file'-attribute, as they reference a backing pom.xml file that can be used for resolution with Aether. <artifact> elements are cached if they directly define a 'pom'-attribute or child. The POM may be file-based or in-memory.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addArtifact
(Artifact artifact) Registers anArtifact
along with its associated POM.void
Registers aPom
into the workspace.findArtifact
(org.eclipse.aether.artifact.Artifact artifact) Attempts to resolve the artifact file for the given artifact from the workspace.findVersions
(org.eclipse.aether.artifact.Artifact artifact) Lists all known versions of the given artifact in the workspace.static ProjectWorkspaceReader
Returns the singleton instance of this workspace reader.org.eclipse.aether.repository.WorkspaceRepository
Returns the workspace repository used for this reader.
-
Method Details
-
addPom
Registers aPom
into the workspace. Only POMs backed by a file are accepted and cached.- Parameters:
pom
- the POM to register
-
addArtifact
Registers anArtifact
along with its associated POM. Only artifacts that reference a POM are accepted.- Parameters:
artifact
- the artifact to register
-
getRepository
public org.eclipse.aether.repository.WorkspaceRepository getRepository()Returns the workspace repository used for this reader. This is always named"ant"
.- Specified by:
getRepository
in interfaceorg.eclipse.aether.repository.WorkspaceReader
- Returns:
- the workspace repository
-
findArtifact
Attempts to resolve the artifact file for the given artifact from the workspace.- Specified by:
findArtifact
in interfaceorg.eclipse.aether.repository.WorkspaceReader
- Parameters:
artifact
- the artifact to locate- Returns:
- the associated file if found, or
null
if not registered
-
findVersions
Lists all known versions of the given artifact in the workspace.- Specified by:
findVersions
in interfaceorg.eclipse.aether.repository.WorkspaceReader
- Parameters:
artifact
- the artifact (ignoring version) to search for- Returns:
- list of available versions; may be empty but never
null
-
getInstance
Returns the singleton instance of this workspace reader. Creates the instance lazily and ensures thread safety.- Returns:
- the global
ProjectWorkspaceReader
instance
-