Search in sources :

Example 6 with VersionMatcher

use of org.apache.ivy.plugins.version.VersionMatcher in project ant-ivy by apache.

the class RepositoryManagementEngine method getDependency.

private ModuleRevisionId getDependency(DependencyDescriptor dd) {
    ModuleRevisionId askedMrid = dd.getDependencyRevisionId();
    VersionMatcher vmatcher = settings.getVersionMatcher();
    if (vmatcher.isDynamic(askedMrid)) {
        ModuleRevisionId mrid = cache.get(askedMrid);
        if (mrid == null) {
            for (ModuleDescriptor md : getAllRevisions(askedMrid)) {
                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;
                    }
                }
            }
            if (mrid == null) {
                return null;
            } else {
                cache.put(askedMrid, mrid);
            }
        }
        return mrid;
    } else {
        return askedMrid;
    }
}
Also used : ModuleDescriptor(org.apache.ivy.core.module.descriptor.ModuleDescriptor) VersionMatcher(org.apache.ivy.plugins.version.VersionMatcher) ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId)

Example 7 with VersionMatcher

use of org.apache.ivy.plugins.version.VersionMatcher in project ant-ivy by apache.

the class XmlSettingsParserTest method testVersionMatchers2.

@Test
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));
}
Also used : MockVersionMatcher(org.apache.ivy.plugins.version.MockVersionMatcher) ChainVersionMatcher(org.apache.ivy.plugins.version.ChainVersionMatcher) MockVersionMatcher(org.apache.ivy.plugins.version.MockVersionMatcher) MavenTimedSnapshotVersionMatcher(org.apache.ivy.plugins.version.MavenTimedSnapshotVersionMatcher) VersionMatcher(org.apache.ivy.plugins.version.VersionMatcher) ChainVersionMatcher(org.apache.ivy.plugins.version.ChainVersionMatcher) Test(org.junit.Test) ModuleDescriptorParserRegistryTest(org.apache.ivy.plugins.parser.ModuleDescriptorParserRegistryTest)

Example 8 with VersionMatcher

use of org.apache.ivy.plugins.version.VersionMatcher in project ant-ivy by apache.

the class XmlSettingsParserTest method testVersionMatchers1.

@Test
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")));
    assertTrue(chain.getMatchers().contains(settings.getVersionMatcher("latest")));
}
Also used : MockVersionMatcher(org.apache.ivy.plugins.version.MockVersionMatcher) ChainVersionMatcher(org.apache.ivy.plugins.version.ChainVersionMatcher) MockVersionMatcher(org.apache.ivy.plugins.version.MockVersionMatcher) MavenTimedSnapshotVersionMatcher(org.apache.ivy.plugins.version.MavenTimedSnapshotVersionMatcher) VersionMatcher(org.apache.ivy.plugins.version.VersionMatcher) ChainVersionMatcher(org.apache.ivy.plugins.version.ChainVersionMatcher) Test(org.junit.Test) ModuleDescriptorParserRegistryTest(org.apache.ivy.plugins.parser.ModuleDescriptorParserRegistryTest)

Example 9 with VersionMatcher

use of org.apache.ivy.plugins.version.VersionMatcher in project ant-ivy by apache.

the class ResolveEngine method fetchDependencies.

private void fetchDependencies(VisitNode node, String conf, boolean shouldBePublic) {
    checkInterrupted();
    long start = System.currentTimeMillis();
    if (node.getParent() != null) {
        Message.verbose("== resolving dependencies " + node.getParent().getId() + "->" + node.getId() + " [" + node.getParentConf() + "->" + conf + "]");
    } else {
        Message.verbose("== resolving dependencies for " + node.getId() + " [" + conf + "]");
    }
    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'
             */
        resolveConflict(node, conf);
    }
    if (node.loadData(conf, shouldBePublic)) {
        // we resolve conflict again now that we have all information loaded
        // indeed in some cases conflict manager need more information than just asked
        // dependency to take the decision
        resolveConflict(node, conf);
        if (!node.isEvicted() && !node.isCircular()) {
            for (String rconf : node.getRealConfs(conf)) {
                doFetchDependencies(node, rconf);
            }
        }
    } else if (!node.hasProblem()) {
        // => we just have to update its dependencies data
        if (!node.isEvicted() && !node.isCircular()) {
            for (String rconf : node.getRealConfs(conf)) {
                doFetchDependencies(node, rconf);
            }
        }
    }
    if (node.isEvicted()) {
        // update selected nodes with confs asked in evicted one
        EvictionData ed = node.getEvictedData();
        if (ed.getSelected() != null) {
            for (IvyNode selected : ed.getSelected()) {
                if (!selected.isLoaded()) {
                    // the node is not yet loaded, we can simply update its set of
                    // configurations to fetch
                    selected.updateConfsToFetch(Collections.singleton(conf));
                } else {
                    // the node has already been loaded, we must fetch its dependencies in the
                    // required conf
                    fetchDependencies(node.gotoNode(selected), conf, true);
                }
            }
        }
    }
    if (settings.debugConflictResolution()) {
        Message.debug(node.getId() + " => dependencies resolved in " + conf + " (" + (System.currentTimeMillis() - start) + "ms)");
    }
    data.setCurrentVisitNode(parentVisitNode);
}
Also used : DependencyDescriptor(org.apache.ivy.core.module.descriptor.DependencyDescriptor) DefaultDependencyDescriptor(org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor) VersionMatcher(org.apache.ivy.plugins.version.VersionMatcher) EvictionData(org.apache.ivy.core.resolve.IvyNodeEviction.EvictionData)

Example 10 with VersionMatcher

use of org.apache.ivy.plugins.version.VersionMatcher in project ant-ivy by apache.

the class XmlSettingsParserTest method testMavenTimedSnapshotVersionMatcher.

/**
 * Tests that the {@code maven-tsnap-vm} version matcher, configured in the settings file,
 * is parsed correctly
 *
 * @throws Exception if something goes wrong
 */
@Test
public void testMavenTimedSnapshotVersionMatcher() throws Exception {
    final IvySettings settings = new IvySettings();
    XmlSettingsParser parser = new XmlSettingsParser(settings);
    parser.parse(XmlSettingsParserTest.class.getResource("ivysettings-maven-tsnap-vmatcher.xml"));
    final VersionMatcher mavenTSnapVersionMatcher = settings.getVersionMatcher(new MavenTimedSnapshotVersionMatcher().getName());
    assertNotNull("Maven timestamped snapshot version matcher is missing", mavenTSnapVersionMatcher);
    assertTrue("Unexpected type for Maven timestamped snapshot version matcher", mavenTSnapVersionMatcher instanceof MavenTimedSnapshotVersionMatcher);
}
Also used : ChainVersionMatcher(org.apache.ivy.plugins.version.ChainVersionMatcher) MockVersionMatcher(org.apache.ivy.plugins.version.MockVersionMatcher) MavenTimedSnapshotVersionMatcher(org.apache.ivy.plugins.version.MavenTimedSnapshotVersionMatcher) VersionMatcher(org.apache.ivy.plugins.version.VersionMatcher) MavenTimedSnapshotVersionMatcher(org.apache.ivy.plugins.version.MavenTimedSnapshotVersionMatcher) Test(org.junit.Test) ModuleDescriptorParserRegistryTest(org.apache.ivy.plugins.parser.ModuleDescriptorParserRegistryTest)

Aggregations

VersionMatcher (org.apache.ivy.plugins.version.VersionMatcher)11 ModuleRevisionId (org.apache.ivy.core.module.id.ModuleRevisionId)5 ModuleDescriptor (org.apache.ivy.core.module.descriptor.ModuleDescriptor)3 IvyNode (org.apache.ivy.core.resolve.IvyNode)3 ModuleDescriptorParserRegistryTest (org.apache.ivy.plugins.parser.ModuleDescriptorParserRegistryTest)3 ChainVersionMatcher (org.apache.ivy.plugins.version.ChainVersionMatcher)3 MavenTimedSnapshotVersionMatcher (org.apache.ivy.plugins.version.MavenTimedSnapshotVersionMatcher)3 MockVersionMatcher (org.apache.ivy.plugins.version.MockVersionMatcher)3 Test (org.junit.Test)3 ParseException (java.text.ParseException)2 ArrayList (java.util.ArrayList)2 DependencyDescriptor (org.apache.ivy.core.module.descriptor.DependencyDescriptor)2 ModuleId (org.apache.ivy.core.module.id.ModuleId)2 ResolvedModuleRevision (org.apache.ivy.core.resolve.ResolvedModuleRevision)2 ArtifactInfo (org.apache.ivy.plugins.latest.ArtifactInfo)2 ResolvedResource (org.apache.ivy.plugins.resolver.util.ResolvedResource)2 File (java.io.File)1 IOException (java.io.IOException)1 LinkedHashSet (java.util.LinkedHashSet)1 Ivy (org.apache.ivy.Ivy)1