org.apache.ivy.core.resolve.ResolveData Java Examples

The following examples show how to use org.apache.ivy.core.resolve.ResolveData. 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: LatestCompatibleConflictManager.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@Override
public void handleAllBlacklistedRevisions(DependencyDescriptor dd,
        Collection<ModuleRevisionId> foundBlacklisted) {
    ResolveData resolveData = IvyContext.getContext().getResolveData();
    Collection<IvyNode> blacklisted = new HashSet<>();
    for (ModuleRevisionId mrid : foundBlacklisted) {
        blacklisted.add(resolveData.getNode(mrid));
    }

    for (IvyNode node : blacklisted) {
        IvyNodeBlacklist bdata = node.getBlacklistData(resolveData.getReport()
                .getConfiguration());
        handleUnsolvableConflict(bdata.getConflictParent(),
            Arrays.asList(bdata.getEvictedNode(), bdata.getSelectedNode()),
            bdata.getEvictedNode(), bdata.getSelectedNode());
    }
}
 
Example #2
Source File: BasicResolver.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
protected ResourceMDParser getRMDParser(final DependencyDescriptor dd, final ResolveData data) {
    return new ResourceMDParser() {
        public MDResolvedResource parse(Resource resource, String rev) {
            try {
                ResolvedModuleRevision rmr = BasicResolver.this.parse(new ResolvedResource(
                        resource, rev), dd, data);
                if (rmr != null) {
                    return new MDResolvedResource(resource, rev, rmr);
                }
            } catch (ParseException e) {
                Message.warn("Failed to parse the file '" + resource + "'", e);
            }
            return null;
        }

    };
}
 
Example #3
Source File: MirroredURLResolverTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
    settings = new IvySettings();
    engine = new ResolveEngine(settings, new EventManager(), new SortEngine(settings));
    data = new ResolveData(engine, new ResolveOptions());
    TestHelper.createCache();
    settings.setDefaultCache(TestHelper.cache);
    settings.setVariable("test.mirroredurl.mirrorlist-solo.url",
        this.getClass().getResource("mirrorlist-solo.txt").toExternalForm());
    settings.setVariable("test.mirroredurl.mirrorlist-failover.url", this.getClass()
            .getResource("mirrorlist-failover.txt").toExternalForm());
    settings.setVariable("test.mirroredurl.mirrorlist-fail.url",
        this.getClass().getResource("mirrorlist-fail.txt").toExternalForm());
    new XmlSettingsParser(settings).parse(MirroredURLResolverTest.class
            .getResource("mirror-resolver-settings.xml"));
}
 
Example #4
Source File: BasicResolver.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
private void resolveAndCheckPublicationDate(DependencyDescriptor systemDd,
        ModuleDescriptor systemMd, ModuleRevisionId systemMrid, ResolveData data) {
    if (data.getDate() == null) {
        return;
    }
    // resolve and check publication date
    long pubDate = getPublicationDate(systemMd, systemDd, data);
    if (pubDate > data.getDate().getTime()) {
        throw new UnresolvedDependencyException("\t" + getName()
                + ": unacceptable publication date => was=" + new Date(pubDate)
                + " required=" + data.getDate());
    }
    if (pubDate == -1) {
        throw new UnresolvedDependencyException("\t" + getName()
                + ": impossible to guess publication date: artifact missing for "
                + systemMrid);
    }
    systemMd.setResolvedPublicationDate(new Date(pubDate));
}
 
Example #5
Source File: LoopbackDependencyResolver.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public ResolvedModuleRevision getDependency(final DependencyDescriptor dd, final ResolveData data) throws ParseException {
    final DependencyResolver loopback = this;
    return cacheLockingManager.useCache(String.format("Resolve %s", dd), new Factory<ResolvedModuleRevision>() {
        public ResolvedModuleRevision create() {
            DefaultBuildableComponentResolveResult result = new DefaultBuildableComponentResolveResult();
            DefaultDependencyMetaData dependency = new DefaultDependencyMetaData(dd);
            IvyContext ivyContext = IvyContext.pushNewCopyContext();
            try {
                ivyContext.setResolveData(data);
                dependencyResolver.resolve(dependency, result);
            } finally {
                IvyContext.popContext();
            }
            return new ResolvedModuleRevision(loopback, loopback, result.getMetaData().getDescriptor(), null);
        }
    });
}
 
Example #6
Source File: PackagerResolverTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
    Message.setDefaultLogger(new DefaultMessageLogger(99));

    settings = new IvySettings();
    ResolveEngine engine = new ResolveEngine(settings, new EventManager(), new SortEngine(
            settings));
    cache = new File("build/cache");
    data = new ResolveData(engine, new ResolveOptions());
    cache.mkdirs();
    settings.setDefaultCache(cache);

    // Create work space with build and resource cache directories
    workdir = new File("build/test/PackagerResolverTest");
    builddir = new File(workdir, "build");
    cachedir = new File(workdir, "resources");
    cleanupTempDirs();
    if (!builddir.mkdirs() || !cachedir.mkdirs()) {
        throw new Exception("can't create directories under " + workdir);
    }
}
 
Example #7
Source File: LoopbackDependencyResolver.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public ResolvedModuleRevision getDependency(final DependencyDescriptor dd, final ResolveData data) throws ParseException {
    final DependencyResolver loopback = this;
    return cacheLockingManager.useCache(String.format("Resolve %s", dd), new Factory<ResolvedModuleRevision>() {
        public ResolvedModuleRevision create() {
            DefaultBuildableComponentResolveResult result = new DefaultBuildableComponentResolveResult();
            DefaultDependencyMetaData dependency = new DefaultDependencyMetaData(dd);
            IvyContext ivyContext = IvyContext.pushNewCopyContext();
            try {
                ivyContext.setResolveData(data);
                dependencyResolver.resolve(dependency, result);
            } finally {
                IvyContext.popContext();
            }
            return new ResolvedModuleRevision(loopback, loopback, result.getMetaData().getDescriptor(), null);
        }
    });
}
 
Example #8
Source File: IBiblioResolver.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@Override
public ResolvedResource findIvyFileRef(DependencyDescriptor dd, ResolveData data) {
    if (!isM2compatible() || !isUsepoms()) {
        return null;
    }
    ModuleRevisionId mrid = dd.getDependencyRevisionId();
    mrid = convertM2IdForResourceSearch(mrid);
    final String revision = dd.getDependencyRevisionId().getRevision();
    final MavenTimedSnapshotVersionMatcher.MavenSnapshotRevision snapshotRevision = MavenTimedSnapshotVersionMatcher.computeIfSnapshot(revision);
    if (snapshotRevision != null) {
        final ResolvedResource rres = findSnapshotDescriptor(dd, data, mrid, snapshotRevision);
        if (rres != null) {
            return rres;
        }
    }
    return findResourceUsingPatterns(mrid, getIvyPatterns(),
            DefaultArtifact.newPomArtifact(mrid, data.getDate()), getRMDParser(dd, data),
            data.getDate());
}
 
Example #9
Source File: JarResolverTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() {
    settings = new IvySettings();
    engine = new ResolveEngine(settings, new EventManager(), new SortEngine(settings));
    cache = new File("build/cache");
    data = new ResolveData(engine, new ResolveOptions());
    cache.mkdirs();
    settings.setDefaultCache(cache);
    cacheManager = (DefaultRepositoryCacheManager) settings.getDefaultRepositoryCacheManager();
}
 
Example #10
Source File: ResolveIvyFactory.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void ivyContextualize(IvyAwareModuleVersionRepository ivyAwareRepository, RepositoryChain userResolverChain, String configurationName) {
    Ivy ivy = IvyContext.getContext().getIvy();
    IvySettings ivySettings = ivy.getSettings();
    LoopbackDependencyResolver loopbackDependencyResolver = new LoopbackDependencyResolver("main", userResolverChain, cacheLockingManager);
    ivySettings.addResolver(loopbackDependencyResolver);
    ivySettings.setDefaultResolver(loopbackDependencyResolver.getName());

    ResolveData resolveData = createResolveData(ivy, configurationName);
    ivyAwareRepository.setSettings(ivySettings);
    ivyAwareRepository.setResolveData(resolveData);
}
 
Example #11
Source File: IvyRepResolverTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() {
    settings = new IvySettings();
    engine = new ResolveEngine(settings, new EventManager(), new SortEngine(settings));
    data = new ResolveData(engine, new ResolveOptions());
    TestHelper.createCache();
    settings.setDefaultCache(TestHelper.cache);
}
 
Example #12
Source File: PomModuleDescriptorParserTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
@Test
public void testParentBomImport() throws ParseException, IOException {
    settings.setDictatorResolver(new MockResolver() {
        public ResolvedModuleRevision getDependency(DependencyDescriptor dd, ResolveData data)
                throws ParseException {
            try {
                ModuleDescriptor moduleDescriptor = PomModuleDescriptorParser.getInstance()
                        .parseDescriptor(settings,
                            getClass().getResource(
                                String.format("depmgt/%s.pom", dd.getDependencyId().getName())),
                            false);
                return new ResolvedModuleRevision(null, null, moduleDescriptor, null);
            } catch (IOException e) {
                throw new AssertionError(e);
            }
        }
    });
    ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings,
        getClass().getResource("depmgt/child.pom"), false);
    assertNotNull(md);
    assertEquals("1.0", md.getRevision());

    DependencyDescriptor[] dds = md.getDependencies();
    assertNotNull(dds);
    assertEquals(1, dds.length);

    assertEquals(ModuleRevisionId.newInstance("commons-logging", "commons-logging", "1.0.4"),
        dds[0].getDependencyRevisionId());
}
 
Example #13
Source File: AbstractLogCircularDependencyStrategy.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
protected String getCircularDependencyId(ModuleRevisionId[] mrids) {
    String contextPrefix = "";
    ResolveData data = IvyContext.getContext().getResolveData();
    if (data != null) {
        contextPrefix = data.getOptions().getResolveId() + " ";
    }
    return contextPrefix + Arrays.asList(mrids);
}
 
Example #14
Source File: PomModuleDescriptorParserTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
@Test
public void testOverrideGrandparentProperties() throws ParseException, IOException {
    settings.setDictatorResolver(new MockResolver() {
        public ResolvedModuleRevision getDependency(DependencyDescriptor dd, ResolveData data)
                throws ParseException {
            String resource;
            if ("test".equals(dd.getDependencyId().getName())) {
                resource = "test-parent-properties.pom";
            } else {
                resource = "test-version.pom";
            }
            try {
                ModuleDescriptor moduleDescriptor = PomModuleDescriptorParser.getInstance()
                        .parseDescriptor(settings, getClass().getResource(resource), false);
                return new ResolvedModuleRevision(null, null, moduleDescriptor, null);
            } catch (IOException e) {
                throw new AssertionError(e);
            }
        }
    });

    ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings,
        getClass().getResource("test-override-grandparent-properties.pom"), false);
    assertNotNull(md);
    assertEquals("1.0", md.getRevision());

    DependencyDescriptor[] dds = md.getDependencies();
    assertNotNull(dds);
    assertEquals(3, dds.length);

    assertEquals(ModuleRevisionId.newInstance("org.apache", "test-version-other", "5.79"),
        dds[0].getDependencyRevisionId());
    assertEquals(ModuleRevisionId.newInstance("org.apache", "test-yet-other", "5.79"),
        dds[2].getDependencyRevisionId());
}
 
Example #15
Source File: PomModuleDescriptorParserTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
@Test
public void testOverrideParentProperties() throws ParseException, IOException {
    settings.setDictatorResolver(new MockResolver() {
        public ResolvedModuleRevision getDependency(DependencyDescriptor dd, ResolveData data)
                throws ParseException {
            try {
                ModuleDescriptor moduleDescriptor = PomModuleDescriptorParser.getInstance()
                        .parseDescriptor(settings, getClass().getResource("test-version.pom"),
                            false);
                return new ResolvedModuleRevision(null, null, moduleDescriptor, null);
            } catch (IOException e) {
                throw new AssertionError(e);
            }
        }
    });
    ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings,
        getClass().getResource("test-override-parent-properties.pom"), false);
    assertNotNull(md);
    assertEquals("1.0", md.getRevision());

    DependencyDescriptor[] dds = md.getDependencies();
    assertNotNull(dds);
    assertEquals(2, dds.length);
    // 2 are inherited from parent. Only the first one is important for this test

    assertEquals(ModuleRevisionId.newInstance("org.apache", "test-yet-other", "5.79"),
        dds[1].getDependencyRevisionId());
}
 
Example #16
Source File: PomModuleDescriptorParserTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
@Test
public void testParentProperties() throws ParseException, IOException {
    settings.setDictatorResolver(new MockResolver() {
        public ResolvedModuleRevision getDependency(DependencyDescriptor dd, ResolveData data)
                throws ParseException {
            try {
                ModuleDescriptor moduleDescriptor = PomModuleDescriptorParser.getInstance()
                        .parseDescriptor(settings, getClass().getResource("test-version.pom"),
                            false);
                return new ResolvedModuleRevision(null, null, moduleDescriptor, null);
            } catch (IOException e) {
                throw new AssertionError(e);
            }
        }
    });

    ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings,
        getClass().getResource("test-parent-properties.pom"), false);
    assertNotNull(md);
    assertEquals("1.0", md.getRevision());

    DependencyDescriptor[] dds = md.getDependencies();
    assertNotNull(dds);
    assertEquals(3, dds.length);
    // 2 are inherited from parent. Only the first one is important for this test

    assertEquals(ModuleRevisionId.newInstance("org.apache", "test-version-other", "5.76"),
        dds[0].getDependencyRevisionId());
    // present in the pom using a property defined in the parent
}
 
Example #17
Source File: BasicResolver.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
private void checkNotConvertedExclusionRule(ModuleDescriptor systemMd, ResolvedResource ivyRef,
        ResolveData data) {
    if (!getNamespace().equals(Namespace.SYSTEM_NAMESPACE) && !systemMd.isDefault()
            && data.getSettings().logNotConvertedExclusionRule()
            && systemMd instanceof DefaultModuleDescriptor) {
        DefaultModuleDescriptor dmd = (DefaultModuleDescriptor) systemMd;
        if (dmd.isNamespaceUseful()) {
            Message.warn("the module descriptor " + ivyRef.getResource()
                    + " has information which can't be converted into the system namespace. It will require the availability of the namespace '"
                    + getNamespace().getName() + "' to be fully usable.");
        }
    }
}
 
Example #18
Source File: PomModuleDescriptorParserTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
@Test
public void testParentProfileBomImport() throws ParseException, IOException {
    settings.setDictatorResolver(new MockResolver() {
        public ResolvedModuleRevision getDependency(DependencyDescriptor dd, ResolveData data)
                throws ParseException {
            try {
                ModuleDescriptor moduleDescriptor = PomModuleDescriptorParser.getInstance()
                        .parseDescriptor(settings,
                            getClass().getResource(
                                String.format("depmgt/%s.pom", dd.getDependencyId().getName())),
                            false);
                return new ResolvedModuleRevision(null, null, moduleDescriptor, null);
            } catch (IOException e) {
                throw new AssertionError(e);
            }
        }
    });
    ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings,
        getClass().getResource("depmgt/profile-parent-child.pom"), false);
    assertNotNull(md);
    assertEquals("1.0", md.getRevision());

    DependencyDescriptor[] dds = md.getDependencies();
    assertNotNull(dds);
    assertEquals(1, dds.length);

    assertEquals(ModuleRevisionId.newInstance("commons-logging", "commons-logging", "1.0.4"),
        dds[0].getDependencyRevisionId());
}
 
Example #19
Source File: Maven2LocalTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() {
    settings = new IvySettings();
    engine = new ResolveEngine(settings, new EventManager(), new SortEngine(settings));
    cache = new File("build/cache");
    data = new ResolveData(engine, new ResolveOptions());
    cache.mkdirs();
    settings.setDefaultCache(cache);
}
 
Example #20
Source File: BasicResolver.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
protected long getPublicationDate(ModuleDescriptor md, DependencyDescriptor dd, ResolveData data) {
    if (md.getPublicationDate() != null) {
        return md.getPublicationDate().getTime();
    }
    ResolvedResource artifactRef = findFirstArtifactRef(md, dd, data);
    if (artifactRef != null) {
        return artifactRef.getLastModified();
    }
    return -1;
}
 
Example #21
Source File: BasicResolver.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
protected ResolvedResource findFirstArtifactRef(ModuleDescriptor md, DependencyDescriptor dd,
        ResolveData data) {
    for (String configName : md.getConfigurationsNames()) {
        for (Artifact artifact : md.getArtifacts(configName)) {
            ResolvedResource ret = getArtifactRef(artifact, data.getDate());
            if (ret != null) {
                return ret;
            }
        }
    }
    return null;
}
 
Example #22
Source File: PomModuleDescriptorParserTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
@Test
public void testParentDependencyMgt() throws ParseException, IOException {
    settings.setDictatorResolver(new MockResolver() {
        public ResolvedModuleRevision getDependency(DependencyDescriptor dd, ResolveData data)
                throws ParseException {
            try {
                ModuleDescriptor moduleDescriptor = PomModuleDescriptorParser.getInstance()
                        .parseDescriptor(settings,
                            getClass().getResource("test-dependencyMgt.pom"), false);
                return new ResolvedModuleRevision(null, null, moduleDescriptor, null);
            } catch (IOException e) {
                throw new AssertionError(e);
            }
        }
    });

    ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings,
        getClass().getResource("test-parentDependencyMgt.pom"), false);
    assertNotNull(md);
    assertEquals(ModuleRevisionId.newInstance("org.apache", "test-parentdep", "1.0"),
        md.getModuleRevisionId());

    DependencyDescriptor[] dds = md.getDependencies();
    assertNotNull(dds);
    assertEquals(2, dds.length);
    assertEquals(
        ModuleRevisionId.newInstance("commons-collection", "commons-collection", "1.0.5"),
        dds[0].getDependencyRevisionId());
    assertEquals(ModuleRevisionId.newInstance("commons-logging", "commons-logging", "1.0.4"),
        dds[1].getDependencyRevisionId());

    ExcludeRule[] excludes = dds[0].getAllExcludeRules();
    assertNotNull(excludes);
    assertEquals(2, excludes.length);
    assertEquals("javax.mail", excludes[0].getId().getModuleId().getOrganisation());
    assertEquals("mail", excludes[0].getId().getModuleId().getName());
    assertEquals("javax.jms", excludes[1].getId().getModuleId().getOrganisation());
    assertEquals("jms", excludes[1].getId().getModuleId().getName());
}
 
Example #23
Source File: ChainResolver.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
public ResolvedResource findIvyFileRef(DependencyDescriptor dd, ResolveData data) {
    for (DependencyResolver resolver : chain) {
        ResolvedResource result = resolver.findIvyFileRef(dd, data);
        if (result != null) {
            return result;
        }
    }
    return null;
}
 
Example #24
Source File: AbstractPatternsBasedResolver.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
public ResolvedResource findIvyFileRef(DependencyDescriptor dd, ResolveData data) {
    ModuleRevisionId mrid = dd.getDependencyRevisionId();
    if (isM2compatible()) {
        mrid = convertM2IdForResourceSearch(mrid);
    }
    return findResourceUsingPatterns(mrid, ivyPatterns,
        DefaultArtifact.newIvyArtifact(mrid, data.getDate()), getRMDParser(dd, data),
        data.getDate());
}
 
Example #25
Source File: AbstractResolver.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
protected boolean doValidate(ResolveData data) {
    if (validate != null) {
        return validate;
    } else {
        return data.isValidate();
    }
}
 
Example #26
Source File: PublishEngineTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
private ResolvedModuleRevision resolveModule(IvySettings settings, FileSystemResolver resolver,
        String module) throws ParseException {
    return resolver.getDependency(
        new DefaultDependencyDescriptor(ModuleRevisionId.parse(module), false),
        new ResolveData(new ResolveEngine(settings, new EventManager(),
                new SortEngine(settings)), new ResolveOptions()));
}
 
Example #27
Source File: AbstractResolver.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
protected ResolvedModuleRevision findModuleInCache(DependencyDescriptor dd, ResolveData data,
        boolean anyResolver) {
    ResolvedModuleRevision rmr = getRepositoryCacheManager().findModuleInCache(dd,
        dd.getDependencyRevisionId(), getCacheOptions(data), anyResolver ? null : getName());
    if (rmr == null) {
        return null;
    }
    if (data.getReport() != null
            && data.isBlacklisted(data.getReport().getConfiguration(), rmr.getId())) {
        Message.verbose("\t" + getName() + ": found revision in cache: " + rmr.getId()
                + " for " + dd + ", but it is blacklisted");
        return null;
    }
    return rmr;
}
 
Example #28
Source File: AbstractResolver.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
protected CacheMetadataOptions getCacheOptions(ResolveData data) {
    return (CacheMetadataOptions) new CacheMetadataOptions()
            .setChangingMatcherName(getChangingMatcherName())
            .setChangingPattern(getChangingPattern())
            .setCheckTTL(!data.getOptions().isUseCacheOnly())
            .setCheckmodified(
                data.getOptions().isUseCacheOnly() ? Boolean.FALSE : checkmodified)
            .setValidate(doValidate(data)).setNamespace(getNamespace())
            .setUseCacheOnly(data.getOptions().isUseCacheOnly())
            .setForce(data.getOptions().isRefresh())
            .setListener(getDownloadListener(getDownloadOptions(data.getOptions())));
}
 
Example #29
Source File: AbstractResolver.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
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;
    }
}
 
Example #30
Source File: IBiblioResolver.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
private ResolvedResource findSnapshotDescriptor(final DependencyDescriptor dd, final ResolveData data,
                                                final ModuleRevisionId mrid,
                                                final MavenTimedSnapshotVersionMatcher.MavenSnapshotRevision snapshotRevision) {
    if (!isM2compatible()) {
        return null;
    }
    final String snapshotDescriptorPattern;
    if (snapshotRevision.isTimestampedSnapshot()) {
        Message.debug(mrid + " has been identified as a (Maven) timestamped snapshot revision");
        // this is a Maven timestamped snapshot revision. Something like 1.0.0-<timestampedRev>
        // We now get the base revision from it, which is "1.0.0" and append the "-SNAPSHOT" to it.
        final String inferredSnapshotRevision = snapshotRevision.getBaseRevision() + "-SNAPSHOT";
        // we replace the "/[revision]" in the descriptor pattern with the "inferred" snapshot
        // revision which is like "1.0.0-SNAPSHOT".
        // Ultimately, this will translate to something like
        // org/module/1.0.0-SNAPSHOT/artifact-1.0.0-<timestampedRev>(-[classifier]).ext
        snapshotDescriptorPattern = getWholePattern().replaceFirst("/\\[revision\\]", "/" + inferredSnapshotRevision);
    } else {
        // it's not a timestamped revision, but a regular snapshot. Try and find any potential
        // timestamped revisions of this regular snapshot, by looking into the Maven metadata
        final String timestampedRev = findTimestampedSnapshotVersion(mrid);
        if (timestampedRev == null) {
            // no timestamped snapshots found and instead this is just a regular snapshot
            // version. So let's just fallback to our logic of finding resources using
            // configured Ivy pattern(s)
            return null;
        }
        Message.verbose(mrid + " has been identified as a snapshot revision which has a timestamped snapshot revision " + timestampedRev);
        // we have found a timestamped revision for a snapshot. So we replace the "-[revision]"
        // in the artifact file name to use the timestamped revision.
        // Ultimately, this will translate to something like
        // org/module/1.0.0-SNAPSHOT/artifact-1.0.0-<timestampedRev>(-[classifier]).ext
        snapshotDescriptorPattern = getWholePattern().replaceFirst("\\-\\[revision\\]", "-" + timestampedRev);
    }
    // find the descriptor using the snapshot descriptor pattern
    return findResourceUsingPattern(mrid, snapshotDescriptorPattern,
            DefaultArtifact.newPomArtifact(mrid, data.getDate()), getRMDParser(dd, data),
            data.getDate());
}