Search in sources :

Example 6 with ModuleDescriptorParser

use of org.apache.ivy.plugins.parser.ModuleDescriptorParser in project ant-ivy by apache.

the class BasicResolver method parse.

public ResolvedModuleRevision parse(final ResolvedResource mdRef, DependencyDescriptor dd, ResolveData data) throws ParseException {
    DependencyDescriptor nsDd = dd;
    dd = toSystem(nsDd);
    ModuleRevisionId mrid = dd.getDependencyRevisionId();
    ModuleDescriptorParser parser = ModuleDescriptorParserRegistry.getInstance().getParser(mdRef.getResource());
    if (parser == null) {
        Message.warn("no module descriptor parser available for " + mdRef.getResource());
        return null;
    }
    Message.verbose("\t" + getName() + ": found md file for " + mrid);
    Message.verbose("\t\t=> " + mdRef);
    Message.debug("\tparser = " + parser);
    ModuleRevisionId resolvedMrid = mrid;
    // first check if this dependency has not yet been resolved
    if (getSettings().getVersionMatcher().isDynamic(mrid)) {
        resolvedMrid = ModuleRevisionId.newInstance(mrid, mdRef.getRevision());
        IvyNode node = data.getNode(resolvedMrid);
        if (node != null && node.getModuleRevision() != null) {
            // this revision has already be resolved : return it
            if (node.getDescriptor() == null || !node.getDescriptor().isDefault()) {
                Message.verbose("\t" + getName() + ": revision already resolved: " + resolvedMrid);
                node.getModuleRevision().getReport().setSearched(true);
                return node.getModuleRevision();
            }
            Message.verbose("\t" + getName() + ": found already resolved revision: " + resolvedMrid + ": but it's a default one, maybe we can find a better one");
        }
    }
    Artifact moduleArtifact = parser.getMetadataArtifact(resolvedMrid, mdRef.getResource());
    return getRepositoryCacheManager().cacheModuleDescriptor(this, mdRef, dd, moduleArtifact, downloader, getCacheOptions(data));
}
Also used : DependencyDescriptor(org.apache.ivy.core.module.descriptor.DependencyDescriptor) ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) ModuleDescriptorParser(org.apache.ivy.plugins.parser.ModuleDescriptorParser) IvyNode(org.apache.ivy.core.resolve.IvyNode) Artifact(org.apache.ivy.core.module.descriptor.Artifact)

Aggregations

ModuleDescriptorParser (org.apache.ivy.plugins.parser.ModuleDescriptorParser)6 ModuleDescriptor (org.apache.ivy.core.module.descriptor.ModuleDescriptor)5 File (java.io.File)4 IOException (java.io.IOException)4 ParseException (java.text.ParseException)3 Artifact (org.apache.ivy.core.module.descriptor.Artifact)3 DefaultModuleDescriptor (org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor)2 ModuleRevisionId (org.apache.ivy.core.module.id.ModuleRevisionId)2 MetadataArtifactDownloadReport (org.apache.ivy.core.report.MetadataArtifactDownloadReport)2 ResolvedModuleRevision (org.apache.ivy.core.resolve.ResolvedModuleRevision)2 XmlModuleDescriptorParser (org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorParser)2 ResolvedResource (org.apache.ivy.plugins.resolver.util.ResolvedResource)2 PropertiesFile (org.apache.ivy.util.PropertiesFile)2 FileInputStream (java.io.FileInputStream)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 MalformedURLException (java.net.MalformedURLException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 Date (java.util.Date)1 ModuleDescriptorWriter (org.apache.ivy.core.cache.ModuleDescriptorWriter)1 RepositoryCacheManager (org.apache.ivy.core.cache.RepositoryCacheManager)1