use of org.apache.ivy.plugins.version.VersionMatcher in project ant-ivy by apache.
the class RepositoryManagementEngine method getDependency.
private ModuleRevisionId getDependency(DependencyDescriptor dd) {
ModuleRevisionId askedMrid = dd.getDependencyRevisionId();
VersionMatcher vmatcher = settings.getVersionMatcher();
if (vmatcher.isDynamic(askedMrid)) {
ModuleRevisionId mrid = cache.get(askedMrid);
if (mrid == null) {
for (ModuleDescriptor md : getAllRevisions(askedMrid)) {
if (vmatcher.needModuleDescriptor(askedMrid, md.getResolvedModuleRevisionId())) {
if (vmatcher.accept(askedMrid, md)) {
mrid = md.getResolvedModuleRevisionId();
break;
}
} else {
if (vmatcher.accept(askedMrid, md.getResolvedModuleRevisionId())) {
mrid = md.getResolvedModuleRevisionId();
break;
}
}
}
if (mrid == null) {
return null;
} else {
cache.put(askedMrid, mrid);
}
}
return mrid;
} else {
return askedMrid;
}
}
use of org.apache.ivy.plugins.version.VersionMatcher 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));
}
use of org.apache.ivy.plugins.version.VersionMatcher 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")));
}
use of org.apache.ivy.plugins.version.VersionMatcher in project ant-ivy by apache.
the class ResolveEngine method fetchDependencies.
private void fetchDependencies(VisitNode node, String conf, boolean shouldBePublic) {
checkInterrupted();
long start = System.currentTimeMillis();
if (node.getParent() != null) {
Message.verbose("== resolving dependencies " + node.getParent().getId() + "->" + node.getId() + " [" + node.getParentConf() + "->" + conf + "]");
} else {
Message.verbose("== resolving dependencies for " + node.getId() + " [" + conf + "]");
}
ResolveData data = node.getNode().getData();
VisitNode parentVisitNode = data.getCurrentVisitNode();
data.setCurrentVisitNode(node);
DependencyDescriptor dd = node.getDependencyDescriptor();
VersionMatcher versionMatcher = node.getNode().getData().getSettings().getVersionMatcher();
if (dd != null && !(node.getRoot() == node.getParent() && versionMatcher.isDynamic(dd.getDependencyRevisionId()))) {
/*
* we don't resolve conflicts before loading data for direct dependencies on dynamic
* revisions, so that direct dynamic revisions are always resolved, which is mandatory
* for proper replacement of dynamic revisions during 'deliver'
*/
resolveConflict(node, conf);
}
if (node.loadData(conf, shouldBePublic)) {
// we resolve conflict again now that we have all information loaded
// indeed in some cases conflict manager need more information than just asked
// dependency to take the decision
resolveConflict(node, conf);
if (!node.isEvicted() && !node.isCircular()) {
for (String rconf : node.getRealConfs(conf)) {
doFetchDependencies(node, rconf);
}
}
} else if (!node.hasProblem()) {
// => we just have to update its dependencies data
if (!node.isEvicted() && !node.isCircular()) {
for (String rconf : node.getRealConfs(conf)) {
doFetchDependencies(node, rconf);
}
}
}
if (node.isEvicted()) {
// update selected nodes with confs asked in evicted one
EvictionData ed = node.getEvictedData();
if (ed.getSelected() != null) {
for (IvyNode selected : ed.getSelected()) {
if (!selected.isLoaded()) {
// the node is not yet loaded, we can simply update its set of
// configurations to fetch
selected.updateConfsToFetch(Collections.singleton(conf));
} else {
// the node has already been loaded, we must fetch its dependencies in the
// required conf
fetchDependencies(node.gotoNode(selected), conf, true);
}
}
}
}
if (settings.debugConflictResolution()) {
Message.debug(node.getId() + " => dependencies resolved in " + conf + " (" + (System.currentTimeMillis() - start) + "ms)");
}
data.setCurrentVisitNode(parentVisitNode);
}
use of org.apache.ivy.plugins.version.VersionMatcher in project ant-ivy by apache.
the class XmlSettingsParserTest method testMavenTimedSnapshotVersionMatcher.
/**
* Tests that the {@code maven-tsnap-vm} version matcher, configured in the settings file,
* is parsed correctly
*
* @throws Exception if something goes wrong
*/
@Test
public void testMavenTimedSnapshotVersionMatcher() throws Exception {
final IvySettings settings = new IvySettings();
XmlSettingsParser parser = new XmlSettingsParser(settings);
parser.parse(XmlSettingsParserTest.class.getResource("ivysettings-maven-tsnap-vmatcher.xml"));
final VersionMatcher mavenTSnapVersionMatcher = settings.getVersionMatcher(new MavenTimedSnapshotVersionMatcher().getName());
assertNotNull("Maven timestamped snapshot version matcher is missing", mavenTSnapVersionMatcher);
assertTrue("Unexpected type for Maven timestamped snapshot version matcher", mavenTSnapVersionMatcher instanceof MavenTimedSnapshotVersionMatcher);
}
Aggregations