Package org.apache.ivy.plugins.parser

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


     * too long, we should use a class to store the settings of the resolve.
     */
    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


            URL url = null;
            ModuleDescriptor parent = null;
            url = getSettings().getRelativeUrlResolver().getURL(descriptorURL, location);
            Message.debug("Trying to load included ivy file from " + url.toString());
            URLResource res = new URLResource(url);
            ModuleDescriptorParser parser = ModuleDescriptorParserRegistry.getInstance().getParser(
                res);

            parent = parser.parseDescriptor(getSettings(), url, isValidate());
            return parent;
        }
View Full Code Here

                            // we can't determine the revision from the pattern, get it
                            // from the moduledescriptor itself
                            File temp = File.createTempFile("ivy", artifact.getExt());
                            temp.deleteOnExit();
                            repository.get(res.getName(), temp);
                            ModuleDescriptorParser parser =
                                ModuleDescriptorParserRegistry.getInstance().getParser(res);
                            ModuleDescriptor md =
                                parser.parseDescriptor(
                                    getParserSettings(), temp.toURI().toURL(), res, false);
                            revision = md.getRevision();
                            if ((revision == null) || (revision.length() == 0)) {
                                revision = "working@" + name;
                            }
View Full Code Here

                Message.verbose("Parent module doesn't exist on the filesystem: " + file.getAbsolutePath());
                return null;
            }
           
            FileResource res = new FileResource(null, file);
            ModuleDescriptorParser parser = ModuleDescriptorParserRegistry.getInstance().getParser(res);
            return parser.parseDescriptor(getSettings(), file.toURL(), res, isValidate());
        }
View Full Code Here

    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) {
                            dest.setLastModified(repLastModified);
                        }
View Full Code Here

        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

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

            // 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);
                    if (!checkedCache) {
                        cachedRmr = findModuleInCache(data, systemMrid);
                    }
                    if (cachedRmr != null) {
                        Message.verbose("\t" + getName() + ": revision in cache: " + systemMrid);
                        return cachedRmr;
                    }
                    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()));
                    }
                }
            } else {
                ResolvedModuleRevision rmr = null;
                if (ivyRef instanceof MDResolvedResource) {
                    rmr = ((MDResolvedResource) ivyRef).getResolvedModuleRevision();
                }
                if (rmr == null) {
                    rmr = parse(ivyRef, systemDd, data);
                    if (rmr == null) {
                        return null;
                    }
                }
                if (!rmr.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 (nsMd instanceof DefaultModuleDescriptor) {
                            String revision = getRevision(ivyRef, nsMrid, nsMd);
                            ((DefaultModuleDescriptor) nsMd).setModuleRevisionId(ModuleRevisionId
                                .newInstance(nsMrid, 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);
                        }
                    }
                }
            }

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

            // resolve revision
            ModuleRevisionId resolvedMrid = nsMrid;
            if (isDynamic) {
                resolvedMrid = nsMd.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());
            }
            nsMd.setResolvedModuleRevisionId(resolvedMrid);

            // keep system md in sync with ns md
            systemMd.setResolvedModuleRevisionId(toSystem(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;
                }
                nsMd.setResolvedPublicationDate(new Date(pubDate));
                systemMd.setResolvedPublicationDate(new Date(pubDate));
            }
           
            if (!nsMd.isDefault()
                    && data.getSettings().logNotConvertedExclusionRule()
                    && nsMd instanceof DefaultModuleDescriptor) {
                DefaultModuleDescriptor dmd = (DefaultModuleDescriptor) nsMd;
                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 = data.getCacheManager();
           
            // 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,
                    systemMd, 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

        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);
                    return DefaultModuleRevision.searchedRmr(node.getModuleRevision());
                }
            }
        }

        Artifact moduleArtifact = parser.getMetadataArtifact(resolvedMrid, mdRef.getResource());
        boolean isChangingRevision = getChangingMatcher().matches(mrid.getRevision());
        boolean isChangingDependency = isChangingRevision || dd.isChanging();
        return data.getCacheManager().cacheModuleDescriptor(
            this, mdRef, moduleArtifact, downloader,
            (CacheMetadataOptions) new CacheMetadataOptions()
View Full Code Here

TOP

Related Classes of org.apache.ivy.plugins.parser.ModuleDescriptorParser

Copyright © 2018 www.massapicom. 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.