Package org.apache.ivy.plugins.resolver
Class BasicResolver
- java.lang.Object
-
- org.apache.ivy.plugins.resolver.AbstractResolver
-
- org.apache.ivy.plugins.resolver.BasicResolver
-
- All Implemented Interfaces:
Validatable,DependencyResolver,HasLatestStrategy
- Direct Known Subclasses:
AbstractOSGiResolver,AbstractPatternsBasedResolver
public abstract class BasicResolver extends AbstractResolver
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classBasicResolver.UnresolvedDependencyExceptionException thrown internally in getDependency to indicate a dependency is unresolved.
-
Field Summary
Fields Modifier and Type Field Description private booleanallownomdprivate java.util.Map<Artifact,java.util.List<java.lang.String>>artattemptsprivate ArtifactResourceResolverartifactResourceResolverprivate booleancheckconsistencyprivate java.lang.Stringchecksumsstatic java.text.SimpleDateFormatDATE_FORMATDeprecated.static java.lang.StringDESCRIPTOR_OPTIONALstatic java.lang.StringDESCRIPTOR_REQUIREDprivate ResourceDownloaderdownloaderprivate booleanenvDependentTrue if the files resolved are dependent of the environment from which they have been resolved, false otherwise.private URLRepositoryextartifactrepprivate booleanforceprivate java.util.List<java.lang.String>ivyattemptsprivate java.lang.StringworkspaceName
-
Constructor Summary
Constructors Constructor Description BasicResolver()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected booleanacceptLatest()private voidcacheModuleDescriptor(ModuleDescriptor systemMd, ModuleRevisionId systemMrid, ResolvedResource ivyRef, ResolvedModuleRevision rmr)private booleancheck(Resource resource, java.io.File dest, java.lang.String algorithm)Checks the given resource checksum if a checksum resource exists.private voidcheckDescriptorConsistency(ModuleRevisionId mrid, ModuleDescriptor md, ResolvedResource ivyRef)private ResolvedModuleRevisioncheckForcedResolvedModuleRevision(ResolvedModuleRevision rmr)protected voidcheckModuleDescriptorRevision(ModuleDescriptor systemMd, ModuleRevisionId systemMrid)private voidcheckNotConvertedExclusionRule(ModuleDescriptor systemMd, ResolvedResource ivyRef, ResolveData data)private voidcheckRevision(ModuleRevisionId systemMrid)protected voidclearArtifactAttempts()protected voidclearIvyAttempts()ResolvedResourcedoFindArtifactRef(Artifact artifact, java.util.Date date)ArtifactDownloadReportdownload(ArtifactOrigin origin, DownloadOptions options)Default implementation downloads the artifact without taking advantage of its locationDownloadReportdownload(Artifact[] artifacts, DownloadOptions options)Download artifacts with specified DownloadOptions.booleanexists(Artifact artifact)Returnstrueif the given artifact can be located by this resolver and actually exist.protected java.util.Collection<java.lang.String>filterNames(java.util.Collection<java.lang.String> names)Filters names before returning them in the findXXXNames or findTokenValues method.protected abstract ResolvedResourcefindArtifactRef(Artifact artifact, java.util.Date date)protected ResolvedResourcefindFirstArtifactRef(ModuleDescriptor md, DependencyDescriptor dd, ResolveData data)protected abstract java.util.Collection<java.lang.String>findNames(java.util.Map<java.lang.String,java.lang.String> tokenValues, java.lang.String token)ResolvedResourcefindResource(ResolvedResource[] rress, ResourceMDParser rmdparser, ModuleRevisionId mrid, java.util.Date date)When the resolver has many choices, this function helps choosing oneprotected abstract longget(Resource resource, java.io.File dest)protected longgetAndCheck(Resource resource, java.io.File dest)private booleangetAndCheckIsDynamic(ModuleRevisionId systemMrid)protected ResolvedResourcegetArtifactRef(Artifact artifact, java.util.Date date)java.lang.String[]getChecksumAlgorithms()protected ResourceMDParsergetDefaultRMDParser(ModuleId mid)ResolvedModuleRevisiongetDependency(DependencyDescriptor dd, ResolveData data)Resolve a module by id, getting its module descriptor and resolving the revision if it's a latest one (i.e.protected longgetPublicationDate(ModuleDescriptor md, DependencyDescriptor dd, ResolveData data)protected abstract ResourcegetResource(java.lang.String source)private ModuleRevisionIdgetRevision(ResolvedResource ivyRef, ModuleRevisionId askedMrid, ModuleDescriptor md)protected ResourceMDParsergetRMDParser(DependencyDescriptor dd, ResolveData data)java.lang.StringgetWorkspaceName()booleanisAllownomd()booleanisCheckconsistency()booleanisEnvDependent()booleanisForce()ModuleEntry[]listModules(OrganisationEntry org)OrganisationEntry[]listOrganisations()RevisionEntry[]listRevisions(ModuleEntry mod)java.lang.String[]listTokenValues(java.lang.String token, java.util.Map<java.lang.String,java.lang.String> otherTokenValues)List all the values the given token can take if other tokens are set as described in the otherTokenValues map.ArtifactOriginlocate(Artifact artifact)Default implementation actually download the artifact Subclasses should overwrite this to avoid the downloadprotected voidlogArtifactAttempt(Artifact art, java.lang.String attempt)protected voidlogAttempt(java.lang.String attempt)protected voidlogIvyAttempt(java.lang.String attempt)ResolvedModuleRevisionparse(ResolvedResource mdRef, DependencyDescriptor dd, ResolveData data)voidreportFailure()Reports last resolve failure as MessagesvoidreportFailure(Artifact art)Reports last artifact download failure as Messagesprivate voidresolveAndCheckPublicationDate(DependencyDescriptor systemDd, ModuleDescriptor systemMd, ModuleRevisionId systemMrid, ResolveData data)private voidresolveAndCheckRevision(ModuleDescriptor systemMd, ModuleRevisionId dependencyConstraint, ResolvedResource ivyRef, boolean isDynamic)voidsetAllownomd(boolean b)voidsetCheckconsistency(boolean checkConsistency)voidsetChecksums(java.lang.String checksums)voidsetDescriptor(java.lang.String descriptorRule)Sets the module descriptor presence rule.voidsetEnvDependent(boolean envDependent)voidsetForce(boolean force)voidsetWorkspaceName(java.lang.String workspaceName)protected booleanshouldReturnResolvedModule(DependencyDescriptor dd, ResolvedModuleRevision mr)java.lang.StringtoString()-
Methods inherited from class org.apache.ivy.plugins.resolver.AbstractResolver
abortPublishTransaction, beginPublishTransaction, checkInterrupted, checkLatest, commitPublishTransaction, doValidate, dumpSettings, findModuleInCache, findModuleInCache, fromSystem, fromSystem, getCacheDownloadOptions, getCacheOptions, getChangingMatcherName, getChangingPattern, getDownloadOptions, getEventManager, getLatest, getLatestStrategy, getName, getNamespace, getParserSettings, getRepositoryCacheManager, getSettings, getSystemNode, getTimeoutConstraint, getTypeName, hidePassword, isAfter, isValidate, listTokenValues, saveModuleRevisionIfNeeded, setCache, setChangingMatcher, setChangingPattern, setCheckmodified, setEventManager, setLatest, setLatestStrategy, setName, setNamespace, setRepositoryCacheManager, setSettings, setTimeoutConstraint, setValidate, toSystem, toSystem, toSystem, toSystem, toSystem, toSystem, validate
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.ivy.plugins.resolver.DependencyResolver
findIvyFileRef, publish
-
-
-
-
Field Detail
-
DESCRIPTOR_OPTIONAL
public static final java.lang.String DESCRIPTOR_OPTIONAL
- See Also:
- Constant Field Values
-
DESCRIPTOR_REQUIRED
public static final java.lang.String DESCRIPTOR_REQUIRED
- See Also:
- Constant Field Values
-
DATE_FORMAT
@Deprecated public static final java.text.SimpleDateFormat DATE_FORMAT
Deprecated.
-
workspaceName
private java.lang.String workspaceName
-
envDependent
private boolean envDependent
True if the files resolved are dependent of the environment from which they have been resolved, false otherwise. In general, relative paths are dependent of the environment, and absolute paths including machine reference are not.
-
ivyattempts
private java.util.List<java.lang.String> ivyattempts
-
artattempts
private java.util.Map<Artifact,java.util.List<java.lang.String>> artattempts
-
checkconsistency
private boolean checkconsistency
-
allownomd
private boolean allownomd
-
force
private boolean force
-
checksums
private java.lang.String checksums
-
extartifactrep
private URLRepository extartifactrep
-
artifactResourceResolver
private final ArtifactResourceResolver artifactResourceResolver
-
downloader
private final ResourceDownloader downloader
-
-
Method Detail
-
getWorkspaceName
public java.lang.String getWorkspaceName()
-
setWorkspaceName
public void setWorkspaceName(java.lang.String workspaceName)
-
isEnvDependent
public boolean isEnvDependent()
-
setEnvDependent
public void setEnvDependent(boolean envDependent)
-
getDependency
public ResolvedModuleRevision getDependency(DependencyDescriptor dd, ResolveData data) throws java.text.ParseException
Description copied from interface:DependencyResolverResolve a module by id, getting its module descriptor and resolving the revision if it's a latest one (i.e. a revision uniquely identifying the revision of a module in the current environment - If this revision is not able to identify uniquely the revision of the module outside of the current environment, then the resolved revision must begin by ##)- Parameters:
dd- DependencyDescriptordata- ResolveData- Returns:
- ResolvedModuleRevision
- Throws:
java.text.ParseException- if something goes wrong
-
shouldReturnResolvedModule
protected boolean shouldReturnResolvedModule(DependencyDescriptor dd, ResolvedModuleRevision mr)
-
checkForcedResolvedModuleRevision
private ResolvedModuleRevision checkForcedResolvedModuleRevision(ResolvedModuleRevision rmr)
-
cacheModuleDescriptor
private void cacheModuleDescriptor(ModuleDescriptor systemMd, ModuleRevisionId systemMrid, ResolvedResource ivyRef, ResolvedModuleRevision rmr)
-
checkNotConvertedExclusionRule
private void checkNotConvertedExclusionRule(ModuleDescriptor systemMd, ResolvedResource ivyRef, ResolveData data)
-
resolveAndCheckPublicationDate
private void resolveAndCheckPublicationDate(DependencyDescriptor systemDd, ModuleDescriptor systemMd, ModuleRevisionId systemMrid, ResolveData data)
-
checkModuleDescriptorRevision
protected void checkModuleDescriptorRevision(ModuleDescriptor systemMd, ModuleRevisionId systemMrid)
-
getAndCheckIsDynamic
private boolean getAndCheckIsDynamic(ModuleRevisionId systemMrid)
-
checkRevision
private void checkRevision(ModuleRevisionId systemMrid)
-
resolveAndCheckRevision
private void resolveAndCheckRevision(ModuleDescriptor systemMd, ModuleRevisionId dependencyConstraint, ResolvedResource ivyRef, boolean isDynamic)
-
getRevision
private ModuleRevisionId getRevision(ResolvedResource ivyRef, ModuleRevisionId askedMrid, ModuleDescriptor md)
-
parse
public ResolvedModuleRevision parse(ResolvedResource mdRef, DependencyDescriptor dd, ResolveData data) throws java.text.ParseException
- Throws:
java.text.ParseException
-
getRMDParser
protected ResourceMDParser getRMDParser(DependencyDescriptor dd, ResolveData data)
-
getDefaultRMDParser
protected ResourceMDParser getDefaultRMDParser(ModuleId mid)
-
checkDescriptorConsistency
private void checkDescriptorConsistency(ModuleRevisionId mrid, ModuleDescriptor md, ResolvedResource ivyRef) throws java.text.ParseException
- Throws:
java.text.ParseException
-
findResource
public ResolvedResource findResource(ResolvedResource[] rress, ResourceMDParser rmdparser, ModuleRevisionId mrid, java.util.Date date)
When the resolver has many choices, this function helps choosing one- Parameters:
rress- the list of resolved resource which the resolver found to fit the requirementrmdparser- the parser of module descriptormrid- the module being resolveddate- the current date- Returns:
- the selected resource
-
filterNames
protected java.util.Collection<java.lang.String> filterNames(java.util.Collection<java.lang.String> names)
Filters names before returning them in the findXXXNames or findTokenValues method.Remember to call the super implementation when overriding this method.
- Parameters:
names- the list to filter.- Returns:
- the filtered list
-
clearIvyAttempts
protected void clearIvyAttempts()
-
logIvyAttempt
protected void logIvyAttempt(java.lang.String attempt)
-
logArtifactAttempt
protected void logArtifactAttempt(Artifact art, java.lang.String attempt)
-
logAttempt
protected void logAttempt(java.lang.String attempt)
-
reportFailure
public void reportFailure()
Description copied from interface:DependencyResolverReports last resolve failure as Messages- Specified by:
reportFailurein interfaceDependencyResolver- Overrides:
reportFailurein classAbstractResolver
-
reportFailure
public void reportFailure(Artifact art)
Description copied from interface:DependencyResolverReports last artifact download failure as Messages- Specified by:
reportFailurein interfaceDependencyResolver- Overrides:
reportFailurein classAbstractResolver- Parameters:
art- Artifact
-
acceptLatest
protected boolean acceptLatest()
-
download
public DownloadReport download(Artifact[] artifacts, DownloadOptions options)
Description copied from interface:DependencyResolverDownload artifacts with specified DownloadOptions.The resolver will always make a best effort, and do not stop when an artifact is not available. It rather continue to attempt to download other requested artifacts, and report what has been done in the returned DownloadReport.
The returned DownloadReport is never
null, and always contain anArtifactDownloadReportfor each requested Artifact.- Parameters:
artifacts- an array of artifacts to download. Must not benull.options- options to apply for this download. Must not benull.- Returns:
- a DownloadReport with details about each Artifact download.
-
clearArtifactAttempts
protected void clearArtifactAttempts()
-
download
public ArtifactDownloadReport download(ArtifactOrigin origin, DownloadOptions options)
Description copied from class:AbstractResolverDefault implementation downloads the artifact without taking advantage of its location- Specified by:
downloadin interfaceDependencyResolver- Overrides:
downloadin classAbstractResolver- Parameters:
origin- ArtifactOriginoptions- DownloadOptions- Returns:
- ArtifactDownloadReport
-
getResource
protected abstract Resource getResource(java.lang.String source) throws java.io.IOException
- Throws:
java.io.IOException
-
exists
public boolean exists(Artifact artifact)
Description copied from interface:DependencyResolverReturnstrueif the given artifact can be located by this resolver and actually exist.- Specified by:
existsin interfaceDependencyResolver- Overrides:
existsin classAbstractResolver- Parameters:
artifact- the artifact which should be tested.- Returns:
trueif the given artifact can be located by this resolver and actually exist.
-
locate
public ArtifactOrigin locate(Artifact artifact)
Description copied from class:AbstractResolverDefault implementation actually download the artifact Subclasses should overwrite this to avoid the download- Specified by:
locatein interfaceDependencyResolver- Overrides:
locatein classAbstractResolver- Parameters:
artifact- ArtifactOrigin- Returns:
- ArtifactOrigin
-
getPublicationDate
protected long getPublicationDate(ModuleDescriptor md, DependencyDescriptor dd, ResolveData data)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classAbstractResolver
-
listTokenValues
public java.lang.String[] listTokenValues(java.lang.String token, java.util.Map<java.lang.String,java.lang.String> otherTokenValues)Description copied from interface:DependencyResolverList all the values the given token can take if other tokens are set as described in the otherTokenValues map. For instance, if token = "revision" and the map contains "organisation"->"foo" "module"->"bar" The results will be the list of revisions of the module bar from the org foo.Note that listing does not take into account namespaces, and return raw information without any namespace transformation. The caller is responsible for calling namespace transformation with the Namespace returned by
DependencyResolver.getNamespace().- Specified by:
listTokenValuesin interfaceDependencyResolver- Overrides:
listTokenValuesin classAbstractResolver- Parameters:
token- StringotherTokenValues- Map- Returns:
- String[]
-
listOrganisations
public OrganisationEntry[] listOrganisations()
- Specified by:
listOrganisationsin interfaceDependencyResolver- Overrides:
listOrganisationsin classAbstractResolver
-
listModules
public ModuleEntry[] listModules(OrganisationEntry org)
- Specified by:
listModulesin interfaceDependencyResolver- Overrides:
listModulesin classAbstractResolver
-
listRevisions
public RevisionEntry[] listRevisions(ModuleEntry mod)
- Specified by:
listRevisionsin interfaceDependencyResolver- Overrides:
listRevisionsin classAbstractResolver
-
findNames
protected abstract java.util.Collection<java.lang.String> findNames(java.util.Map<java.lang.String,java.lang.String> tokenValues, java.lang.String token)
-
findFirstArtifactRef
protected ResolvedResource findFirstArtifactRef(ModuleDescriptor md, DependencyDescriptor dd, ResolveData data)
-
getAndCheck
protected long getAndCheck(Resource resource, java.io.File dest) throws java.io.IOException
- Throws:
java.io.IOException
-
check
private boolean check(Resource resource, java.io.File dest, java.lang.String algorithm) throws java.io.IOException
Checks the given resource checksum if a checksum resource exists.- Parameters:
resource- the resource to checkdest- the file where the resource has been downloadedalgorithm- the checksum algorithm to use- Returns:
- true if the checksum has been successfully checked, false if the checksum wasn't available
- Throws:
java.io.IOException- if a checksum exist but do not match the downloaded file checksum
-
getArtifactRef
protected ResolvedResource getArtifactRef(Artifact artifact, java.util.Date date)
-
doFindArtifactRef
public ResolvedResource doFindArtifactRef(Artifact artifact, java.util.Date date)
-
findArtifactRef
protected abstract ResolvedResource findArtifactRef(Artifact artifact, java.util.Date date)
-
get
protected abstract long get(Resource resource, java.io.File dest) throws java.io.IOException
- Throws:
java.io.IOException
-
isCheckconsistency
public boolean isCheckconsistency()
-
setCheckconsistency
public void setCheckconsistency(boolean checkConsistency)
-
setForce
public void setForce(boolean force)
-
isForce
public boolean isForce()
-
isAllownomd
public boolean isAllownomd()
-
setAllownomd
public void setAllownomd(boolean b)
-
setDescriptor
public void setDescriptor(java.lang.String descriptorRule)
Sets the module descriptor presence rule. Should be one ofDESCRIPTOR_REQUIREDorDESCRIPTOR_OPTIONAL.- Parameters:
descriptorRule- the descriptor rule to use with this resolver.
-
getChecksumAlgorithms
public java.lang.String[] getChecksumAlgorithms()
-
setChecksums
public void setChecksums(java.lang.String checksums)
-
-