Search in sources :

Example 51 with DefaultDependencyDescriptor

use of org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor in project ant-ivy by apache.

the class TestHelper method parseMicroIvyDescriptor.

/**
 * Parses a string representation of a module descriptor in micro ivy format.
 * <p>
 * Examples:
 * </p>
 * <pre>
 * #A;1
 * </pre>
 * <hr>
 * <pre>
 * #A;2-&gt; #B;[1.0,1.5]
 * </pre>
 * <hr>
 * <pre>
 * #A;3-&gt; { #B;[1.0,1.5] #C;[2.0,2.5] }
 * </pre>
 *
 * @param microIvy
 *            the micro ivy description of the module descriptor
 * @return the parsed module descriptor
 */
public static ModuleDescriptor parseMicroIvyDescriptor(String microIvy) {
    Pattern mridPattern = ModuleRevisionId.NON_CAPTURING_PATTERN;
    Matcher m = mridPattern.matcher(microIvy);
    if (m.matches()) {
        return DefaultModuleDescriptor.newBasicInstance(ModuleRevisionId.parse(microIvy), new Date());
    }
    Pattern oneDependencyPattern = Pattern.compile(String.format("(%s)\\s*->\\s*(%s)", mridPattern.pattern(), mridPattern.pattern()));
    m = oneDependencyPattern.matcher(microIvy);
    if (m.matches()) {
        DefaultModuleDescriptor md = DefaultModuleDescriptor.newBasicInstance(ModuleRevisionId.parse(m.group(1)), new Date());
        md.addDependency(new DefaultDependencyDescriptor(ModuleRevisionId.parse(m.group(2)), false));
        return md;
    }
    String p = String.format("(%s)\\s*->\\s*\\{\\s*((?:%s,?\\s+)*%s)?\\s*\\}", mridPattern.pattern(), mridPattern.pattern(), mridPattern.pattern());
    Pattern multipleDependenciesPattern = Pattern.compile(p);
    m = multipleDependenciesPattern.matcher(microIvy);
    if (m.matches()) {
        DefaultModuleDescriptor md = DefaultModuleDescriptor.newBasicInstance(ModuleRevisionId.parse(m.group(1)), new Date());
        String mrids = m.group(2);
        if (mrids != null) {
            for (ModuleRevisionId dep : parseMrids(mrids)) {
                md.addDependency(new DefaultDependencyDescriptor(dep, false));
            }
        }
        return md;
    }
    throw new IllegalArgumentException("invalid micro ivy format: " + microIvy);
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) DefaultDependencyDescriptor(org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor) DefaultModuleDescriptor(org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor) Date(java.util.Date)

Example 52 with DefaultDependencyDescriptor

use of org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor in project ant-ivy by apache.

the class IvyDependency method asDependencyDescriptor.

DependencyDescriptor asDependencyDescriptor(ModuleDescriptor md, String masterConf, IvySettings settings) {
    if (org == null) {
        throw new BuildException("'org' is required on ");
    }
    if (name == null) {
        throw new BuildException("'name' is required when using inline mode");
    }
    ModuleRevisionId mrid = ModuleRevisionId.newInstance(org, name, branch, rev);
    DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(md, mrid, force, changing, transitive);
    if (conf != null) {
        dd.addDependencyConfiguration(masterConf, conf);
    } else {
        dd.addDependencyConfiguration(masterConf, "*");
    }
    for (IvyDependencyConf c : confs) {
        c.addConf(dd, masterConf);
    }
    for (IvyDependencyArtifact artifact : artifacts) {
        artifact.addArtifact(dd, masterConf);
    }
    for (IvyDependencyExclude exclude : excludes) {
        DefaultExcludeRule rule = exclude.asRule(settings);
        dd.addExcludeRule(masterConf, rule);
    }
    for (IvyDependencyInclude include : includes) {
        DefaultIncludeRule rule = include.asRule(settings);
        dd.addIncludeRule(masterConf, rule);
    }
    return dd;
}
Also used : DefaultExcludeRule(org.apache.ivy.core.module.descriptor.DefaultExcludeRule) ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) BuildException(org.apache.tools.ant.BuildException) DefaultDependencyDescriptor(org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor) DefaultIncludeRule(org.apache.ivy.core.module.descriptor.DefaultIncludeRule)

Example 53 with DefaultDependencyDescriptor

use of org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor in project ant-ivy by apache.

the class XmlModuleDescriptorParserTest method testFull.

@Test
public void testFull() throws Exception {
    ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings, getClass().getResource("test.xml"), true);
    assertNotNull(md);
    assertEquals("myorg", md.getModuleRevisionId().getOrganisation());
    assertEquals("mymodule", md.getModuleRevisionId().getName());
    assertEquals("myrev", md.getModuleRevisionId().getRevision());
    assertEquals("integration", md.getStatus());
    Date pubdate = new GregorianCalendar(2004, 10, 1, 11, 0, 0).getTime();
    assertEquals(pubdate, md.getPublicationDate());
    License[] licenses = md.getLicenses();
    assertEquals(1, licenses.length);
    assertEquals("MyLicense", licenses[0].getName());
    assertEquals("http://www.my.org/mymodule/mylicense.html", licenses[0].getUrl());
    assertEquals("http://www.my.org/mymodule/", md.getHomePage());
    assertEquals("This module is <b>great</b> !<br/>\n\t" + "You can use it especially with myconf1 and myconf2, " + "and myconf4 is not too bad too.", md.getDescription().replaceAll("\r\n", "\n").replace('\r', '\n'));
    assertEquals(1, md.getExtraInfos().size());
    ExtraInfoHolder someExtraElement = md.getExtraInfos().get(0);
    assertEquals("e:someExtra", someExtraElement.getName());
    assertEquals("56576", someExtraElement.getContent());
    assertEquals(0, someExtraElement.getAttributes().size());
    Configuration[] confs = md.getConfigurations();
    assertNotNull(confs);
    assertEquals(5, confs.length);
    assertConf(md, "myconf1", "desc 1", PUBLIC, new String[0]);
    assertConf(md, "myconf2", "desc 2", PUBLIC, new String[0]);
    assertConf(md, "myconf3", "desc 3", PRIVATE, new String[0]);
    assertConf(md, "myconf4", "desc 4", PUBLIC, new String[] { "myconf1", "myconf2" });
    assertConf(md, "myoldconf", "my old desc", PUBLIC, new String[0]);
    assertArtifacts(md.getArtifacts("myconf1"), new String[] { "myartifact1", "myartifact2", "myartifact3", "myartifact4" });
    assertArtifacts(md.getArtifacts("myconf2"), new String[] { "myartifact1", "myartifact3" });
    assertArtifacts(md.getArtifacts("myconf3"), new String[] { "myartifact1", "myartifact3", "myartifact4" });
    assertArtifacts(md.getArtifacts("myconf4"), new String[] { "myartifact1" });
    DependencyDescriptor[] dependencies = md.getDependencies();
    assertNotNull(dependencies);
    assertEquals(13, dependencies.length);
    // no conf def => equivalent to *->*
    DependencyDescriptor dd = getDependency(dependencies, "mymodule2");
    assertNotNull(dd);
    assertEquals("myorg", dd.getDependencyId().getOrganisation());
    assertEquals("2.0", dd.getDependencyRevisionId().getRevision());
    assertEquals(Collections.singletonList("*"), Arrays.asList(dd.getModuleConfigurations()));
    assertEquals(Collections.singletonList("*"), Arrays.asList(dd.getDependencyConfigurations("myconf1")));
    assertEquals(Collections.singletonList("*"), Arrays.asList(dd.getDependencyConfigurations(new String[] { "myconf2", "myconf3", "myconf4" })));
    assertDependencyArtifactIncludeRules(dd, new String[] { "myconf1", "myconf2", "myconf3", "myconf4" }, new String[0]);
    assertFalse(dd.isChanging());
    assertTrue(dd.isTransitive());
    // changing = true
    dd = getDependency(dependencies, "mymodule3");
    assertNotNull(dd);
    assertTrue(dd.isChanging());
    assertFalse(dd.isTransitive());
    // conf="myconf1" => equivalent to myconf1->myconf1
    dd = getDependency(dependencies, "yourmodule1");
    assertNotNull(dd);
    assertEquals("yourorg", dd.getDependencyId().getOrganisation());
    assertEquals("trunk", dd.getDependencyRevisionId().getBranch());
    assertEquals("1.1", dd.getDependencyRevisionId().getRevision());
    assertEquals("branch1", dd.getDynamicConstraintDependencyRevisionId().getBranch());
    assertEquals("1+", dd.getDynamicConstraintDependencyRevisionId().getRevision());
    assertEquals("yourorg#yourmodule1#branch1;1+", dd.getDynamicConstraintDependencyRevisionId().toString());
    assertEquals(Collections.singletonList("myconf1"), Arrays.asList(dd.getModuleConfigurations()));
    assertEquals(Collections.singletonList("myconf1"), Arrays.asList(dd.getDependencyConfigurations("myconf1")));
    assertEquals(Collections.emptyList(), Arrays.asList(dd.getDependencyConfigurations(new String[] { "myconf2", "myconf3", "myconf4" })));
    assertDependencyArtifactIncludeRules(dd, new String[] { "myconf1", "myconf2", "myconf3", "myconf4" }, new String[0]);
    // conf="myconf1->yourconf1"
    dd = getDependency(dependencies, "yourmodule2");
    assertNotNull(dd);
    assertEquals("yourorg", dd.getDependencyId().getOrganisation());
    assertEquals("2+", dd.getDependencyRevisionId().getRevision());
    assertEquals(Collections.singletonList("myconf1"), Arrays.asList(dd.getModuleConfigurations()));
    assertEquals(Collections.singletonList("yourconf1"), Arrays.asList(dd.getDependencyConfigurations("myconf1")));
    assertEquals(Collections.emptyList(), Arrays.asList(dd.getDependencyConfigurations(new String[] { "myconf2", "myconf3", "myconf4" })));
    assertDependencyArtifactIncludeRules(dd, new String[] { "myconf1", "myconf2", "myconf3", "myconf4" }, new String[0]);
    // conf="myconf1->yourconf1, yourconf2"
    dd = getDependency(dependencies, "yourmodule3");
    assertNotNull(dd);
    assertEquals("yourorg", dd.getDependencyId().getOrganisation());
    assertEquals("3.1", dd.getDependencyRevisionId().getRevision());
    assertEquals(Collections.singletonList("myconf1"), Arrays.asList(dd.getModuleConfigurations()));
    assertEquals(Arrays.asList("yourconf1", "yourconf2"), Arrays.asList(dd.getDependencyConfigurations("myconf1")));
    assertEquals(Collections.emptyList(), Arrays.asList(dd.getDependencyConfigurations(new String[] { "myconf2", "myconf3", "myconf4" })));
    assertDependencyArtifactIncludeRules(dd, new String[] { "myconf1", "myconf2", "myconf3", "myconf4" }, new String[0]);
    // conf="myconf1, myconf2->yourconf1, yourconf2"
    dd = getDependency(dependencies, "yourmodule4");
    assertNotNull(dd);
    assertEquals("yourorg", dd.getDependencyId().getOrganisation());
    assertEquals("4.1", dd.getDependencyRevisionId().getRevision());
    assertEquals(new HashSet<>(Arrays.asList("myconf1", "myconf2")), new HashSet<>(Arrays.asList(dd.getModuleConfigurations())));
    assertEquals(Arrays.asList("yourconf1", "yourconf2"), Arrays.asList(dd.getDependencyConfigurations("myconf1")));
    assertEquals(Arrays.asList("yourconf1", "yourconf2"), Arrays.asList(dd.getDependencyConfigurations("myconf2")));
    assertEquals(Collections.emptyList(), Arrays.asList(dd.getDependencyConfigurations(new String[] { "myconf3", "myconf4" })));
    assertDependencyArtifactIncludeRules(dd, new String[] { "myconf1", "myconf2", "myconf3", "myconf4" }, new String[0]);
    // conf="myconf1->yourconf1;myconf2->yourconf1, yourconf2"
    dd = getDependency(dependencies, "yourmodule5");
    assertNotNull(dd);
    assertEquals("yourorg", dd.getDependencyId().getOrganisation());
    assertEquals("5.1", dd.getDependencyRevisionId().getRevision());
    assertEquals(new HashSet<>(Arrays.asList("myconf1", "myconf2")), new HashSet<>(Arrays.asList(dd.getModuleConfigurations())));
    assertEquals(Collections.singletonList("yourconf1"), Arrays.asList(dd.getDependencyConfigurations("myconf1")));
    assertEquals(Arrays.asList("yourconf1", "yourconf2"), Arrays.asList(dd.getDependencyConfigurations("myconf2")));
    assertEquals(Collections.emptyList(), Arrays.asList(dd.getDependencyConfigurations(new String[] { "myconf3", "myconf4" })));
    assertDependencyArtifactIncludeRules(dd, new String[] { "myconf1", "myconf2", "myconf3", "myconf4" }, new String[0]);
    // conf="*->@"
    dd = getDependency(dependencies, "yourmodule11");
    assertNotNull(dd);
    assertEquals("yourorg", dd.getDependencyId().getOrganisation());
    assertEquals("11.1", dd.getDependencyRevisionId().getRevision());
    assertEquals(Collections.singleton("*"), new HashSet<>(Arrays.asList(dd.getModuleConfigurations())));
    assertEquals(Collections.singletonList("myconf1"), Arrays.asList(dd.getDependencyConfigurations("myconf1")));
    assertEquals(Collections.singletonList("myconf2"), Arrays.asList(dd.getDependencyConfigurations("myconf2")));
    assertEquals(Collections.singletonList("myconf3"), Arrays.asList(dd.getDependencyConfigurations("myconf3")));
    assertEquals(Collections.singletonList("myconf4"), Arrays.asList(dd.getDependencyConfigurations("myconf4")));
    dd = getDependency(dependencies, "yourmodule6");
    assertNotNull(dd);
    assertEquals("yourorg", dd.getDependencyId().getOrganisation());
    assertEquals("latest.integration", dd.getDependencyRevisionId().getRevision());
    assertEquals(new HashSet<>(Arrays.asList("myconf1", "myconf2")), new HashSet<>(Arrays.asList(dd.getModuleConfigurations())));
    assertEquals(Collections.singletonList("yourconf1"), Arrays.asList(dd.getDependencyConfigurations("myconf1")));
    assertEquals(Arrays.asList("yourconf1", "yourconf2"), Arrays.asList(dd.getDependencyConfigurations("myconf2")));
    assertEquals(Collections.emptyList(), Arrays.asList(dd.getDependencyConfigurations(new String[] { "myconf3", "myconf4" })));
    assertDependencyArtifactIncludeRules(dd, new String[] { "myconf1", "myconf2", "myconf3", "myconf4" }, new String[0]);
    dd = getDependency(dependencies, "yourmodule7");
    assertNotNull(dd);
    assertEquals("yourorg", dd.getDependencyId().getOrganisation());
    assertEquals("7.1", dd.getDependencyRevisionId().getRevision());
    assertEquals(new HashSet<>(Arrays.asList("myconf1", "myconf2")), new HashSet<>(Arrays.asList(dd.getModuleConfigurations())));
    assertEquals(Collections.singletonList("yourconf1"), Arrays.asList(dd.getDependencyConfigurations("myconf1")));
    assertEquals(Arrays.asList("yourconf1", "yourconf2"), Arrays.asList(dd.getDependencyConfigurations("myconf2")));
    assertEquals(Collections.emptyList(), Arrays.asList(dd.getDependencyConfigurations(new String[] { "myconf3", "myconf4" })));
    assertDependencyArtifactIncludeRules(dd, new String[] { "myconf1", "myconf2", "myconf3", "myconf4" }, new String[0]);
    dd = getDependency(dependencies, "yourmodule8");
    assertNotNull(dd);
    assertEquals("yourorg", dd.getDependencyId().getOrganisation());
    assertEquals("8.1", dd.getDependencyRevisionId().getRevision());
    assertEquals(new HashSet<>(Collections.singletonList("*")), new HashSet<>(Arrays.asList(dd.getModuleConfigurations())));
    assertDependencyArtifacts(dd, new String[] { "myconf1" }, new String[] { "yourartifact8-1", "yourartifact8-2" });
    assertDependencyArtifacts(dd, new String[] { "myconf2" }, new String[] { "yourartifact8-1", "yourartifact8-2" });
    assertDependencyArtifacts(dd, new String[] { "myconf3" }, new String[] { "yourartifact8-1", "yourartifact8-2" });
    assertDependencyArtifacts(dd, new String[] { "myconf4" }, new String[] { "yourartifact8-1", "yourartifact8-2" });
    dd = getDependency(dependencies, "yourmodule9");
    assertNotNull(dd);
    assertEquals("yourorg", dd.getDependencyId().getOrganisation());
    assertEquals("9.1", dd.getDependencyRevisionId().getRevision());
    assertEquals(new HashSet<>(Arrays.asList("myconf1", "myconf2", "myconf3")), new HashSet<>(Arrays.asList(dd.getModuleConfigurations())));
    assertDependencyArtifacts(dd, new String[] { "myconf1" }, new String[] { "yourartifact9-1" });
    assertDependencyArtifacts(dd, new String[] { "myconf2" }, new String[] { "yourartifact9-1", "yourartifact9-2" });
    assertDependencyArtifacts(dd, new String[] { "myconf3" }, new String[] { "yourartifact9-2" });
    assertDependencyArtifacts(dd, new String[] { "myconf4" }, new String[] {});
    assertDependencyArtifactExcludeRules(dd, new String[] { "myconf1" }, new String[] {});
    assertDependencyArtifactExcludeRules(dd, new String[] { "myconf2" }, new String[] {});
    assertDependencyArtifactExcludeRules(dd, new String[] { "myconf3" }, new String[] {});
    assertDependencyArtifactExcludeRules(dd, new String[] { "myconf4" }, new String[] {});
    dd = getDependency(dependencies, "yourmodule10");
    assertNotNull(dd);
    assertEquals("yourorg", dd.getDependencyId().getOrganisation());
    assertEquals("10.1", dd.getDependencyRevisionId().getRevision());
    assertEquals(Collections.singleton("*"), new HashSet<>(Arrays.asList(dd.getModuleConfigurations())));
    assertDependencyArtifactIncludeRules(dd, new String[] { "myconf1" }, new String[] { "your.*", PatternMatcher.ANY_EXPRESSION });
    assertDependencyArtifactIncludeRules(dd, new String[] { "myconf2" }, new String[] { "your.*", PatternMatcher.ANY_EXPRESSION });
    assertDependencyArtifactIncludeRules(dd, new String[] { "myconf3" }, new String[] { "your.*", PatternMatcher.ANY_EXPRESSION });
    assertDependencyArtifactIncludeRules(dd, new String[] { "myconf4" }, new String[] { "your.*", PatternMatcher.ANY_EXPRESSION });
    assertDependencyArtifactExcludeRules(dd, new String[] { "myconf1" }, new String[] { "toexclude" });
    assertDependencyArtifactExcludeRules(dd, new String[] { "myconf2" }, new String[] { "toexclude" });
    assertDependencyArtifactExcludeRules(dd, new String[] { "myconf3" }, new String[] { "toexclude" });
    assertDependencyArtifactExcludeRules(dd, new String[] { "myconf4" }, new String[] { "toexclude" });
    ConflictManager cm = md.getConflictManager(new ModuleId("yourorg", "yourmodule1"));
    assertNotNull(cm);
    assertTrue(cm instanceof NoConflictManager);
    cm = md.getConflictManager(new ModuleId("yourorg", "yourmodule2"));
    assertNotNull(cm);
    assertTrue(cm instanceof NoConflictManager);
    cm = md.getConflictManager(new ModuleId("theirorg", "theirmodule1"));
    assertNotNull(cm);
    assertTrue(cm instanceof FixedConflictManager);
    FixedConflictManager fcm = (FixedConflictManager) cm;
    assertEquals(2, fcm.getRevs().size());
    assertTrue(fcm.getRevs().contains("1.0"));
    assertTrue(fcm.getRevs().contains("1.1"));
    cm = md.getConflictManager(new ModuleId("theirorg", "theirmodule2"));
    assertNull(cm);
    assertEquals(ModuleRevisionId.parse("yourorg#yourmodule1#BRANCH;1.0"), md.mediate(new DefaultDependencyDescriptor(ModuleRevisionId.parse("yourorg#yourmodule1;2.0"), false)).getDependencyRevisionId());
    ExcludeRule[] rules = md.getAllExcludeRules();
    assertNotNull(rules);
    assertEquals(2, rules.length);
    assertEquals(GlobPatternMatcher.INSTANCE, rules[0].getMatcher());
    assertEquals(ExactPatternMatcher.INSTANCE, rules[1].getMatcher());
    assertEquals(Collections.singletonList("myconf1"), Arrays.asList(rules[0].getConfigurations()));
    assertEquals(Arrays.asList("myconf1", "myconf2", "myconf3", "myconf4", "myoldconf"), Arrays.asList(rules[1].getConfigurations()));
}
Also used : Configuration(org.apache.ivy.core.module.descriptor.Configuration) DependencyDescriptor(org.apache.ivy.core.module.descriptor.DependencyDescriptor) DefaultDependencyDescriptor(org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor) ExtraInfoHolder(org.apache.ivy.core.module.descriptor.ExtraInfoHolder) GregorianCalendar(java.util.GregorianCalendar) License(org.apache.ivy.core.module.descriptor.License) FixedConflictManager(org.apache.ivy.plugins.conflict.FixedConflictManager) ExcludeRule(org.apache.ivy.core.module.descriptor.ExcludeRule) Date(java.util.Date) ModuleDescriptor(org.apache.ivy.core.module.descriptor.ModuleDescriptor) ModuleId(org.apache.ivy.core.module.id.ModuleId) NoConflictManager(org.apache.ivy.plugins.conflict.NoConflictManager) DefaultDependencyDescriptor(org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor) NoConflictManager(org.apache.ivy.plugins.conflict.NoConflictManager) FixedConflictManager(org.apache.ivy.plugins.conflict.FixedConflictManager) ConflictManager(org.apache.ivy.plugins.conflict.ConflictManager) Test(org.junit.Test)

Example 54 with DefaultDependencyDescriptor

use of org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor in project ant-ivy by apache.

the class ChainResolverTest method testDual.

@Test
public void testDual() throws Exception {
    ChainResolver chain = new ChainResolver();
    chain.setName("chain");
    chain.setSettings(settings);
    chain.setDual(true);
    MockResolver[] resolvers = new MockResolver[] { MockResolver.buildMockResolver(settings, "1", false, null), MockResolver.buildMockResolver(settings, "2", true, null), MockResolver.buildMockResolver(settings, "3", true, null) };
    for (MockResolver resolver : resolvers) {
        chain.add(resolver);
    }
    assertResolversSizeAndNames(chain, resolvers.length);
    DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(ModuleRevisionId.newInstance("org", "mod", "rev"), false);
    ResolvedModuleRevision rmr = chain.getDependency(dd, data);
    assertNotNull(rmr);
    assertEquals("2", rmr.getResolver().getName());
    assertEquals("chain", rmr.getArtifactResolver().getName());
}
Also used : ResolvedModuleRevision(org.apache.ivy.core.resolve.ResolvedModuleRevision) DefaultDependencyDescriptor(org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor) Test(org.junit.Test)

Example 55 with DefaultDependencyDescriptor

use of org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor in project ant-ivy by apache.

the class DualResolverTest method testResolve.

@Test
public void testResolve() throws Exception {
    DualResolver dual = new DualResolver();
    MockResolver ivyResolver = MockResolver.buildMockResolver(settings, "ivy", true, new GregorianCalendar(2005, 1, 20).getTime());
    MockResolver artifactResolver = MockResolver.buildMockResolver(settings, "artifact", false, new GregorianCalendar(2005, 1, 20).getTime());
    dual.setIvyResolver(ivyResolver);
    dual.setArtifactResolver(artifactResolver);
    DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(ModuleRevisionId.newInstance("org", "mod", "rev"), false);
    ResolvedModuleRevision rmr = dual.getDependency(dd, data);
    assertNotNull(rmr);
    assertEquals(dual, rmr.getArtifactResolver());
    assertEquals(Collections.<DependencyDescriptor>singletonList(dd), ivyResolver.askedDeps);
    assertTrue(artifactResolver.askedDeps.isEmpty());
}
Also used : GregorianCalendar(java.util.GregorianCalendar) ResolvedModuleRevision(org.apache.ivy.core.resolve.ResolvedModuleRevision) DefaultDependencyDescriptor(org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor) Test(org.junit.Test)

Aggregations

DefaultDependencyDescriptor (org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor)80 ResolvedModuleRevision (org.apache.ivy.core.resolve.ResolvedModuleRevision)61 Test (org.junit.Test)60 ModuleRevisionId (org.apache.ivy.core.module.id.ModuleRevisionId)47 GregorianCalendar (java.util.GregorianCalendar)25 Date (java.util.Date)23 Artifact (org.apache.ivy.core.module.descriptor.Artifact)23 File (java.io.File)22 ArtifactDownloadReport (org.apache.ivy.core.report.ArtifactDownloadReport)19 DownloadReport (org.apache.ivy.core.report.DownloadReport)18 DefaultArtifact (org.apache.ivy.core.module.descriptor.DefaultArtifact)16 DependencyDescriptor (org.apache.ivy.core.module.descriptor.DependencyDescriptor)12 DefaultModuleDescriptor (org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor)9 DownloadOptions (org.apache.ivy.core.resolve.DownloadOptions)9 LatestRevisionStrategy (org.apache.ivy.plugins.latest.LatestRevisionStrategy)7 Configuration (org.apache.ivy.core.module.descriptor.Configuration)6 ModuleDescriptor (org.apache.ivy.core.module.descriptor.ModuleDescriptor)5 ModuleId (org.apache.ivy.core.module.id.ModuleId)5 BufferedReader (java.io.BufferedReader)3 Locale (java.util.Locale)3