Class DefaultModuleDescriptor
- java.lang.Object
-
- org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor
-
- All Implemented Interfaces:
DependencyDescriptorMediator,ModuleDescriptor,ArtifactInfo,ExtendableItem
- Direct Known Subclasses:
DefaultWorkspaceModuleDescriptor,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 Deprecated Methods Modifier and Type Method Description voidaddArtifact(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 accuratevoidaddConfiguration(Configuration conf)voidaddConflictManager(ModuleId moduleId, PatternMatcher matcher, ConflictManager manager)regular expressions as explained in Pattern class may be used in ModuleId organisation and namevoidaddDependency(DependencyDescriptor dependency)voidaddDependencyDescriptorMediator(ModuleId moduleId, PatternMatcher matcher, DependencyDescriptorMediator ddm)voidaddExcludeRule(ExcludeRule rule)voidaddExtraAttributeNamespace(java.lang.String prefix, java.lang.String namespace)voidaddExtraInfo(java.lang.String infoKey, java.lang.String value)Deprecated.voidaddExtraInfo(ExtraInfoHolder extraInfo)voidaddInheritedDescriptor(ExtendsDescriptor descriptor)voidaddLicense(License license)booleancanExclude()voidcheck()Throws an exception if the module descriptor is inconsistent.booleandependsOn(VersionMatcher matcher, ModuleDescriptor md)booleandoesExclude(java.lang.String[] moduleConfigurations, ArtifactId artifactId)Only works when namespace is properly set.booleanequals(java.lang.Object obj)Artifact[]getAllArtifacts()ModuleRules<DependencyDescriptorMediator>getAllDependencyDescriptorMediators()ExcludeRule[]getAllExcludeRules()Module Descriptor exclude rules are used to exclude (usually transitive) dependencies for the whole module.Artifact[]getArtifacts(java.lang.String conf)java.lang.StringgetAttribute(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<java.lang.String,java.lang.String>getAttributes()Returns a Map of all attributes of this extendable item, including standard and extra ones.ConfigurationgetConfiguration(java.lang.String confName)Configuration[]getConfigurations()java.lang.String[]getConfigurationsNames()ConflictManagergetConflictManager(ModuleId moduleId)java.lang.StringgetDefaultConf()java.lang.StringgetDefaultConfMapping()DependencyDescriptor[]getDependencies()java.lang.StringgetDescription()ExcludeRule[]getExcludeRules(java.lang.String[] moduleConfigurations)java.lang.StringgetExtraAttribute(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<java.lang.String,java.lang.String>getExtraAttributes()Returns a Map of all extra attributes of this extendable item.java.util.Map<java.lang.String,java.lang.String>getExtraAttributesNamespaces()java.util.Map<java.lang.String,java.lang.String>getExtraInfo()Deprecated.ExtraInfoHoldergetExtraInfoByTagName(java.lang.String tagName)java.lang.StringgetExtraInfoContentByTagName(java.lang.String tagName)java.util.List<ExtraInfoHolder>getExtraInfos()java.lang.StringgetHomePage()ExtendsDescriptor[]getInheritedDescriptors()longgetLastModified()License[]getLicenses()ArtifactgetMetadataArtifact()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.ModuleRevisionIdgetModuleRevisionId()NamespacegetNamespace()ModuleDescriptorParsergetParser()java.util.DategetPublicationDate()java.lang.String[]getPublicConfigurationsNames()java.util.Map<java.lang.String,java.lang.String>getQualifiedExtraAttributes()Returns a Map of all extra attributes of this extendable item.ModuleRevisionIdgetResolvedModuleRevisionId()java.util.DategetResolvedPublicationDate()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.ResourcegetResource()java.lang.StringgetRevision()java.lang.StringgetStatus()inthashCode()booleanisDefault()booleanisMappingOverride()booleanisNamespaceUseful()DependencyDescriptormediate(DependencyDescriptor dd)Mediates the givenDependencyDescriptoraccording to thisModuleDescriptor.static DefaultModuleDescriptornewBasicInstance(ModuleRevisionId mrid, java.util.Date publicationDate)static DefaultModuleDescriptornewCallerInstance(ModuleRevisionId[] mrids, boolean transitive, boolean changing)static DefaultModuleDescriptornewCallerInstance(ModuleRevisionId mrid, java.lang.String[] confs, boolean transitive, boolean changing)static DefaultModuleDescriptornewDefaultInstance(ModuleRevisionId mrid)static DefaultModuleDescriptornewDefaultInstance(ModuleRevisionId mrid, DependencyArtifactDescriptor[] artifacts)voidsetDefault(boolean b)voidsetDefaultConf(java.lang.String defaultConf)voidsetDefaultConfMapping(java.lang.String defaultConfMapping)voidsetDescription(java.lang.String description)voidsetHomePage(java.lang.String homePage)voidsetLastModified(long lastModified)voidsetMappingOverride(boolean override)voidsetModuleArtifact(Artifact moduleArtifact)voidsetModuleRevisionId(ModuleRevisionId revId)voidsetNamespace(Namespace ns)voidsetPublicationDate(java.util.Date publicationDate)voidsetResolvedModuleRevisionId(ModuleRevisionId revId)This method updates the resolved module revision idvoidsetResolvedPublicationDate(java.util.Date publicationDate)This method update the resolved publication datevoidsetStatus(java.lang.String status)voidtoIvyFile(java.io.File destFile)Writes this module descriptor as an ivy file.java.lang.StringtoString()static ModuleDescriptortransformInstance(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 !- Parameters:
parser- ModuleDescriptorParserres- Resource
-
-
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[] mrids, 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 namespace lacks the ability to convert regular expressions)- Parameters:
md- ModuleDescriptorns- Namespace- Returns:
- ModuleDescriptor
-
getMetadataArtifact
public Artifact getMetadataArtifact()
Description copied from interface:ModuleDescriptorEven 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:
getMetadataArtifactin interfaceModuleDescriptor- Returns:
- the Artifact representing this module descriptor itself.
-
setModuleArtifact
public void setModuleArtifact(Artifact moduleArtifact)
-
isDefault
public boolean isDefault()
- Specified by:
isDefaultin interfaceModuleDescriptor- Returns:
- true if this descriptor is a default one, i.e. one generated for a module not actually having one.
-
setPublicationDate
public void setPublicationDate(java.util.Date publicationDate)
-
getPublicationDate
public java.util.Date getPublicationDate()
- Specified by:
getPublicationDatein interfaceModuleDescriptor- Returns:
- the publication date or null when not known in the descriptor itself.
-
setResolvedPublicationDate
public void setResolvedPublicationDate(java.util.Date publicationDate)
Description copied from interface:ModuleDescriptorThis method update the resolved publication date- Specified by:
setResolvedPublicationDatein interfaceModuleDescriptor- Parameters:
publicationDate- Date
-
getResolvedPublicationDate
public java.util.Date getResolvedPublicationDate()
Description copied from interface:ModuleDescriptorThe 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:
getResolvedPublicationDatein interfaceModuleDescriptor- Returns:
- Date
-
getRevision
public java.lang.String getRevision()
- Specified by:
getRevisionin interfaceArtifactInfo
-
setModuleRevisionId
public void setModuleRevisionId(ModuleRevisionId revId)
-
setResolvedModuleRevisionId
public void setResolvedModuleRevisionId(ModuleRevisionId revId)
Description copied from interface:ModuleDescriptorThis method updates the resolved module revision id- Specified by:
setResolvedModuleRevisionIdin interfaceModuleDescriptor- Parameters:
revId- ModuleRevisionId
-
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- dittoartifact- ditto
-
getModuleRevisionId
public ModuleRevisionId getModuleRevisionId()
- Specified by:
getModuleRevisionIdin interfaceModuleDescriptor
-
getResolvedModuleRevisionId
public ModuleRevisionId getResolvedModuleRevisionId()
- Specified by:
getResolvedModuleRevisionIdin interfaceModuleDescriptor- Returns:
- the resolved module revision id; it is never the 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
-
getStatus
public java.lang.String getStatus()
- Specified by:
getStatusin interfaceModuleDescriptor
-
getInheritedDescriptors
public ExtendsDescriptor[] getInheritedDescriptors()
- Specified by:
getInheritedDescriptorsin interfaceModuleDescriptor- Returns:
- the list of parent descriptors imported via an <extends> element. Only directly imported descriptors are included; the parent's parents are not included.
-
getConfigurations
public Configuration[] getConfigurations()
- Specified by:
getConfigurationsin interfaceModuleDescriptor- 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).
-
getConfigurationsNames
public java.lang.String[] getConfigurationsNames()
- Specified by:
getConfigurationsNamesin interfaceModuleDescriptor
-
getPublicConfigurationsNames
public java.lang.String[] getPublicConfigurationsNames()
- Specified by:
getPublicConfigurationsNamesin interfaceModuleDescriptor
-
getConfiguration
public Configuration getConfiguration(java.lang.String confName)
- Specified by:
getConfigurationin interfaceModuleDescriptor- Parameters:
confName- String- Returns:
- the configuration object with the given name in the current module descriptor, null if not found.
-
getArtifacts
public Artifact[] getArtifacts(java.lang.String conf)
- Specified by:
getArtifactsin interfaceModuleDescriptor
-
getAllArtifacts
public Artifact[] getAllArtifacts()
- Specified by:
getAllArtifactsin interfaceModuleDescriptor- Returns:
- all published artifacts of this module, excluding the artifact corresponding to the module descriptor.
- See Also:
ModuleDescriptor.getMetadataArtifact()
-
getDependencies
public DependencyDescriptor[] getDependencies()
- Specified by:
getDependenciesin interfaceModuleDescriptor- Returns:
- The dependencies of the module. If there are no dependencies return an empty array (non null)
-
dependsOn
public boolean dependsOn(VersionMatcher matcher, ModuleDescriptor md)
- Specified by:
dependsOnin interfaceModuleDescriptor- Parameters:
matcher- VersionMatchermd- ModuleDescriptor- Returns:
- true if the module described by this descriptor depends directly upon the given module descriptor
-
toIvyFile
public void toIvyFile(java.io.File destFile) throws java.text.ParseException, java.io.IOExceptionDescription copied from interface:ModuleDescriptorWrites 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:
toIvyFilein interfaceModuleDescriptor- Parameters:
destFile- the destination ivy file- Throws:
java.text.ParseException- if something goes wrongjava.io.IOException- if something goes wrong
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin 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- dittomatcher- PatternMatchermanager- ConflictManager
-
getConflictManager
public ConflictManager getConflictManager(ModuleId moduleId)
- Specified by:
getConflictManagerin interfaceModuleDescriptor- Parameters:
moduleId- ModuleId- Returns:
- the conflict manager to use for the given ModuleId, or null if no specific conflict manager is associated with the given module id in this module descriptor.
-
addDependencyDescriptorMediator
public void addDependencyDescriptorMediator(ModuleId moduleId, PatternMatcher matcher, DependencyDescriptorMediator ddm)
-
mediate
public DependencyDescriptor mediate(DependencyDescriptor dd)
Description copied from interface:DependencyDescriptorMediatorMediates the givenDependencyDescriptoraccording 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:
mediatein interfaceDependencyDescriptorMediator- Parameters:
dd- the dependency descriptor which should be mediated.- Returns:
- the mediated
DependencyDescriptor, or the originalDependencyDescriptorif no mediation is required by this ModuleDescriptor.
-
getAllDependencyDescriptorMediators
public ModuleRules<DependencyDescriptorMediator> getAllDependencyDescriptorMediators()
- Specified by:
getAllDependencyDescriptorMediatorsin interfaceModuleDescriptor- Returns:
- all the
DependencyDescriptorMediators used by thisModuleDescriptor, as an instance ofModuleRules.
-
addLicense
public void addLicense(License license)
-
getLicenses
public License[] getLicenses()
- Specified by:
getLicensesin interfaceModuleDescriptor- Returns:
- the licenses of the module described by this descriptor
-
getHomePage
public java.lang.String getHomePage()
- Specified by:
getHomePagein interfaceModuleDescriptor
-
setHomePage
public void setHomePage(java.lang.String homePage)
-
getDescription
public java.lang.String getDescription()
- Specified by:
getDescriptionin interfaceModuleDescriptor
-
setDescription
public void setDescription(java.lang.String description)
-
getLastModified
public long getLastModified()
- Specified by:
getLastModifiedin interfaceArtifactInfo- Specified by:
getLastModifiedin 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:ExtendableItemGets 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:
getAttributein 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<java.lang.String,java.lang.String> getAttributes()
Description copied from interface:ExtendableItemReturns 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:
getAttributesin 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:ExtendableItemGets 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:
getExtraAttributein 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<java.lang.String,java.lang.String> getExtraAttributes()
Description copied from interface:ExtendableItemReturns 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:
getExtraAttributesin interfaceExtendableItem- Returns:
- A Map instance containing all the extra attributes and their values.
- See Also:
ExtendableItem.getQualifiedExtraAttributes()
-
getQualifiedExtraAttributes
public java.util.Map<java.lang.String,java.lang.String> getQualifiedExtraAttributes()
Description copied from interface:ExtendableItemReturns 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:
getQualifiedExtraAttributesin interfaceExtendableItem- Returns:
- A Map instance containing all the extra attributes and their values.
- See Also:
ExtendableItem.getExtraAttributes()
-
getParser
public ModuleDescriptorParser getParser()
- Specified by:
getParserin interfaceModuleDescriptor- Returns:
- the ModuleDescriptorParser used to parse this module descriptor, null is no parser was used.
-
getResource
public Resource getResource()
- Specified by:
getResourcein interfaceModuleDescriptor- Returns:
- the resource being the source of this module descriptor, null if no resource corresponds to this module descriptor.
-
addExcludeRule
public void addExcludeRule(ExcludeRule rule)
-
canExclude
public boolean canExclude()
- Specified by:
canExcludein 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:
doesExcludein interfaceModuleDescriptor- Parameters:
moduleConfigurations- String[]artifactId- ditto- Returns:
- boolean
-
getAllExcludeRules
public ExcludeRule[] getAllExcludeRules()
Description copied from interface:ModuleDescriptorModule Descriptor exclude rules are used to exclude (usually transitive) dependencies for the whole module.- Specified by:
getAllExcludeRulesin interfaceModuleDescriptor- Returns:
- an array of all
ExcludeRulethis module descriptor currently holds.
-
getExcludeRules
public ExcludeRule[] getExcludeRules(java.lang.String[] moduleConfigurations)
-
getExtraAttributesNamespaces
public java.util.Map<java.lang.String,java.lang.String> getExtraAttributesNamespaces()
- Specified by:
getExtraAttributesNamespacesin interfaceModuleDescriptor- 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
-
addExtraAttributeNamespace
public void addExtraAttributeNamespace(java.lang.String prefix, java.lang.String namespace)
-
addExtraInfo
@Deprecated public void addExtraInfo(java.lang.String infoKey, java.lang.String value)Deprecated.
-
getExtraInfo
@Deprecated public java.util.Map<java.lang.String,java.lang.String> getExtraInfo()
Deprecated.- Specified by:
getExtraInfoin interfaceModuleDescriptor- 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.
-
getExtraInfos
public java.util.List<ExtraInfoHolder> getExtraInfos()
- Specified by:
getExtraInfosin interfaceModuleDescriptor- Returns:
- a list of extras infos (tag name, attributes and content). All the tags except the description are given.
-
addExtraInfo
public void addExtraInfo(ExtraInfoHolder extraInfo)
-
getExtraInfoContentByTagName
public java.lang.String getExtraInfoContentByTagName(java.lang.String tagName)
- Specified by:
getExtraInfoContentByTagNamein interfaceModuleDescriptor- Parameters:
tagName- String- Returns:
- content from first extrainfo matching with given tag name.
-
getExtraInfoByTagName
public ExtraInfoHolder getExtraInfoByTagName(java.lang.String tagName)
- Specified by:
getExtraInfoByTagNamein interfaceModuleDescriptor- Parameters:
tagName- String- Returns:
- first extrainfo matching with given tag name.
-
-