Java Code Examples for org.apache.ivy.plugins.resolver.DependencyResolver#getDependency()

The following examples show how to use org.apache.ivy.plugins.resolver.DependencyResolver#getDependency() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ResolveEngine.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
public ResolvedModuleRevision findModule(ModuleRevisionId id, ResolveOptions options) {
    DependencyResolver r = settings.getResolver(id);
    if (r == null) {
        throw new IllegalStateException("no resolver found for " + id.getModuleId());
    }
    DefaultModuleDescriptor md = DefaultModuleDescriptor.newCallerInstance(id,
        new String[] {"*"}, false, false);

    if (options.getResolveId() == null) {
        options.setResolveId(ResolveOptions.getDefaultResolveId(md));
    }

    try {
        return r.getDependency(new DefaultDependencyDescriptor(id, true), new ResolveData(this,
                options, new ConfigurationResolveReport(this, md, "default", null, options)));
    } catch (ParseException e) {
        throw new RuntimeException("problem while parsing repository module descriptor for "
                + id + ": " + e, e);
    }
}
 
Example 2
Source File: UpdateSiteResolverTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
private void genericTestResolveDownload(DependencyResolver resolver, ModuleRevisionId mrid)
        throws ParseException {
    ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid,
            false), data);
    assertNotNull(rmr);
    assertEquals(mrid, rmr.getId());

    Artifact artifact = rmr.getDescriptor().getAllArtifacts()[0];
    DownloadReport report = resolver.download(new Artifact[] {artifact}, new DownloadOptions());
    assertNotNull(report);

    assertEquals(1, report.getArtifactsReports().length);

    ArtifactDownloadReport ar = report.getArtifactReport(artifact);
    assertNotNull(ar);

    assertEquals(artifact, ar.getArtifact());
    assertEquals(DownloadStatus.SUCCESSFUL, ar.getDownloadStatus());

    // test to ask to download again, should use cache
    report = resolver.download(new Artifact[] {artifact}, new DownloadOptions());
    assertNotNull(report);

    assertEquals(1, report.getArtifactsReports().length);

    ar = report.getArtifactReport(artifact);
    assertNotNull(ar);

    assertEquals(artifact, ar.getArtifact());
    assertEquals(DownloadStatus.NO, ar.getDownloadStatus());
}
 
Example 3
Source File: OBRResolverTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
private void genericTestResolveDownload(DependencyResolver resolver, ModuleRevisionId mrid)
        throws ParseException {
    ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid,
            false), data);
    assertNotNull(rmr);
    assertEquals(mrid, rmr.getId());

    Artifact artifact = rmr.getDescriptor().getAllArtifacts()[0];
    DownloadReport report = resolver.download(new Artifact[] {artifact}, new DownloadOptions());
    assertNotNull(report);

    assertEquals(1, report.getArtifactsReports().length);

    ArtifactDownloadReport ar = report.getArtifactReport(artifact);
    assertNotNull(ar);

    assertEquals(artifact, ar.getArtifact());
    assertEquals(DownloadStatus.SUCCESSFUL, ar.getDownloadStatus());

    // test to ask to download again, should use cache
    report = resolver.download(new Artifact[] {artifact}, new DownloadOptions());
    assertNotNull(report);

    assertEquals(1, report.getArtifactsReports().length);

    ar = report.getArtifactReport(artifact);
    assertNotNull(ar);

    assertEquals(artifact, ar.getArtifact());
    assertEquals(DownloadStatus.NO, ar.getDownloadStatus());
}
 
Example 4
Source File: AggregatedOSGiResolverTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
private void genericTestResolveDownload(DependencyResolver resolver, ModuleRevisionId mrid)
        throws ParseException {
    ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid,
            false), data);
    assertNotNull(rmr);
    assertEquals(mrid, rmr.getId());

    Artifact artifact = rmr.getDescriptor().getAllArtifacts()[0];
    DownloadReport report = resolver.download(new Artifact[] {artifact}, new DownloadOptions());
    assertNotNull(report);

    assertEquals(1, report.getArtifactsReports().length);

    ArtifactDownloadReport ar = report.getArtifactReport(artifact);
    assertNotNull(ar);

    assertEquals(artifact, ar.getArtifact());
    assertEquals(DownloadStatus.SUCCESSFUL, ar.getDownloadStatus());

    // test to ask to download again, should use cache
    report = resolver.download(new Artifact[] {artifact}, new DownloadOptions());
    assertNotNull(report);

    assertEquals(1, report.getArtifactsReports().length);

    ar = report.getArtifactReport(artifact);
    assertNotNull(ar);

    assertEquals(artifact, ar.getArtifact());
    assertEquals(DownloadStatus.NO, ar.getDownloadStatus());
}