Search in sources :

Example 1 with ChainVersionMatcher

use of org.apache.ivy.plugins.version.ChainVersionMatcher 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 2 with ChainVersionMatcher

use of org.apache.ivy.plugins.version.ChainVersionMatcher 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 3 with ChainVersionMatcher

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

the class IvySettings method addVersionMatcher.

public synchronized void addVersionMatcher(VersionMatcher vmatcher) {
    init(vmatcher);
    versionMatchers.put(vmatcher.getName(), vmatcher);
    if (versionMatcher == null) {
        versionMatcher = new ChainVersionMatcher();
        addVersionMatcher(new ExactVersionMatcher());
    }
    if (versionMatcher instanceof ChainVersionMatcher) {
        ChainVersionMatcher chain = (ChainVersionMatcher) versionMatcher;
        chain.add(vmatcher);
    }
}
Also used : ExactVersionMatcher(org.apache.ivy.plugins.version.ExactVersionMatcher) ChainVersionMatcher(org.apache.ivy.plugins.version.ChainVersionMatcher)

Aggregations

ChainVersionMatcher (org.apache.ivy.plugins.version.ChainVersionMatcher)3 ModuleDescriptorParserRegistryTest (org.apache.ivy.plugins.parser.ModuleDescriptorParserRegistryTest)2 MavenTimedSnapshotVersionMatcher (org.apache.ivy.plugins.version.MavenTimedSnapshotVersionMatcher)2 MockVersionMatcher (org.apache.ivy.plugins.version.MockVersionMatcher)2 VersionMatcher (org.apache.ivy.plugins.version.VersionMatcher)2 Test (org.junit.Test)2 ExactVersionMatcher (org.apache.ivy.plugins.version.ExactVersionMatcher)1