Examples of ModuleDescriptorParser


Examples of org.apache.ivy.plugins.parser.ModuleDescriptorParser

    private void cacheModuleDescriptor(ModuleDescriptor systemMd, ModuleRevisionId systemMrid,
            ResolvedResource ivyRef, ResolvedModuleRevision rmr) {
        RepositoryCacheManager cacheManager = getRepositoryCacheManager();
       
        final ModuleDescriptorParser parser = systemMd.getParser();
       
        // the metadata artifact which was used to cache the original metadata file
        Artifact requestedMetadataArtifact =
            ivyRef == null
            ? systemMd.getMetadataArtifact()
            : parser.getMetadataArtifact(
                ModuleRevisionId.newInstance(systemMrid, ivyRef.getRevision()),
                ivyRef.getResource());
       
        cacheManager.originalToCachedModuleDescriptor(this, ivyRef, requestedMetadataArtifact,
                rmr, new ModuleDescriptorWriter() {
            public void write(ResolvedResource originalMdResource, ModuleDescriptor md,
                    File src, File dest)
                    throws IOException, ParseException {
                if (originalMdResource == null) {
                    // a basic ivy file is written containing default data
                    XmlModuleDescriptorWriter.write(md, dest);
                } else {
                    // copy and update ivy file from source to cache
                    parser.toIvyFile(
                        new FileInputStream(src),
                        originalMdResource.getResource(), dest,
                        md);
                    long repLastModified = originalMdResource.getLastModified();
                    if (repLastModified > 0) {
View Full Code Here

Examples of org.apache.ivy.plugins.parser.ModuleDescriptorParser

        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() + ": found already resolved revision: "
                            + resolvedMrid
                            + ": but it's a default one, maybe we can find a better one");
                } else {
                    Message.verbose("\t" + getName() + ": revision already resolved: "
                            + resolvedMrid);
                    node.getModuleRevision().getReport().setSearched(true);
                    return node.getModuleRevision();
                }
            }
        }

        Artifact moduleArtifact = parser.getMetadataArtifact(resolvedMrid, mdRef.getResource());
        return getRepositoryCacheManager().cacheModuleDescriptor(
            this, mdRef, dd, moduleArtifact, downloader,
            getCacheOptions(data));
    }
View Full Code Here

Examples of org.apache.ivy.plugins.parser.ModuleDescriptorParser

           
            ResolvedResource ivyRef = findIvyFileRef(nsDd, data);
            checkInterrupted();

            // get module descriptor
            final ModuleDescriptorParser parser;
            ModuleDescriptor nsMd;
            ModuleDescriptor systemMd = null;
            if (ivyRef == null) {
                if (!isAllownomd()) {
                    Message.verbose("\t" + getName() + ": no ivy file found for " + systemMrid);
                    return null;
                }
                parser = XmlModuleDescriptorParser.getInstance();
                nsMd = DefaultModuleDescriptor.newDefaultInstance(nsMrid, nsDd
                    .getAllDependencyArtifacts());
                ResolvedResource artifactRef = findFirstArtifactRef(nsMd, nsDd, data);
                checkInterrupted();
                if (artifactRef == null) {
                    Message.verbose("\t" + getName() + ": no ivy file nor artifact found for "
                        + systemMrid);
                    return null;
                } else {
                    long lastModified = artifactRef.getLastModified();
                    if (lastModified != 0 && nsMd instanceof DefaultModuleDescriptor) {
                        ((DefaultModuleDescriptor) nsMd).setLastModified(lastModified);
                    }
                    Message.verbose("\t" + getName() + ": no ivy file found for " + systemMrid
                        + ": using default data");
                    if (isDynamic) {
                        nsMd.setResolvedModuleRevisionId(ModuleRevisionId.newInstance(nsMrid,
                            artifactRef.getRevision()));
                    }
                    systemMd = toSystem(nsMd);
                    MetadataArtifactDownloadReport madr =
                        new MetadataArtifactDownloadReport(systemMd.getMetadataArtifact());
                    madr.setDownloadStatus(DownloadStatus.NO);
                    madr.setSearched(true);
                    rmr = new ResolvedModuleRevision(this, this, systemMd, madr);
                }
            } else {
                if (ivyRef instanceof MDResolvedResource) {
                    rmr = ((MDResolvedResource) ivyRef).getResolvedModuleRevision();
                }
                if (rmr == null) {
                    rmr = parse(ivyRef, systemDd, data);
                    if (rmr == null) {
                        return null;
                    }
                }
                if (!rmr.getReport().isDownloaded()) {
                    return toSystem(rmr);
                } else {
                    nsMd = rmr.getDescriptor();
                    parser = ModuleDescriptorParserRegistry.getInstance().getParser(
                        ivyRef.getResource());

                    // check descriptor data is in sync with resource revision and names
                    systemMd = toSystem(nsMd);
                    if (checkconsistency) {
                        checkDescriptorConsistency(systemMrid, systemMd, ivyRef);
                        checkDescriptorConsistency(nsMrid, nsMd, ivyRef);
                    } else {
                        if (systemMd instanceof DefaultModuleDescriptor) {
                            String revision = getRevision(ivyRef, systemMrid, systemMd);
                            ((DefaultModuleDescriptor) systemMd).setModuleRevisionId(
                                ModuleRevisionId.newInstance(systemMrid, revision));
                        } else {
                            Message.warn(
                              "consistency disabled with instance of non DefaultModuleDescriptor..."
                              + " module info can't be updated, so consistency check will be done");
                            checkDescriptorConsistency(nsMrid, nsMd, ivyRef);
                            checkDescriptorConsistency(systemMrid, systemMd, ivyRef);
                        }
                    }
                    MetadataArtifactDownloadReport madr =
                        new MetadataArtifactDownloadReport(systemMd.getMetadataArtifact());
                    madr.setDownloadStatus(rmr.getReport().getDownloadStatus());
                    madr.setDownloadDetails(rmr.getReport().getDownloadDetails());
                    madr.setArtifactOrigin(rmr.getReport().getArtifactOrigin());
                    madr.setDownloadTimeMillis(rmr.getReport().getDownloadTimeMillis());
                    madr.setSize(rmr.getReport().getSize());
                    madr.setOriginalLocalFile(rmr.getReport().getOriginalLocalFile());
                    madr.setSearched(true);
                    rmr = new ResolvedModuleRevision(this, this, systemMd, madr);
                }
            }

            // resolve revision
            ModuleRevisionId resolvedMrid = systemMrid;
            if (isDynamic) {
                resolvedMrid = systemMd.getResolvedModuleRevisionId();
                if (resolvedMrid.getRevision() == null
                        || resolvedMrid.getRevision().length() == 0) {
                    if (ivyRef.getRevision() == null || ivyRef.getRevision().length() == 0) {
                        resolvedMrid = ModuleRevisionId.newInstance(resolvedMrid, "working@"
                            + getName());
                    } else {
                        resolvedMrid = ModuleRevisionId.newInstance(resolvedMrid, ivyRef
                            .getRevision());
                    }
                }
                Message.verbose("\t\t[" + toSystem(resolvedMrid).getRevision() + "] "
                    + systemMrid.getModuleId());
            }
            systemMd.setResolvedModuleRevisionId(resolvedMrid);

            // check module descriptor revision
            if (!getSettings().getVersionMatcher().accept(systemMrid, systemMd)) {
                Message.info("\t" + getName() + ": unacceptable revision => was="
                    + systemMd.getModuleRevisionId().getRevision() + " required="
                    + systemMrid.getRevision());
                return null;
            }

            // resolve and check publication date
            if (data.getDate() != null) {
                long pubDate = getPublicationDate(systemMd, systemDd, data);
                if (pubDate > data.getDate().getTime()) {
                    Message.info("\t" + getName() + ": unacceptable publication date => was="
                        + new Date(pubDate) + " required=" + data.getDate());
                    return null;
                } else if (pubDate == -1) {
                    Message.info("\t" + getName()
                        + ": impossible to guess publication date: artifact missing for "
                        + systemMrid);
                    return null;
                }
                systemMd.setResolvedPublicationDate(new Date(pubDate));
            }
           
            if (!systemMd.isDefault()
                    && data.getSettings().logNotConvertedExclusionRule()
                    && systemMd instanceof DefaultModuleDescriptor) {
                DefaultModuleDescriptor dmd = (DefaultModuleDescriptor) systemMd;
                if (dmd.isNamespaceUseful()) {
                    Message.warn(
                        "the module descriptor "
                        + ivyRef.getResource()
                        + " has information which can't be converted into "
                        + "the system namespace. "
                        + "It will require the availability of the namespace '"
                        + getNamespace().getName() + "' to be fully usable.");
                }
            }

            RepositoryCacheManager cacheManager = getRepositoryCacheManager();
           
            // the metadata artifact which was used to cache the original metadata file
            Artifact requestedMetadataArtifact =
                ivyRef == null
                ? systemMd.getMetadataArtifact()
                : parser.getMetadataArtifact(
                    ModuleRevisionId.newInstance(systemMrid, ivyRef.getRevision()),
                    ivyRef.getResource());
           
            cacheManager.originalToCachedModuleDescriptor(this, ivyRef, requestedMetadataArtifact,
                    rmr, new ModuleDescriptorWriter() {
                public void write(ResolvedResource originalMdResource, ModuleDescriptor md,
                        File src, File dest)
                        throws IOException, ParseException {
                    if (originalMdResource == null) {
                        // a basic ivy file is written containing default data
                        XmlModuleDescriptorWriter.write(md, dest);
                    } else {
                        // copy and update ivy file from source to cache
                        parser.toIvyFile(
                            new FileInputStream(src),
                            originalMdResource.getResource(), dest,
                            md);
                        long repLastModified = originalMdResource.getLastModified();
                        if (repLastModified > 0) {
View Full Code Here

Examples of org.apache.ivy.plugins.parser.ModuleDescriptorParser

        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() + ": found already resolved revision: "
                            + resolvedMrid
                            + ": but it's a default one, maybe we can find a better one");
                } else {
                    Message.verbose("\t" + getName() + ": revision already resolved: "
                            + resolvedMrid);
                    node.getModuleRevision().getReport().setSearched(true);
                    return node.getModuleRevision();
                }
            }
        }

        Artifact moduleArtifact = parser.getMetadataArtifact(resolvedMrid, mdRef.getResource());
        return getRepositoryCacheManager().cacheModuleDescriptor(
            this, mdRef, dd, moduleArtifact, downloader,
            getCacheOptions(data));
    }
View Full Code Here

Examples of org.apache.ivy.plugins.parser.ModuleDescriptorParser

    public ResolvedModuleRevision cacheModuleDescriptor(
            DependencyResolver resolver, final ResolvedResource mdRef, DependencyDescriptor dd,
            Artifact moduleArtifact, ResourceDownloader downloader, CacheMetadataOptions options)
            throws ParseException {
        ModuleDescriptorParser parser = ModuleDescriptorParserRegistry
            .getInstance().getParser(mdRef.getResource());
        Date cachedPublicationDate = null;
        ArtifactDownloadReport report;
        ModuleRevisionId mrid = moduleArtifact.getModuleRevisionId();
        Artifact originalMetadataArtifact = getOriginalMetadataArtifact(moduleArtifact);
        if (!lockMetadataArtifact(mrid)) {
            Message.error("impossible to acquire lock for " + mrid);
            return null;
        }
        try {
            // now let's see if we can find it in cache and if it is up to date
            ResolvedModuleRevision rmr = doFindModuleInCache(mrid, options, null);
            if (rmr != null) {
                if (rmr.getDescriptor().isDefault() && rmr.getResolver() != resolver) {
                    Message.verbose("\t" + getName() + ": found revision in cache: " + mrid
                        + " (resolved by " + rmr.getResolver().getName()
                        + "): but it's a default one, maybe we can find a better one");
                } else {
                    if (!isCheckmodified(dd, options) && !isChanging(dd, options)) {
                        Message.verbose("\t" + getName() + ": revision in cache: " + mrid);
                        rmr.getReport().setSearched(true);
                        return rmr;
                    }
                    long repLastModified = mdRef.getLastModified();
                    long cacheLastModified = rmr.getDescriptor().getLastModified();
                    if (!rmr.getDescriptor().isDefault() && repLastModified <= cacheLastModified) {
                        Message.verbose("\t" + getName() + ": revision in cache (not updated): "
                            + mrid);
                        rmr.getReport().setSearched(true);
                        return rmr;
                    } else {
                        Message.verbose("\t" + getName() + ": revision in cache is not up to date: "
                            + mrid);
                        if (isChanging(dd, options)) {
                            // ivy file has been updated, we should see if it has a new publication
                            // date to see if a new download is required (in case the dependency is
                            // a changing one)
                            cachedPublicationDate =
                                rmr.getDescriptor().getResolvedPublicationDate();
                        }
                    }
                }
            }

            // now download module descriptor and parse it
            report = download(
                originalMetadataArtifact,
                new ArtifactResourceResolver() {
                    public ResolvedResource resolve(Artifact artifact) {
                        return mdRef;
                    }
                }, downloader,
                new CacheDownloadOptions().setListener(options.getListener()).setForce(true));
            Message.verbose("\t" + report);

            if (report.getDownloadStatus() == DownloadStatus.FAILED) {
                Message.warn("problem while downloading module descriptor: " + mdRef.getResource()
                    + ": " + report.getDownloadDetails()
                    + " (" + report.getDownloadTimeMillis() + "ms)");
                return null;
            }

            URL cachedMDURL = null;
            try {
                cachedMDURL = report.getLocalFile().toURL();
            } catch (MalformedURLException ex) {
                Message.warn("malformed url exception for original in cache file: "
                    + report.getLocalFile() + ": " + ex.getMessage());
                return null;
            }
            try {
                ModuleDescriptor md = parser.parseDescriptor(
                    settings, cachedMDURL, mdRef.getResource(), options.isValidate());
                if (md == null) {
                    throw new IllegalStateException(
                        "module descriptor parser returned a null module descriptor, "
                        + "which is not allowed. "
                        + "parser=" + parser
                        + "; parser class=" + parser.getClass().getName()
                        + "; module descriptor resource=" + mdRef.getResource());
                }
                Message.debug("\t" + getName() + ": parsed downloaded md file for " + mrid
                    + "; parsed=" + md.getModuleRevisionId());
View Full Code Here

Examples of org.apache.ivy.plugins.parser.ModuleDescriptorParser

            try {
                File ivyFile = getCache().getResolvedIvyFileInCache(mrid);
                Message.verbose("no explicit confs given for retrieve, using ivy file: " + ivyFile);
                URL ivySource = ivyFile.toURL();
                URLResource res = new URLResource(ivySource);
                ModuleDescriptorParser parser = ModuleDescriptorParserRegistry.getInstance()
                        .getParser(res);
                Message.debug("using " + parser + " to parse " + ivyFile);
                ModuleDescriptor md = parser.parseDescriptor(settings, ivySource, false);
                confs = md.getConfigurationsNames();
                options.setConfs(confs);
            } catch (IOException e) {
                throw e;
            } catch (Exception e) {
View Full Code Here

Examples of org.apache.ivy.plugins.parser.ModuleDescriptorParser

     * Resolve dependencies of a module described by an ivy file.
     */
    public ResolveReport resolve(URL ivySource, ResolveOptions options) throws ParseException,
            IOException {
        URLResource res = new URLResource(ivySource);
        ModuleDescriptorParser parser = ModuleDescriptorParserRegistry.getInstance().getParser(res);
        Message.verbose("using " + parser + " to parse " + ivySource);
        ModuleDescriptor md = parser.parseDescriptor(settings, ivySource, options.isValidate());
        String revision = options.getRevision();
        if (revision == null && md.getResolvedModuleRevisionId().getRevision() == null) {
            revision = Ivy.getWorkingRevision();
        }
        if (revision != null) {
View Full Code Here

Examples of org.apache.ivy.plugins.parser.ModuleDescriptorParser

            try {
                File ivyFile = options.getCache().getResolvedIvyFileInCache(mrid);
                Message.verbose("no explicit confs given for retrieve, using ivy file: " + ivyFile);
                URL ivySource = ivyFile.toURL();
                URLResource res = new URLResource(ivySource);
                ModuleDescriptorParser parser = ModuleDescriptorParserRegistry.getInstance()
                        .getParser(res);
                Message.debug("using " + parser + " to parse " + ivyFile);
                ModuleDescriptor md = parser.parseDescriptor(settings, ivySource, false);
                confs = md.getConfigurationsNames();
                options.setConfs(confs);
            } catch (IOException e) {
                throw e;
            } catch (Exception e) {
View Full Code Here

Examples of org.apache.ivy.plugins.parser.ModuleDescriptorParser

            ResolvedResource ivyRef = findIvyFileRef(dd, data);
            checkInterrupted();
            searched = true;

            // get module descriptor
            ModuleDescriptorParser parser;
            ModuleDescriptor md;
            ModuleDescriptor systemMd = null;
            if (ivyRef == null) {
                if (!isAllownomd()) {
                    Message.verbose("\t" + getName() + ": no ivy file found for " + mrid);
                    return null;
                }
                parser = XmlModuleDescriptorParser.getInstance();
                md = DefaultModuleDescriptor.newDefaultInstance(mrid, dd
                        .getAllDependencyArtifacts());
                ResolvedResource artifactRef = findFirstArtifactRef(md, dd, data);
                checkInterrupted();
                if (artifactRef == null) {
                    Message.verbose("\t" + getName() + ": no ivy file nor artifact found for "
                            + mrid);
                    if (!checkedCache) {
                        cachedRmr = findModuleInCache(data, mrid);
                    }
                    if (cachedRmr != null) {
                        Message.verbose("\t" + getName() + ": revision in cache: " + mrid);
                        return toSystem(cachedRmr);
                    }
                    return null;
                } else {
                    long lastModified = artifactRef.getLastModified();
                    if (lastModified != 0 && md instanceof DefaultModuleDescriptor) {
                        ((DefaultModuleDescriptor) md).setLastModified(lastModified);
                    }
                    Message.verbose("\t" + getName() + ": no ivy file found for " + mrid
                            + ": using default data");
                    if (isDynamic) {
                        md.setResolvedModuleRevisionId(ModuleRevisionId.newInstance(mrid,
                            artifactRef.getRevision()));
                    }
                }
            } else {
                ResolvedModuleRevision rmr = null;
                if (ivyRef instanceof MDResolvedResource) {
                    rmr = ((MDResolvedResource) ivyRef).getResolvedModuleRevision();
                }
                if (rmr == null) {
                    rmr = parse(ivyRef, dd, data);
                    if (rmr == null) {
                        return null;
                    }
                }
                if (!rmr.isDownloaded()) {
                    return toSystem(rmr);
                } else {
                    md = rmr.getDescriptor();
                    parser = ModuleDescriptorParserRegistry.getInstance().getParser(
                        ivyRef.getResource());
                    cachedIvyURL = rmr.getLocalMDUrl();

                    // check descriptor data is in sync with resource revision and names
                    systemMd = toSystem(md);
                    if (checkconsistency) {
                        checkDescriptorConsistency(mrid, md, ivyRef);
                        checkDescriptorConsistency(systemDd.getDependencyRevisionId(), systemMd,
                            ivyRef);
                    } else {
                        if (md instanceof DefaultModuleDescriptor) {
                            String revision = getRevision(ivyRef, mrid, md);
                            ((DefaultModuleDescriptor) md).setModuleRevisionId(ModuleRevisionId
                                    .newInstance(mrid, revision));
                        } else {
                            Message.warn(
                              "consistency disabled with instance of non DefaultModuleDescriptor..."
                              + " module info can't be updated, so consistency check will be done");
                            checkDescriptorConsistency(mrid, md, ivyRef);
                            checkDescriptorConsistency(systemDd.getDependencyRevisionId(),
                                systemMd, ivyRef);
                        }
                    }
                }
            }

            if (systemMd == null) {
                systemMd = toSystem(md);
            }

            // resolve revision
            ModuleRevisionId resolvedMrid = mrid;
            if (isDynamic) {
                resolvedMrid = md.getResolvedModuleRevisionId();
                if (resolvedMrid.getRevision() == null
                        || resolvedMrid.getRevision().length() == 0) {
                    if (ivyRef.getRevision() == null || ivyRef.getRevision().length() == 0) {
                        resolvedMrid = ModuleRevisionId.newInstance(resolvedMrid, "working@"
                                + getName());
                    } else {
                        resolvedMrid = ModuleRevisionId.newInstance(resolvedMrid, ivyRef
                                .getRevision());
                    }
                }
                Message.verbose("\t\t[" + resolvedMrid.getRevision() + "] " + mrid.getModuleId());
            }
            md.setResolvedModuleRevisionId(resolvedMrid);
            systemMd.setResolvedModuleRevisionId(toSystem(resolvedMrid)); // keep system md in
            // sync with md

            // check module descriptor revision
            if (!getSettings().getVersionMatcher().accept(mrid, md)) {
                Message.info("\t" + getName() + ": unacceptable revision => was="
                        + md.getModuleRevisionId().getRevision() + " required="
                        + mrid.getRevision());
                return null;
            }

            // resolve and check publication date
            if (data.getDate() != null) {
                long pubDate = getPublicationDate(md, dd, data);
                if (pubDate > data.getDate().getTime()) {
                    Message.info("\t" + getName() + ": unacceptable publication date => was="
                            + new Date(pubDate) + " required=" + data.getDate());
                    return null;
                } else if (pubDate == -1) {
                    Message.info("\t" + getName()
                            + ": impossible to guess publication date: artifact missing for "
                            + mrid);
                    return null;
                }
                md.setResolvedPublicationDate(new Date(pubDate));
                systemMd.setResolvedPublicationDate(new Date(pubDate)); // keep system md in sync
                // with md
            }

            try {
                File ivyFile = data.getCacheManager().getIvyFileInCache(
                    systemMd.getResolvedModuleRevisionId());
                if (ivyRef == null) {
                    // a basic ivy file is written containing default data
                    XmlModuleDescriptorWriter.write(systemMd, ivyFile);
                } else {
                    if (md instanceof DefaultModuleDescriptor) {
                        DefaultModuleDescriptor dmd = (DefaultModuleDescriptor) md;
                        if (data.getSettings().logNotConvertedExclusionRule()
                                && dmd.isNamespaceUseful()) {
                            Message.warn(
                                "the module descriptor "
                                + ivyRef.getResource()
                                + " has information which can't be converted into "
                                + "the system namespace. "
                                + "It will require the availability of the namespace '"
                                + getNamespace().getName() + "' to be fully usable.");
                        }
                    }
                    // copy and update ivy file from source to cache
                    parser.toIvyFile(cachedIvyURL.openStream(), ivyRef.getResource(), ivyFile,
                        systemMd);
                    long repLastModified = ivyRef.getLastModified();
                    if (repLastModified > 0) {
                        ivyFile.setLastModified(repLastModified);
                    }
View Full Code Here

Examples of org.apache.ivy.plugins.parser.ModuleDescriptorParser

    public ResolvedModuleRevision parse(ResolvedResource ivyRef, DependencyDescriptor dd,
            ResolveData data) throws ParseException {

        ModuleRevisionId mrid = dd.getDependencyRevisionId();
        ModuleDescriptorParser parser = ModuleDescriptorParserRegistry.getInstance().getParser(
            ivyRef.getResource());
        if (parser == null) {
            Message.warn("no module descriptor parser available for " + ivyRef.getResource());
            return null;
        }
        Message.verbose("\t" + getName() + ": found md file for " + mrid);
        Message.verbose("\t\t=> " + ivyRef);
        Message.debug("\tparser = " + parser);

        boolean isChangingRevision = getChangingMatcher().matches(mrid.getRevision());
        boolean isChangingDependency = isChangingRevision || dd.isChanging();
        Date cachedPublicationDate = null;
        ModuleRevisionId resolvedMrid = mrid;

        // first check if this dependency has not yet been resolved
        if (getSettings().getVersionMatcher().isDynamic(mrid)) {
            resolvedMrid = ModuleRevisionId.newInstance(mrid, ivyRef.getRevision());
            IvyNode node = getSystemNode(data, 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() + ": found already resolved revision: "
                            + resolvedMrid
                            + ": but it's a default one, maybe we can find a better one");
                } else {
                    Message.verbose("\t" + getName() + ": revision already resolved: "
                            + resolvedMrid);
                    return searchedRmr(node.getModuleRevision());
                }
            }
        }

        // now let's see if we can find it in cache and if it is up to date
        ResolvedModuleRevision rmr = findModuleInCache(data, resolvedMrid);
        if (rmr != null) {
            if (rmr.getDescriptor().isDefault() && rmr.getResolver() != this) {
                Message.verbose("\t" + getName() + ": found revision in cache: " + mrid
                        + " (resolved by " + rmr.getResolver().getName()
                        + "): but it's a default one, maybe we can find a better one");
            } else {
                if (!isCheckmodified() && !isChangingDependency) {
                    Message.verbose("\t" + getName() + ": revision in cache: " + mrid);
                    return searchedRmr(rmr);
                }
                long repLastModified = ivyRef.getLastModified();
                long cacheLastModified = rmr.getDescriptor().getLastModified();
                if (!rmr.getDescriptor().isDefault() && repLastModified <= cacheLastModified) {
                    Message.verbose("\t" + getName() + ": revision in cache (not updated): "
                            + resolvedMrid);
                    return searchedRmr(rmr);
                } else {
                    Message.verbose("\t" + getName() + ": revision in cache is not up to date: "
                            + resolvedMrid);
                    if (isChangingDependency) {
                        // ivy file has been updated, we should see if it has a new publication date
                        // to see if a new download is required (in case the dependency is a
                        // changing one)
                        cachedPublicationDate = rmr.getDescriptor().getResolvedPublicationDate();
                    }
                }
            }
        }

        // now download ivy file and parse it
        URL cachedIvyURL = null;
        File ivyTempFile = null;
        try {
            // first check if source file is not cache file itself
            if (ResourceHelper.equals(ivyRef.getResource(), data.getCacheManager()
                    .getIvyFileInCache(toSystem(resolvedMrid)))) {
                Message.error("invalid configuration for resolver '" + getName()
                        + "': pointing ivy files to ivy cache is forbidden !");
                return null;
            }

            // temp file is used to prevent downloading twice
            ivyTempFile = File.createTempFile("ivy", "xml");
            ivyTempFile.deleteOnExit();
            Message.debug("\t" + getName() + ": downloading " + ivyRef.getResource() + " to "
                    + ivyTempFile);
            getAndCheck(ivyRef.getResource(), ivyTempFile);
            try {
                cachedIvyURL = ivyTempFile.toURL();
            } catch (MalformedURLException ex) {
                Message.warn("malformed url exception for temp file: " + ivyTempFile + ": "
                        + ex.getMessage());
                return null;
            }
        } catch (IOException ex) {
            Message.warn("problem while downloading ivy file: " + ivyRef.getResource() + " to "
                    + ivyTempFile + ": " + ex.getMessage());
            return null;
        }
        try {
            ModuleDescriptor md = parser.parseDescriptor(data.getSettings(), cachedIvyURL, ivyRef
                    .getResource(), doValidate(data));
            Message.debug("\t" + getName() + ": parsed downloaded md file for " + mrid + " parsed="
                    + md.getModuleRevisionId());

            // check if we should delete old artifacts
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.