Examples of VersionMatcher


Examples of org.apache.ivy.plugins.version.VersionMatcher

        ArtifactInfo[] infos = new ArtifactInfo[revisions.length];
        for (int i = 0; i < revisions.length; i++) {
            infos[i] = new ResolvedModuleRevisionArtifactInfo(revisions[i]);
        }
       
        VersionMatcher matcher = settings.getVersionMatcher();
        LatestStrategy latestStrategy = settings.getLatestStrategy("latest-revision");
        List sorted = latestStrategy.sort(infos);

        ModuleRevisionId askedMrid = ModuleRevisionId.newInstance(organisation,
            module, branch, revision);

        String foundRevision = null;
        for (ListIterator iter = sorted.listIterator(sorted.size()); iter.hasPrevious();) {
            ResolvedModuleRevisionArtifactInfo info = (ResolvedModuleRevisionArtifactInfo) iter.previous();
           
            if (!matcher.accept(askedMrid, info.rmr)) {
                continue;
            }
           
            if (matcher.needModuleDescriptor(askedMrid, info.rmr)) {
                ResolvedModuleRevision rmr = ivy.findModule(info.rmr);
                if (matcher.accept(askedMrid, rmr.getDescriptor())) {
                    foundRevision = info.rmr.getRevision();
                }
            } else {
                foundRevision = info.rmr.getRevision();
            }
View Full Code Here

Examples of org.apache.ivy.plugins.version.VersionMatcher

    public void testVersionMatchers1() throws Exception {
        IvySettings settings = new IvySettings();
        XmlSettingsParser parser = new XmlSettingsParser(settings);
        parser.parse(XmlSettingsParserTest.class.getResource("ivysettings-vmatcher1.xml"));

        VersionMatcher mock = settings.getVersionMatcher("vmock");
        assertNotNull(mock);
        assertTrue(mock instanceof MockVersionMatcher);

        VersionMatcher v = settings.getVersionMatcher();
        assertTrue(v instanceof ChainVersionMatcher);
        ChainVersionMatcher chain = (ChainVersionMatcher) v;
        assertEquals(3, chain.getMatchers().size());
        assertTrue(chain.getMatchers().contains(mock));
        assertTrue(chain.getMatchers().contains(settings.getVersionMatcher("exact")));
View Full Code Here

Examples of org.apache.ivy.plugins.version.VersionMatcher

    public void testVersionMatchers2() throws Exception {
        IvySettings settings = new IvySettings();
        XmlSettingsParser parser = new XmlSettingsParser(settings);
        parser.parse(XmlSettingsParserTest.class.getResource("ivysettings-vmatcher2.xml"));

        VersionMatcher mock = settings.getVersionMatcher("vmock");
        assertNotNull(mock);
        assertTrue(mock instanceof MockVersionMatcher);

        VersionMatcher v = settings.getVersionMatcher();
        assertTrue(v instanceof ChainVersionMatcher);
        ChainVersionMatcher chain = (ChainVersionMatcher) v;
        assertEquals(5, chain.getMatchers().size());
        assertTrue(chain.getMatchers().contains(mock));
    }
View Full Code Here

Examples of org.apache.ivy.plugins.version.VersionMatcher

             * or lower than the other one. Note that if the version matcher compare method returns
             * 0, it's because it's not possible to know which revision is greater. In this case we
             * consider the dynamic one to be greater, because most of the time it will then be
             * actually resolved and a real comparison will occur.
             */
            VersionMatcher vmatcher = IvyContext.getContext().getSettings().getVersionMatcher();
            ModuleRevisionId mrid1 = ModuleRevisionId.newInstance("", "", rev1);
            ModuleRevisionId mrid2 = ModuleRevisionId.newInstance("", "", rev2);
            if (vmatcher.isDynamic(mrid1)) {
                int c = vmatcher.compare(mrid1, mrid2, mridComparator);
                return c >= 0 ? 1 : -1;
            } else if (vmatcher.isDynamic(mrid2)) {
                int c = vmatcher.compare(mrid2, mrid1, mridComparator);
                return c >= 0 ? -1 : 1;
            }
       
            return mridComparator.compare(mrid1, mrid2);
        }
View Full Code Here

Examples of org.apache.ivy.plugins.version.VersionMatcher

        return mrids;
    }

    private ModuleRevisionId getDependency(DependencyDescriptor dd) {
        ModuleRevisionId askedMrid = dd.getDependencyRevisionId();
        VersionMatcher vmatcher = settings.getVersionMatcher();
        if (vmatcher.isDynamic(askedMrid)) {
            ModuleRevisionId mrid = (ModuleRevisionId) cache.get(askedMrid);
            if (mrid == null) {
                Collection revs = getAllRevisions(askedMrid);
                for (Iterator iterator = revs.iterator(); iterator.hasNext();) {
                    ModuleDescriptor md = (ModuleDescriptor) iterator.next();
                    if (vmatcher.needModuleDescriptor(
                            askedMrid, md.getResolvedModuleRevisionId())) {
                        if (vmatcher.accept(askedMrid, md)) {
                            mrid = md.getResolvedModuleRevisionId();
                            break;
                        }
                    } else {
                        if (vmatcher.accept(askedMrid, md.getResolvedModuleRevisionId())) {
                            mrid = md.getResolvedModuleRevisionId();
                            break;
                        }
                    }
                }
View Full Code Here

Examples of org.apache.ivy.plugins.version.VersionMatcher

            String pattern, Artifact artifact, ResourceMDParser rmdparser, Date date);

    public ResolvedResource findResource(ResolvedResource[] rress, ResourceMDParser rmdparser,
            ModuleRevisionId mrid, Date date) {
        String name = getName();
        VersionMatcher versionMatcher = getSettings().getVersionMatcher();
       
        ResolvedResource found = null;
        List sorted = getLatestStrategy().sort(rress);
        List rejected = new ArrayList();
        List foundBlacklisted = new ArrayList();
        IvyContext context = IvyContext.getContext();
       
        for (ListIterator iter = sorted.listIterator(sorted.size()); iter.hasPrevious();) {
            ResolvedResource rres = (ResolvedResource) iter.previous();
            if (filterNames(new ArrayList(Collections.singleton(rres.getRevision()))).isEmpty()) {
                Message.debug("\t" + name + ": filtered by name: " + rres);
                continue;
            }
            if ((date != null && rres.getLastModified() > date.getTime())) {
                Message.verbose("\t" + name + ": too young: " + rres);
                rejected.add(rres.getRevision() + " (" + rres.getLastModified() + ")");
                continue;
            }
            ModuleRevisionId foundMrid = ModuleRevisionId.newInstance(mrid, rres.getRevision());
           
            ResolveData data = context.getResolveData();
            if (data != null
                    && data.getReport() != null
                    && data.isBlacklisted(data.getReport().getConfiguration(), foundMrid)) {
                Message.debug("\t" + name + ": blacklisted: " + rres);
                rejected.add(rres.getRevision() + " (blacklisted)");
                foundBlacklisted.add(foundMrid);
                continue;
            }
           
            if (!versionMatcher.accept(mrid, foundMrid)) {
                Message.debug("\t" + name + ": rejected by version matcher: " + rres);
                rejected.add(rres.getRevision());
                continue;
            }
            if (versionMatcher.needModuleDescriptor(mrid, foundMrid)) {
                ResolvedResource r = rmdparser.parse(rres.getResource(), rres.getRevision());
                if (r == null) {
                    Message.debug("\t" + name
                        + ": impossible to get module descriptor resource: " + rres);
                    rejected.add(rres.getRevision() + " (no or bad MD)");
                    continue;
                }
                ModuleDescriptor md = ((MDResolvedResource) r).getResolvedModuleRevision()
                        .getDescriptor();
                if (md.isDefault()) {
                    Message.debug("\t" + name + ": default md rejected by version matcher"
                            + "requiring module descriptor: " + rres);
                    rejected.add(rres.getRevision() + " (MD)");
                    continue;
                } else if (!versionMatcher.accept(mrid, md)) {
                    Message.debug("\t" + name + ": md rejected by version matcher: " + rres);
                    rejected.add(rres.getRevision() + " (MD)");
                    continue;
                } else {
                    found = r;
View Full Code Here

Examples of org.apache.ivy.plugins.version.VersionMatcher

        ResolveData data = node.getNode().getData();
        VisitNode parentVisitNode = data.getCurrentVisitNode();
       
        data.setCurrentVisitNode(node);
        DependencyDescriptor dd = node.getDependencyDescriptor();
        VersionMatcher versionMatcher = node.getNode().getData().getSettings().getVersionMatcher();
        if (dd != null
                && !(node.getRoot() == node.getParent()
                        && versionMatcher.isDynamic(dd.getDependencyRevisionId()))) {
            /*
             * we don't resolve conflicts before loading data for direct dependencies on dynamic
             * revisions, so that direct dynamic revisions are always resolved, which is mandatory
             * for proper replacement of dynamic revisions during 'deliver'
             */
 
View Full Code Here

Examples of org.apache.ivy.plugins.version.VersionMatcher

    }

    protected ResolvedResource findResourceUsingPattern(ModuleRevisionId mrid, String pattern,
            Artifact artifact, ResourceMDParser rmdparser, Date date) {
        String name = getName();
        VersionMatcher versionMatcher = getSettings().getVersionMatcher();
        try {
            if (!versionMatcher.isDynamic(mrid) || isAlwaysCheckExactRevision()) {
                String resourceName = IvyPatternHelper.substitute(pattern, mrid, artifact);
                Message.debug("\t trying " + resourceName);
                logAttempt(resourceName);
                Resource res = repository.getResource(resourceName);
                boolean reachable = res.exists();
                if (reachable) {
                    String revision;
                    if (pattern.indexOf(IvyPatternHelper.REVISION_KEY) == -1) {
                        if ("ivy".equals(artifact.getType()) || "pom".equals(artifact.getType())) {
                            // 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(
                                    getSettings(), temp.toURI().toURL(), res, false);
                            revision = md.getRevision();
                            if ((revision == null) || (revision.length() == 0)) {
                                revision = "working@" + name;
                            }
                        } else {
                            revision = "working@" + name;
                        }
                    } else {
                        revision = mrid.getRevision();
                    }
                    return new ResolvedResource(res, revision);
                } else if (versionMatcher.isDynamic(mrid)) {
                    return findDynamicResourceUsingPattern(
                        rmdparser, mrid, pattern, artifact, date);
                } else {
                    Message.debug("\t" + name + ": resource not reachable for " + mrid + ": res="
                            + res);
View Full Code Here

Examples of org.apache.ivy.plugins.version.VersionMatcher

    public StrictConflictManager() {
    }

    public Collection resolveConflicts(IvyNode parent, Collection conflicts) {
        VersionMatcher versionMatcher = getSettings().getVersionMatcher();
       
        IvyNode lastNode = null;
        for (Iterator iter = conflicts.iterator(); iter.hasNext();) {
            IvyNode node = (IvyNode) iter.next();

            if (versionMatcher.isDynamic(node.getResolvedId())) {
                // dynamic revision, not enough information to resolve conflict
                return null;
            }
           
            if (lastNode != null && !lastNode.equals(node)) {
View Full Code Here

Examples of org.apache.ivy.plugins.version.VersionMatcher

    public Collection resolveConflicts(IvyNode parent, Collection conflicts) {
        if (conflicts.size() < 2) {
            return conflicts;
        }
        VersionMatcher versionMatcher = getSettings().getVersionMatcher();
       
        Iterator iter = conflicts.iterator();
        IvyNode node = (IvyNode) iter.next();
        ModuleRevisionId mrid = node.getResolvedId();
       
        if (versionMatcher.isDynamic(mrid)) {
            while (iter.hasNext()) {
                IvyNode other = (IvyNode) iter.next();
                if (versionMatcher.isDynamic(other.getResolvedId())) {
                    // two dynamic versions in conflict, not enough information yet
                    return null;
                } else if (!versionMatcher.accept(mrid, other.getResolvedId())) {
                    // incompatibility found
                    if (!handleIncompatibleConflict(parent, conflicts, node, other)) {
                        return null;
                    }
                }
            }
            // no incompatibility nor dynamic version found, let's return the latest static version
            if (conflicts.size() == 2) {
                // very common special case of only two modules in conflict,
                // let's return the second one (static)
                Iterator it = conflicts.iterator();
                it.next();
                return Collections.singleton(it.next());
            }
            Collection newConflicts = new LinkedHashSet(conflicts);
            newConflicts.remove(node);
            return super.resolveConflicts(parent, newConflicts);
        } else {
            // the first node is a static revision, let's see if all other versions match
            while (iter.hasNext()) {
                IvyNode other = (IvyNode) iter.next();
                if (!versionMatcher.accept(other.getResolvedId(), mrid)) {
                    // incompatibility found
                    if (!handleIncompatibleConflict(parent, conflicts, node, other)) {
                        return null;
                    }
                }
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.