Class Dependencies
- All Implemented Interfaces:
Cloneable,DependencyContainer
This Ant DataType represents a collection of Dependency elements.
It is typically used within tasks like Resolve,
CreatePom,
Deploy, and
Install to provide
structured dependency information.
Usage Example (inline):
<repo:resolve>
<repo:dependencies>
<repo:dependency groupId="org.apache.commons" artifactId="commons-lang3" version="3.18.0"/>
<repo:dependency groupId="com.google.guava" artifactId="guava" version="32.0.2"/>
</repo:dependencies>
<path id="my.classpath"/>
</resolve>
Usage Example (referenced):
<dependencies id="compile.deps">
<dependency groupId="org.slf4j" artifactId="slf4j-api" version="2.0.7"/>
</dependencies>
<resolve dependenciesRef="compile.deps">
<path id="compile.classpath"/>
</resolve>
Attributes:
- id — optional Ant reference ID, allowing reuse in multiple tasks
Nested Elements:
<dependency>— defines a single Maven dependency (seeDependency)
Typical Use Cases:
- Providing dependencies to resolution tasks like Resolve or CreatePom
- Reusing a named set of dependencies across tasks via
dependenciesRef
Behavior:
After being referenced by a task (e.g. viadependenciesRef), the container is
evaluated and each contained <dependency> is passed to the task’s resolution
or POM generation logic.- See Also:
-
Field Summary
Fields inherited from class org.apache.tools.ant.types.DataType
checked, refFields inherited from class org.apache.tools.ant.ProjectComponent
description, location, project -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDependencies(Dependencies dependencies) Adds anotherDependenciescontainer to this one.voidaddDependency(Dependency dependency) Adds a singleDependencyto this container.voidaddExclusion(Exclusion exclusion) Adds anExclusionelement to apply to all dependencies in this container.voidAllows ant to add the pom element specified in the build file.Returns the list of containedDependencyContainerinstances.Returns the list of exclusions applied to this container.getFile()Get the file attribute.getPom()Returns thePomelement if one was added to this container.protected DependenciesgetRef()Resolves this object if defined as a reference and verifies that it is aDependenciesinstance.voidSet the file attribute.voidsetPomRef(org.apache.tools.ant.types.Reference ref) Assigns a reference to aPomelement that defines the dependencies.voidsetRefid(org.apache.tools.ant.types.Reference ref) Sets the reference to another<dependencies>defined elsewhere.voidvalidate(org.apache.tools.ant.Task task) Validates the container's internal structure and attributes.Methods inherited from class org.apache.tools.ant.types.DataType
checkAttributesAllowed, checkChildrenAllowed, circularReference, clone, dieOnCircularReference, dieOnCircularReference, dieOnCircularReference, getCheckedRef, getCheckedRef, getCheckedRef, getCheckedRef, getCheckedRef, getDataTypeName, getRefid, invokeCircularReferenceCheck, isChecked, isReference, noChildrenAllowed, pushAndInvokeCircularReferenceCheck, setChecked, tooManyAttributes, toStringMethods inherited from class org.apache.tools.ant.ProjectComponent
getDescription, getLocation, getProject, log, log, setDescription, setLocation, setProject
-
Constructor Details
-
Dependencies
public Dependencies()Default constructor for the Dependencies data type.
-
-
Method Details
-
getRef
Resolves this object if defined as a reference and verifies that it is aDependenciesinstance.- Returns:
- the referenced
Dependenciesinstance - Throws:
org.apache.tools.ant.BuildException- if the reference is invalid
-
validate
public void validate(org.apache.tools.ant.Task task) Description copied from interface:DependencyContainerValidates the container's internal structure and attributes.This method is typically invoked by Ant tasks during execution to ensure that dependency definitions are well-formed, unambiguous, and do not conflict.
- Specified by:
validatein interfaceDependencyContainer- Parameters:
task- the Ant task requesting validation, typically used for error context
-
setRefid
public void setRefid(org.apache.tools.ant.types.Reference ref) Sets the reference to another<dependencies>defined elsewhere.This allows the current element to inherit the list of dependencies from the referenced element. No other children are allowed when this reference is set.
- Overrides:
setRefidin classorg.apache.tools.ant.types.DataType- Parameters:
ref- the reference to use
-
setFile
Set the file attribute.- Parameters:
file- the File to set
-
getFile
Get the file attribute.- Returns:
- the File.
-
addPom
Allows ant to add the pom element specified in the build file. Only one pom element is allowed.- Parameters:
pom- the Pom element to add.
-
getPom
Returns thePomelement if one was added to this container.- Returns:
- the
Pomornullif none
-
setPomRef
public void setPomRef(org.apache.tools.ant.types.Reference ref) Assigns a reference to aPomelement that defines the dependencies.This is an alternative to specifying nested
<dependency>elements directly.- Parameters:
ref- the reference to aPomelement
-
addDependency
Adds a singleDependencyto this container.- Parameters:
dependency- the dependency to add
-
addDependencies
Adds anotherDependenciescontainer to this one.Allows for nesting of dependency collections. This can be useful when grouping dependencies by purpose or configuration.
- Parameters:
dependencies- anotherDependenciesobject to merge- Throws:
org.apache.tools.ant.BuildException- if attempting to add self or if usage conflicts with other sources
-
getDependencyContainers
Returns the list of containedDependencyContainerinstances. This may includeDependencyelements or nestedDependencies.- Returns:
- list of dependency containers
-
addExclusion
Adds anExclusionelement to apply to all dependencies in this container.Exclusions can be used to omit specific transitive dependencies.
- Parameters:
exclusion- the exclusion to apply
-
getExclusions
Returns the list of exclusions applied to this container.- Returns:
- list of
Exclusionobjects
-