Class AntRepoSys
java.lang.Object
org.apache.maven.resolver.internal.ant.AntRepoSys
Central utility for managing Maven repository system configuration and sessions within Ant builds.
This class handles the lifecycle of a RepositorySystem and provides access to its components,
such as mirror selectors, proxy selectors, authentication, session management, and settings resolution.
It also provides methods for resolving dependencies, installing, and deploying artifacts.
An instance of this class is typically retrieved via getInstance(Project) and registered under
a predefined reference ID for reuse throughout the Ant build.
This class supports merging default and user-defined repositories and processing settings from
settings.xml files, including mirrors, proxies, and server credentials.
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddAuthentication(Authentication authentication) Registers anAuthenticationinstance to be used during authentication selection.voidRegisters aMirrorto be included in the mirror selector.voidRegisters aProxyto be considered when building the proxy selector.org.eclipse.aether.collection.CollectResultcollectDependencies(org.apache.tools.ant.Task task, Dependencies dependencies, LocalRepository localRepository, RemoteRepositories remoteRepositories) Performs dependency resolution by collecting transitive dependencies for the given configuration.voiddeploy(org.apache.tools.ant.Task task, Pom pom, Artifacts artifacts, RemoteRepository releaseRepository, RemoteRepository snapshotRepository) Deploys the specified artifacts to the configured remote repository (release or snapshot).Returns the defaultPom, if set.static AntRepoSysgetInstance(org.apache.tools.ant.Project project) Returns the singleton instance ofAntRepoSysassociated with the given AntProject.org.eclipse.aether.RepositorySystemSessiongetSession(org.apache.tools.ant.Task task, LocalRepository localRepo) Creates and returns a newRepositorySystemSessionfor the given task and local repository.org.eclipse.aether.RepositorySystemReturns theRepositorySystemused for dependency resolution and repository operations.voidInstalls the specified artifacts to the local Maven repository.org.apache.maven.model.ModelloadModel(org.apache.tools.ant.Task task, File pomFile, boolean local, RemoteRepositories remoteRepositories) Resolves aModelfrom apom.xmlfile, optionally validating it as a local or remote model.voidsetDefaultPom(Pom pom) Sets the defaultPomused for artifact operations when none is explicitly provided.voidsetGlobalSettings(File file) Sets the path to the globalsettings.xmlfile.voidsetLocalRepository(LocalRepository localRepository) Sets the local repository configuration.voidsetUserSettings(File file) Sets the path to the user-levelsettings.xmlfile.
-
Method Details
-
getInstance
Returns the singleton instance ofAntRepoSysassociated with the given AntProject. Registers a new instance if not already present.- Parameters:
project- the current Ant project- Returns:
- the
AntRepoSysinstance
-
getSystem
public org.eclipse.aether.RepositorySystem getSystem()Returns theRepositorySystemused for dependency resolution and repository operations.- Returns:
- the repository system instance
-
getSession
public org.eclipse.aether.RepositorySystemSession getSession(org.apache.tools.ant.Task task, LocalRepository localRepo) Creates and returns a newRepositorySystemSessionfor the given task and local repository. Configures authentication, mirrors, proxies, offline mode, and repository listeners.- Parameters:
task- the invoking Ant task (used for logging and listeners)localRepo- optional local repository configuration- Returns:
- a configured repository system session
-
setUserSettings
Sets the path to the user-levelsettings.xmlfile. If changed, forces reloading of settings.- Parameters:
file- the user settings file
-
setGlobalSettings
Sets the path to the globalsettings.xmlfile. If changed, forces reloading of settings.- Parameters:
file- the global settings file
-
addProxy
Registers aProxyto be considered when building the proxy selector.- Parameters:
proxy- the proxy configuration
-
addMirror
Registers aMirrorto be included in the mirror selector.- Parameters:
mirror- the mirror configuration
-
addAuthentication
Registers anAuthenticationinstance to be used during authentication selection.- Parameters:
authentication- the authentication configuration
-
setLocalRepository
Sets the local repository configuration.- Parameters:
localRepository- the local repository configuration
-
loadModel
public org.apache.maven.model.Model loadModel(org.apache.tools.ant.Task task, File pomFile, boolean local, RemoteRepositories remoteRepositories) Resolves aModelfrom apom.xmlfile, optionally validating it as a local or remote model.- Parameters:
task- the Ant task contextpomFile- the POM filelocal- whether to load the model in strict/local moderemoteRepositories- optional custom remote repositories- Returns:
- the effective Maven model
- Throws:
org.apache.tools.ant.BuildException- if the POM cannot be loaded or resolved
-
setDefaultPom
Sets the defaultPomused for artifact operations when none is explicitly provided.- Parameters:
pom- the default POM
-
getDefaultPom
Returns the defaultPom, if set.- Returns:
- the default POM or
null
-
collectDependencies
public org.eclipse.aether.collection.CollectResult collectDependencies(org.apache.tools.ant.Task task, Dependencies dependencies, LocalRepository localRepository, RemoteRepositories remoteRepositories) Performs dependency resolution by collecting transitive dependencies for the given configuration.- Parameters:
task- the Ant task contextdependencies- the root dependencieslocalRepository- optional local repository overrideremoteRepositories- optional custom remote repositories- Returns:
- the result of dependency collection
- Throws:
org.apache.tools.ant.BuildException- if the dependency collection fails
-
install
Installs the specified artifacts to the local Maven repository.- Parameters:
task- the Ant task contextpom- the associated POM metadataartifacts- the artifacts to install- Throws:
org.apache.tools.ant.BuildException- if the installation fails
-
deploy
public void deploy(org.apache.tools.ant.Task task, Pom pom, Artifacts artifacts, RemoteRepository releaseRepository, RemoteRepository snapshotRepository) Deploys the specified artifacts to the configured remote repository (release or snapshot).- Parameters:
task- the Ant task contextpom- the associated POM metadataartifacts- the artifacts to deployreleaseRepository- the repository for release artifactssnapshotRepository- the repository for snapshot artifacts- Throws:
org.apache.tools.ant.BuildException- if the deployment fails
-