Class DefaultModuleDescriptor
- java.lang.Object
-
- org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor
-
- All Implemented Interfaces:
DependencyDescriptorMediator
,ModuleDescriptor
,ArtifactInfo
,ExtendableItem
- Direct Known Subclasses:
PomModuleDescriptorBuilder.PomModuleDescriptor
public class DefaultModuleDescriptor extends java.lang.Object implements ModuleDescriptor
-
-
Field Summary
-
Fields inherited from interface org.apache.ivy.core.module.descriptor.ModuleDescriptor
CALLER_ALL_CONFIGURATION, DEFAULT_CONFIGURATION
-
-
Constructor Summary
Constructors Constructor Description DefaultModuleDescriptor(ModuleRevisionId id, java.lang.String status, java.util.Date pubDate)
DefaultModuleDescriptor(ModuleRevisionId id, java.lang.String status, java.util.Date pubDate, boolean isDefault)
DefaultModuleDescriptor(ModuleDescriptorParser parser, Resource res)
IMPORTANT : at least call setModuleRevisionId and setResolvedPublicationDate with instances created by this constructor !
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addArtifact(java.lang.String conf, Artifact artifact)
Artifact configurations are not used since added artifact may not be entirely completed, so its configurations data may not be accuratevoid
addConfiguration(Configuration conf)
void
addConflictManager(ModuleId moduleId, PatternMatcher matcher, ConflictManager manager)
regular expressions as explained in Pattern class may be used in ModuleId organisation and namevoid
addDependency(DependencyDescriptor dependency)
void
addDependencyDescriptorMediator(ModuleId moduleId, PatternMatcher matcher, DependencyDescriptorMediator ddm)
void
addExcludeRule(ExcludeRule rule)
void
addExtraAttributeNamespace(java.lang.String prefix, java.lang.String namespace)
void
addExtraInfo(java.lang.String infoKey, java.lang.String value)
void
addExtraInfo(ExtraInfoHolder extraInfo)
void
addInheritedDescriptor(ExtendsDescriptor descriptor)
void
addLicense(License license)
boolean
canExclude()
Returns true if this descriptor contains any exclusion rulevoid
check()
Throws an exception if the module descriptor is inconsistent For the moment, only extended configurations existence and cycles are checkedboolean
dependsOn(VersionMatcher matcher, ModuleDescriptor md)
Returns true if the module described by this descriptor dependes directly upon the given module descriptorboolean
doesExclude(java.lang.String[] moduleConfigurations, ArtifactId artifactId)
only works when namespace is properly set.boolean
equals(java.lang.Object obj)
Artifact[]
getAllArtifacts()
Returns all artifacts of this module, excluding the artifact corresponding to the module descriptor.ModuleRules
getAllDependencyDescriptorMediators()
Returns all the dependency descriptor mediators used by thisModuleDescriptor
, as an instance ofModuleRules
.ExcludeRule[]
getAllExcludeRules()
Returns an array of all the exclude rules this module descriptor currently holds.Artifact[]
getArtifacts(java.lang.String conf)
java.lang.String
getAttribute(java.lang.String attName)
Gets the value of an attribute Can be used to access the value of a standard attribute (like organisation, revision) or of an extra attribute.java.util.Map
getAttributes()
Returns a Map of all attributes of this extendable item, including standard and extra ones.Configuration
getConfiguration(java.lang.String confName)
Returns the configuration object with the given name in the current module descriptor, null if not found.Configuration[]
getConfigurations()
Returns all the configurations declared by this module as an array.java.lang.String[]
getConfigurationsNames()
ConflictManager
getConflictManager(ModuleId moduleId)
Returns the conflict manager to use for the given ModuleId, ornull
if no specific conflict manager is associated with the given module id in this module descriptor.java.lang.String
getDefaultConf()
java.lang.String
getDefaultConfMapping()
DependencyDescriptor[]
getDependencies()
java.lang.String
getDescription()
ExcludeRule[]
getExcludeRules(java.lang.String[] moduleConfigurations)
java.lang.String
getExtraAttribute(java.lang.String attName)
Gets the value of an extra attribute Can be used only to access the value of an extra attribute, not a standard one (like organisation, revision)java.util.Map
getExtraAttributes()
Returns a Map of all extra attributes of this extendable item.java.util.Map
getExtraAttributesNamespaces()
Returns the list of xml namespaces used by extra attributes, as Map from prefix to namespace URIs.java.util.Map
getExtraInfo()
Returns the custom info provided in the info tag.java.util.List<ExtraInfoHolder>
getExtraInfos()
Returns a list of extras infos (tag name, attributes and content).java.lang.String
getHomePage()
ExtendsDescriptor[]
getInheritedDescriptors()
Get the list of parent descriptors imported via an <extends> element.long
getLastModified()
License[]
getLicenses()
Returns the licenses of the module described by this descriptorArtifact
getMetadataArtifact()
Returns the Artifact representing this module descriptor itself.ModuleRevisionId
getModuleRevisionId()
Namespace
getNamespace()
ModuleDescriptorParser
getParser()
The ModuleDescriptorParser used to parse this module descriptor, null is no parser was used.java.util.Date
getPublicationDate()
May benull
if unknown in the descriptor itself.java.lang.String[]
getPublicConfigurationsNames()
java.util.Map
getQualifiedExtraAttributes()
Returns a Map of all extra attributes of this extendable item.ModuleRevisionId
getResolvedModuleRevisionId()
The module revision id returned here is the resolved one, i.e.java.util.Date
getResolvedPublicationDate()
The publication date of the module revision should be the date at which it has been published, i.e.Resource
getResource()
The resource being the source of this module descriptor, null if no resource corresponds to this module descriptorjava.lang.String
getRevision()
java.lang.String
getStatus()
int
hashCode()
boolean
isDefault()
Returns true if this descriptor is a default one, i.e.boolean
isMappingOverride()
boolean
isNamespaceUseful()
DependencyDescriptor
mediate(DependencyDescriptor dd)
Mediates the givenDependencyDescriptor
according to thisModuleDescriptor
.static DefaultModuleDescriptor
newBasicInstance(ModuleRevisionId mrid, java.util.Date publicationDate)
static DefaultModuleDescriptor
newCallerInstance(ModuleRevisionId[] mrid, boolean transitive, boolean changing)
static DefaultModuleDescriptor
newCallerInstance(ModuleRevisionId mrid, java.lang.String[] confs, boolean transitive, boolean changing)
static DefaultModuleDescriptor
newDefaultInstance(ModuleRevisionId mrid)
static DefaultModuleDescriptor
newDefaultInstance(ModuleRevisionId mrid, DependencyArtifactDescriptor[] artifacts)
void
setDefault(boolean b)
void
setDefaultConf(java.lang.String defaultConf)
void
setDefaultConfMapping(java.lang.String defaultConfMapping)
void
setDescription(java.lang.String description)
void
setHomePage(java.lang.String homePage)
void
setLastModified(long lastModified)
void
setMappingOverride(boolean override)
void
setModuleArtifact(Artifact moduleArtifact)
void
setModuleRevisionId(ModuleRevisionId revId)
void
setNamespace(Namespace ns)
void
setPublicationDate(java.util.Date publicationDate)
void
setResolvedModuleRevisionId(ModuleRevisionId revId)
This method update the resolved module revision idvoid
setResolvedPublicationDate(java.util.Date publicationDate)
This method update the resolved publication datevoid
setStatus(java.lang.String status)
void
toIvyFile(java.io.File destFile)
Writes this module descriptor as an ivy file.java.lang.String
toString()
static ModuleDescriptor
transformInstance(ModuleDescriptor md, Namespace ns)
Transforms the given module descriptor of the given namespace and return a new module descriptor in the system namespace.
-
-
-
Constructor Detail
-
DefaultModuleDescriptor
public DefaultModuleDescriptor(ModuleRevisionId id, java.lang.String status, java.util.Date pubDate)
-
DefaultModuleDescriptor
public DefaultModuleDescriptor(ModuleRevisionId id, java.lang.String status, java.util.Date pubDate, boolean isDefault)
-
DefaultModuleDescriptor
public DefaultModuleDescriptor(ModuleDescriptorParser parser, Resource res)
IMPORTANT : at least call setModuleRevisionId and setResolvedPublicationDate with instances created by this constructor !
-
-
Method Detail
-
newDefaultInstance
public static DefaultModuleDescriptor newDefaultInstance(ModuleRevisionId mrid)
-
newCallerInstance
public static DefaultModuleDescriptor newCallerInstance(ModuleRevisionId mrid, java.lang.String[] confs, boolean transitive, boolean changing)
-
newCallerInstance
public static DefaultModuleDescriptor newCallerInstance(ModuleRevisionId[] mrid, boolean transitive, boolean changing)
-
newDefaultInstance
public static DefaultModuleDescriptor newDefaultInstance(ModuleRevisionId mrid, DependencyArtifactDescriptor[] artifacts)
-
newBasicInstance
public static DefaultModuleDescriptor newBasicInstance(ModuleRevisionId mrid, java.util.Date publicationDate)
-
transformInstance
public static ModuleDescriptor transformInstance(ModuleDescriptor md, Namespace ns)
Transforms the given module descriptor of the given namespace and return a new module descriptor in the system namespace. Note that dependency exclude rules are not converted in system namespace, because they aren't transformable (the name space hasn't the ability to convert regular expressions)- Parameters:
md
-ns
-- Returns:
-
getMetadataArtifact
public Artifact getMetadataArtifact()
Description copied from interface:ModuleDescriptor
Returns the Artifact representing this module descriptor itself.Even though the module descriptor is never described as a published artifact of a module in the module descriptor itself, it is often useful to consider it as any other artifact of the module. This method allows to access to the Artifact object representing this module descriptor for this purpose.
- Specified by:
getMetadataArtifact
in interfaceModuleDescriptor
- Returns:
- the Artifact representing this module descriptor itself.
-
setModuleArtifact
public void setModuleArtifact(Artifact moduleArtifact)
-
isDefault
public boolean isDefault()
Description copied from interface:ModuleDescriptor
Returns true if this descriptor is a default one, i.e. one generated for a module not actually having one.- Specified by:
isDefault
in interfaceModuleDescriptor
- Returns:
-
setPublicationDate
public void setPublicationDate(java.util.Date publicationDate)
-
getPublicationDate
public java.util.Date getPublicationDate()
Description copied from interface:ModuleDescriptor
May benull
if unknown in the descriptor itself.- Specified by:
getPublicationDate
in interfaceModuleDescriptor
- Returns:
- The publication date or
null
when not knwon.
-
setResolvedPublicationDate
public void setResolvedPublicationDate(java.util.Date publicationDate)
Description copied from interface:ModuleDescriptor
This method update the resolved publication date- Specified by:
setResolvedPublicationDate
in interfaceModuleDescriptor
-
getResolvedPublicationDate
public java.util.Date getResolvedPublicationDate()
Description copied from interface:ModuleDescriptor
The publication date of the module revision should be the date at which it has been published, i.e. in general the date of any of its published artifacts, since all published artifact of a module should follow the same publishing cycle.- Specified by:
getResolvedPublicationDate
in interfaceModuleDescriptor
-
getRevision
public java.lang.String getRevision()
- Specified by:
getRevision
in interfaceArtifactInfo
-
setModuleRevisionId
public void setModuleRevisionId(ModuleRevisionId revId)
-
setResolvedModuleRevisionId
public void setResolvedModuleRevisionId(ModuleRevisionId revId)
Description copied from interface:ModuleDescriptor
This method update the resolved module revision id- Specified by:
setResolvedModuleRevisionId
in interfaceModuleDescriptor
-
setStatus
public void setStatus(java.lang.String status)
-
addInheritedDescriptor
public void addInheritedDescriptor(ExtendsDescriptor descriptor)
-
addDependency
public void addDependency(DependencyDescriptor dependency)
-
addConfiguration
public void addConfiguration(Configuration conf)
-
addArtifact
public void addArtifact(java.lang.String conf, Artifact artifact)
Artifact configurations are not used since added artifact may not be entirely completed, so its configurations data may not be accurate- Parameters:
conf
-artifact
-
-
getModuleRevisionId
public ModuleRevisionId getModuleRevisionId()
- Specified by:
getModuleRevisionId
in interfaceModuleDescriptor
-
getResolvedModuleRevisionId
public ModuleRevisionId getResolvedModuleRevisionId()
Description copied from interface:ModuleDescriptor
The module revision id returned here is the resolved one, i.e. it is never a latest one. If the revision has not been resolved, a null revision should be returned by getRevision() of the returned ModuleRevisionId. This revision must be the same as the module descriptor resolved revision id unless no module descriptor is defined- Specified by:
getResolvedModuleRevisionId
in interfaceModuleDescriptor
- Returns:
-
getStatus
public java.lang.String getStatus()
- Specified by:
getStatus
in interfaceModuleDescriptor
-
getInheritedDescriptors
public ExtendsDescriptor[] getInheritedDescriptors()
Description copied from interface:ModuleDescriptor
Get the list of parent descriptors imported via an <extends> element. Only directly imported descriptors are included; the parent's parents are not included.- Specified by:
getInheritedDescriptors
in interfaceModuleDescriptor
-
getConfigurations
public Configuration[] getConfigurations()
Description copied from interface:ModuleDescriptor
Returns all the configurations declared by this module as an array. This array is never empty (a 'default' conf is assumed when none is declared in the ivy file)- Specified by:
getConfigurations
in interfaceModuleDescriptor
- Returns:
- all the configurations declared by this module as an array.
-
getConfigurationsNames
public java.lang.String[] getConfigurationsNames()
- Specified by:
getConfigurationsNames
in interfaceModuleDescriptor
-
getPublicConfigurationsNames
public java.lang.String[] getPublicConfigurationsNames()
- Specified by:
getPublicConfigurationsNames
in interfaceModuleDescriptor
-
getConfiguration
public Configuration getConfiguration(java.lang.String confName)
Returns the configuration object with the given name in the current module descriptor, null if not found.- Specified by:
getConfiguration
in interfaceModuleDescriptor
- Returns:
-
getArtifacts
public Artifact[] getArtifacts(java.lang.String conf)
- Specified by:
getArtifacts
in interfaceModuleDescriptor
-
getAllArtifacts
public Artifact[] getAllArtifacts()
Description copied from interface:ModuleDescriptor
Returns all artifacts of this module, excluding the artifact corresponding to the module descriptor.- Specified by:
getAllArtifacts
in interfaceModuleDescriptor
- Returns:
- all published artifacts of this module
- See Also:
ModuleDescriptor.getMetadataArtifact()
-
getDependencies
public DependencyDescriptor[] getDependencies()
- Specified by:
getDependencies
in interfaceModuleDescriptor
-
dependsOn
public boolean dependsOn(VersionMatcher matcher, ModuleDescriptor md)
Description copied from interface:ModuleDescriptor
Returns true if the module described by this descriptor dependes directly upon the given module descriptor- Specified by:
dependsOn
in interfaceModuleDescriptor
- Returns:
-
toIvyFile
public void toIvyFile(java.io.File destFile) throws java.text.ParseException, java.io.IOException
Description copied from interface:ModuleDescriptor
Writes this module descriptor as an ivy file. If this descriptor was obtained through the parsing of an ivy file, it should keep the layout of the file the most possible similar to the original one.- Specified by:
toIvyFile
in interfaceModuleDescriptor
- Parameters:
destFile
- the destination ivy file- Throws:
java.text.ParseException
java.io.IOException
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
setDefault
public void setDefault(boolean b)
-
addConflictManager
public void addConflictManager(ModuleId moduleId, PatternMatcher matcher, ConflictManager manager)
regular expressions as explained in Pattern class may be used in ModuleId organisation and name- Parameters:
moduleId
-matcher
-resolverName
-
-
getConflictManager
public ConflictManager getConflictManager(ModuleId moduleId)
Description copied from interface:ModuleDescriptor
Returns the conflict manager to use for the given ModuleId, ornull
if no specific conflict manager is associated with the given module id in this module descriptor.- Specified by:
getConflictManager
in interfaceModuleDescriptor
- Returns:
-
addDependencyDescriptorMediator
public void addDependencyDescriptorMediator(ModuleId moduleId, PatternMatcher matcher, DependencyDescriptorMediator ddm)
-
mediate
public DependencyDescriptor mediate(DependencyDescriptor dd)
Description copied from interface:DependencyDescriptorMediator
Mediates the givenDependencyDescriptor
according to thisModuleDescriptor
.This method gives the opportunity to a ModuleDescriptor to override dependency version information of any of its transitive dependencies, since it is called by dependency resolvers before actually resolving a dependency.
- Specified by:
mediate
in interfaceDependencyDescriptorMediator
- Parameters:
dd
- the dependency descriptor which should be mediated.- Returns:
- the mediated
DependencyDescriptor
, or the originalDependencyDescriptor
if no mediation is required by this ModuleDescriptor.
-
getAllDependencyDescriptorMediators
public ModuleRules getAllDependencyDescriptorMediators()
Description copied from interface:ModuleDescriptor
Returns all the dependency descriptor mediators used by thisModuleDescriptor
, as an instance ofModuleRules
.All rules in the
ModuleRules
object returned areDependencyDescriptorMediator
.- Specified by:
getAllDependencyDescriptorMediators
in interfaceModuleDescriptor
- Returns:
- all the dependency descriptor mediators used by this
ModuleDescriptor
.
-
addLicense
public void addLicense(License license)
-
getLicenses
public License[] getLicenses()
Description copied from interface:ModuleDescriptor
Returns the licenses of the module described by this descriptor- Specified by:
getLicenses
in interfaceModuleDescriptor
- Returns:
-
getHomePage
public java.lang.String getHomePage()
- Specified by:
getHomePage
in interfaceModuleDescriptor
-
setHomePage
public void setHomePage(java.lang.String homePage)
-
getDescription
public java.lang.String getDescription()
- Specified by:
getDescription
in interfaceModuleDescriptor
-
setDescription
public void setDescription(java.lang.String description)
-
getLastModified
public long getLastModified()
- Specified by:
getLastModified
in interfaceArtifactInfo
- Specified by:
getLastModified
in interfaceModuleDescriptor
-
setLastModified
public void setLastModified(long lastModified)
-
getNamespace
public Namespace getNamespace()
-
isNamespaceUseful
public boolean isNamespaceUseful()
-
setNamespace
public void setNamespace(Namespace ns)
-
check
public void check()
Throws an exception if the module descriptor is inconsistent For the moment, only extended configurations existence and cycles are checked
-
getDefaultConf
public java.lang.String getDefaultConf()
-
setDefaultConf
public void setDefaultConf(java.lang.String defaultConf)
-
getDefaultConfMapping
public java.lang.String getDefaultConfMapping()
-
setDefaultConfMapping
public void setDefaultConfMapping(java.lang.String defaultConfMapping)
-
setMappingOverride
public void setMappingOverride(boolean override)
-
isMappingOverride
public boolean isMappingOverride()
-
getAttribute
public java.lang.String getAttribute(java.lang.String attName)
Description copied from interface:ExtendableItem
Gets the value of an attribute Can be used to access the value of a standard attribute (like organisation, revision) or of an extra attribute.- Specified by:
getAttribute
in interfaceExtendableItem
- Parameters:
attName
- the name of the attribute to get- Returns:
- the value of the attribute, null if the attribute doesn't exist
-
getAttributes
public java.util.Map getAttributes()
Description copied from interface:ExtendableItem
Returns a Map of all attributes of this extendable item, including standard and extra ones. The Map keys are attribute names as Strings, and values are corresponding attribute values (as String too). Extra attributes are included in unqualified form only.- Specified by:
getAttributes
in interfaceExtendableItem
- Returns:
- A Map instance containing all the attributes and their values.
-
getExtraAttribute
public java.lang.String getExtraAttribute(java.lang.String attName)
Description copied from interface:ExtendableItem
Gets the value of an extra attribute Can be used only to access the value of an extra attribute, not a standard one (like organisation, revision)- Specified by:
getExtraAttribute
in interfaceExtendableItem
- Parameters:
attName
- the name of the extra attribute to get. This name can be either qualified or unqualified.- Returns:
- the value of the attribute, null if the attribute doesn't exist
-
getExtraAttributes
public java.util.Map getExtraAttributes()
Description copied from interface:ExtendableItem
Returns a Map of all extra attributes of this extendable item. The Map keys are unqualified attribute names as Strings, and values are corresponding attribute values (as String too)- Specified by:
getExtraAttributes
in interfaceExtendableItem
- Returns:
- A Map instance containing all the extra attributes and their values.
- See Also:
ExtendableItem.getQualifiedExtraAttributes()
-
getQualifiedExtraAttributes
public java.util.Map getQualifiedExtraAttributes()
Description copied from interface:ExtendableItem
Returns a Map of all extra attributes of this extendable item.The Map keys are qualified attribute names as Strings, and values are corresponding attribute values (as String too).
An attribute name is qualified with a namespace exactly the same way xml attributes are qualified. Thus qualified attribute names are of the form
prefix:name
- Specified by:
getQualifiedExtraAttributes
in interfaceExtendableItem
- Returns:
- A Map instance containing all the extra attributes and their values.
- See Also:
ExtendableItem.getExtraAttributes()
-
getParser
public ModuleDescriptorParser getParser()
Description copied from interface:ModuleDescriptor
The ModuleDescriptorParser used to parse this module descriptor, null is no parser was used.- Specified by:
getParser
in interfaceModuleDescriptor
- Returns:
-
getResource
public Resource getResource()
Description copied from interface:ModuleDescriptor
The resource being the source of this module descriptor, null if no resource corresponds to this module descriptor- Specified by:
getResource
in interfaceModuleDescriptor
- Returns:
-
addExcludeRule
public void addExcludeRule(ExcludeRule rule)
-
canExclude
public boolean canExclude()
Description copied from interface:ModuleDescriptor
Returns true if this descriptor contains any exclusion rule- Specified by:
canExclude
in interfaceModuleDescriptor
- Returns:
- true if this descriptor contains any exclusion rule
-
doesExclude
public boolean doesExclude(java.lang.String[] moduleConfigurations, ArtifactId artifactId)
only works when namespace is properly set. The behaviour is not specified if namespace is not set- Specified by:
doesExclude
in interfaceModuleDescriptor
- Returns:
-
getAllExcludeRules
public ExcludeRule[] getAllExcludeRules()
Description copied from interface:ModuleDescriptor
Returns an array of all the exclude rules this module descriptor currently holds. Module Descriptor exclude rules are used to exclude (usually transitive) dependencies for the whole module.- Specified by:
getAllExcludeRules
in interfaceModuleDescriptor
- Returns:
- an array of
ExcludeRule
this module descriptor holds
-
getExcludeRules
public ExcludeRule[] getExcludeRules(java.lang.String[] moduleConfigurations)
-
getExtraAttributesNamespaces
public java.util.Map getExtraAttributesNamespaces()
Description copied from interface:ModuleDescriptor
Returns the list of xml namespaces used by extra attributes, as Map from prefix to namespace URIs.The returned list is never
null
, it is empty when no extra attribute is used or if extra attributes are used without xml namespaces- Specified by:
getExtraAttributesNamespaces
in interfaceModuleDescriptor
- Returns:
- the list of xml namespaces used by extra attributes, as Map from prefix to namespace URIs.
-
addExtraAttributeNamespace
public void addExtraAttributeNamespace(java.lang.String prefix, java.lang.String namespace)
-
addExtraInfo
public void addExtraInfo(java.lang.String infoKey, java.lang.String value)
-
getExtraInfo
public java.util.Map getExtraInfo()
Description copied from interface:ModuleDescriptor
Returns the custom info provided in the info tag. All the tags except the description are given. The key is the name of the tag, the value is its content.- Specified by:
getExtraInfo
in interfaceModuleDescriptor
- Returns:
-
getExtraInfos
public java.util.List<ExtraInfoHolder> getExtraInfos()
Description copied from interface:ModuleDescriptor
Returns a list of extras infos (tag name, attributes and content). All the tags except the description are given.- Specified by:
getExtraInfos
in interfaceModuleDescriptor
- Returns:
-
addExtraInfo
public void addExtraInfo(ExtraInfoHolder extraInfo)
-
-