Search in sources :

Example 86 with ResolvedModuleRevision

use of org.apache.ivy.core.resolve.ResolvedModuleRevision in project ant-ivy by apache.

the class URLResolverTest method testLatestFile.

@Test
public void testLatestFile() throws Exception {
    URLResolver resolver = new URLResolver();
    resolver.setSettings(settings);
    String rootpath = new File("test/repositories/1").toURI().toURL().toExternalForm();
    resolver.addIvyPattern(rootpath + "[organisation]/[module]/ivys/ivy-[revision].xml");
    resolver.addArtifactPattern(rootpath + "[organisation]/[module]/[type]s/[artifact]-[revision].[type]");
    resolver.setName("test");
    assertEquals("test", resolver.getName());
    ModuleRevisionId mrid = ModuleRevisionId.newInstance("org1", "mod1.1", "2.0");
    ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(ModuleRevisionId.newInstance("org1", "mod1.1", "latest.integration"), false), data);
    assertNotNull(rmr);
    assertEquals(mrid, rmr.getId());
    Date pubdate = new GregorianCalendar(2005, 1, 15, 11, 0, 0).getTime();
    assertEquals(pubdate, rmr.getPublicationDate());
}
Also used : GregorianCalendar(java.util.GregorianCalendar) ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) ResolvedModuleRevision(org.apache.ivy.core.resolve.ResolvedModuleRevision) DefaultDependencyDescriptor(org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor) File(java.io.File) Date(java.util.Date) Test(org.junit.Test)

Example 87 with ResolvedModuleRevision

use of org.apache.ivy.core.resolve.ResolvedModuleRevision in project ant-ivy by apache.

the class PomModuleDescriptorParser method addTo.

private void addTo(PomModuleDescriptorBuilder mdBuilder, PomDependencyMgt dep, ParserSettings ivySettings) throws ParseException, IOException {
    if ("import".equals(dep.getScope())) {
        ModuleRevisionId importModRevID = ModuleRevisionId.newInstance(dep.getGroupId(), dep.getArtifactId(), dep.getVersion());
        ResolvedModuleRevision importModule = parseOtherPom(ivySettings, importModRevID);
        if (importModule == null) {
            throw new IOException("Impossible to import module for " + mdBuilder.getModuleDescriptor().getResource().getName() + ". Import=" + importModRevID);
        }
        ModuleDescriptor importDescr = importModule.getDescriptor();
        // add dependency management info from imported module
        for (PomDependencyMgt importedDepMgt : getDependencyManagements(importDescr)) {
            mdBuilder.addDependencyMgt(new DefaultPomDependencyMgt(importedDepMgt.getGroupId(), importedDepMgt.getArtifactId(), importedDepMgt.getVersion(), importedDepMgt.getScope(), importedDepMgt.getExcludedModules()));
        }
    } else {
        mdBuilder.addDependencyMgt(dep);
    }
}
Also used : ModuleDescriptor(org.apache.ivy.core.module.descriptor.ModuleDescriptor) ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) ResolvedModuleRevision(org.apache.ivy.core.resolve.ResolvedModuleRevision) IOException(java.io.IOException)

Example 88 with ResolvedModuleRevision

use of org.apache.ivy.core.resolve.ResolvedModuleRevision in project ant-ivy by apache.

the class CacheResolver method getDependency.

@Override
public ResolvedModuleRevision getDependency(DependencyDescriptor dd, ResolveData data) throws ParseException {
    clearIvyAttempts();
    ModuleRevisionId mrid = dd.getDependencyRevisionId();
    // check revision
    ResolvedModuleRevision rmr = getRepositoryCacheManager().findModuleInCache(dd, mrid, getCacheOptions(data), null);
    if (rmr != null) {
        Message.verbose("\t" + getName() + ": revision in cache: " + mrid);
        return rmr;
    } else if (!getSettings().getVersionMatcher().isDynamic(mrid)) {
        Message.verbose("\t" + getName() + ": no ivy file in cache found for " + mrid);
        return null;
    } else {
        ensureConfigured();
        ResolvedResource ivyRef = findIvyFileRef(dd, data);
        if (ivyRef != null) {
            Message.verbose("\t" + getName() + ": found ivy file in cache for " + mrid);
            Message.verbose("\t\t=> " + ivyRef);
            ModuleRevisionId resolvedMrid = ModuleRevisionId.newInstance(mrid, ivyRef.getRevision());
            IvyNode node = data.getNode(resolvedMrid);
            if (node != null && node.getModuleRevision() != null) {
                // this revision has already be resolved : return it
                Message.verbose("\t" + getName() + ": revision already resolved: " + resolvedMrid);
                return node.getModuleRevision();
            }
            rmr = getRepositoryCacheManager().findModuleInCache(dd.clone(ModuleRevisionId.newInstance(dd.getDependencyRevisionId(), ivyRef.getRevision())), dd.getDependencyRevisionId(), getCacheOptions(data), null);
            if (rmr != null) {
                Message.verbose("\t" + getName() + ": revision in cache: " + resolvedMrid);
                return rmr;
            } else {
                Message.error("\t" + getName() + ": inconsistent cache: clean it and resolve again");
                return null;
            }
        } else {
            Message.verbose("\t" + getName() + ": no ivy file in cache found for " + mrid);
            return null;
        }
    }
}
Also used : ResolvedResource(org.apache.ivy.plugins.resolver.util.ResolvedResource) ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) ResolvedModuleRevision(org.apache.ivy.core.resolve.ResolvedModuleRevision) IvyNode(org.apache.ivy.core.resolve.IvyNode)

Example 89 with ResolvedModuleRevision

use of org.apache.ivy.core.resolve.ResolvedModuleRevision in project ant-ivy by apache.

the class AbstractResolver method checkLatest.

protected ResolvedModuleRevision checkLatest(DependencyDescriptor dd, ResolvedModuleRevision newModuleFound, ResolveData data) {
    Checks.checkNotNull(dd, "dd");
    Checks.checkNotNull(data, "data");
    // always cache dynamic mrids because we can store per-resolver values
    saveModuleRevisionIfNeeded(dd, newModuleFound);
    // check if latest is asked and compare to return the most recent
    ResolvedModuleRevision previousModuleFound = data.getCurrentResolvedModuleRevision();
    String newModuleDesc = describe(newModuleFound);
    Message.debug("\tchecking " + newModuleDesc + " against " + describe(previousModuleFound));
    if (previousModuleFound == null) {
        Message.debug("\tmodule revision kept as first found: " + newModuleDesc);
        return newModuleFound;
    } else if (isAfter(newModuleFound, previousModuleFound, data.getDate())) {
        Message.debug("\tmodule revision kept as younger: " + newModuleDesc);
        return newModuleFound;
    } else if (!newModuleFound.getDescriptor().isDefault() && previousModuleFound.getDescriptor().isDefault()) {
        Message.debug("\tmodule revision kept as better (not default): " + newModuleDesc);
        return newModuleFound;
    } else {
        Message.debug("\tmodule revision discarded as older: " + newModuleDesc);
        return previousModuleFound;
    }
}
Also used : ResolvedModuleRevision(org.apache.ivy.core.resolve.ResolvedModuleRevision)

Aggregations

ResolvedModuleRevision (org.apache.ivy.core.resolve.ResolvedModuleRevision)89 Test (org.junit.Test)63 DefaultDependencyDescriptor (org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor)61 ModuleRevisionId (org.apache.ivy.core.module.id.ModuleRevisionId)45 Artifact (org.apache.ivy.core.module.descriptor.Artifact)25 GregorianCalendar (java.util.GregorianCalendar)24 File (java.io.File)19 ArtifactDownloadReport (org.apache.ivy.core.report.ArtifactDownloadReport)19 Date (java.util.Date)18 DefaultArtifact (org.apache.ivy.core.module.descriptor.DefaultArtifact)18 DependencyDescriptor (org.apache.ivy.core.module.descriptor.DependencyDescriptor)18 DownloadReport (org.apache.ivy.core.report.DownloadReport)18 ModuleDescriptor (org.apache.ivy.core.module.descriptor.ModuleDescriptor)17 IOException (java.io.IOException)14 ParseException (java.text.ParseException)14 DefaultModuleDescriptor (org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor)13 ResolveData (org.apache.ivy.core.resolve.ResolveData)11 MockResolver (org.apache.ivy.plugins.resolver.MockResolver)9 MetadataArtifactDownloadReport (org.apache.ivy.core.report.MetadataArtifactDownloadReport)8 DownloadOptions (org.apache.ivy.core.resolve.DownloadOptions)8