use of org.apache.ivy.core.module.descriptor.ModuleDescriptor in project ant-ivy by apache.
the class XmlModuleUpdaterTest method testMergedUpdateWithExtendsAndExcludes.
/**
* Test case for IVY-1356.
*
* @throws Exception if something goes wrong
* @see <a href="https://issues.apache.org/jira/browse/IVY-1356">IVY-1356</a>
*/
@Test
public void testMergedUpdateWithExtendsAndExcludes() throws Exception {
URL url = XmlModuleUpdaterTest.class.getResource("test-extends-dependencies-exclude.xml");
XmlModuleDescriptorParser parser = XmlModuleDescriptorParser.getInstance();
ModuleDescriptor md = parser.parseDescriptor(new IvySettings(), url, true);
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
XmlModuleDescriptorUpdater.update(url, buffer, getUpdateOptions("release", "mynewrev").setMerge(true).setMergedDescriptor(md));
ModuleDescriptor updatedMd = parser.parseDescriptor(new IvySettings(), new ByteArrayInputStream(buffer.toByteArray()), new BasicResource("test", false, 0, 0, false), true);
DependencyDescriptor[] deps = updatedMd.getDependencies();
assertNotNull("Dependencies shouldn't be null", deps);
assertEquals("Number of dependencies is incorrect", 2, deps.length);
// test indentation
String updatedXml = buffer.toString();
System.out.println(updatedXml);
assertTrue(updatedXml.contains(XmlModuleDescriptorUpdater.LINE_SEPARATOR + "\t\t<dependency org=\"myorg\" name=\"mymodule1\" rev=\"1.0\" conf=\"default->default\"/>" + XmlModuleDescriptorUpdater.LINE_SEPARATOR));
}
use of org.apache.ivy.core.module.descriptor.ModuleDescriptor in project ant-ivy by apache.
the class XmlModuleUpdaterTest method testUpdateWithExcludeConfigurations1.
@Test
public void testUpdateWithExcludeConfigurations1() throws Exception {
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
URL settingsUrl = new File("test/java/org/apache/ivy/plugins/parser/xml/" + "test-update-excludedconfs1.xml").toURI().toURL();
XmlModuleDescriptorUpdater.update(settingsUrl, buffer, getUpdateOptions("release", "mynewrev").setConfsToExclude(new String[] { "myconf2" }));
XmlModuleDescriptorParser parser = XmlModuleDescriptorParser.getInstance();
ModuleDescriptor updatedMd = parser.parseDescriptor(new IvySettings(), new ByteArrayInputStream(buffer.toByteArray()), new BasicResource("test", false, 0, 0, false), true);
// test the number of configurations
Configuration[] configs = updatedMd.getConfigurations();
assertNotNull("Configurations shouldn't be null", configs);
assertEquals("Number of configurations incorrect", 3, configs.length);
// test that the correct configuration has been removed
assertNull("myconf2 hasn't been removed", updatedMd.getConfiguration("myconf2"));
// test that the other configurations aren't removed
assertNotNull("myconf1 has been removed", updatedMd.getConfiguration("myconf1"));
assertNotNull("myconf3 has been removed", updatedMd.getConfiguration("myconf3"));
assertNotNull("myconf4 has been removed", updatedMd.getConfiguration("myconf4"));
}
use of org.apache.ivy.core.module.descriptor.ModuleDescriptor in project ant-ivy by apache.
the class XmlModuleUpdaterTest method testUpdateWithExcludeConfigurations4.
@Test
public void testUpdateWithExcludeConfigurations4() throws Exception {
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
URL settingsUrl = new File("test/java/org/apache/ivy/plugins/parser/xml/" + "test-update-excludedconfs4.xml").toURI().toURL();
XmlModuleDescriptorUpdater.update(settingsUrl, buffer, getUpdateOptions("release", "mynewrev").setConfsToExclude(new String[] { "myconf2" }));
XmlModuleDescriptorParser parser = XmlModuleDescriptorParser.getInstance();
ModuleDescriptor updatedMd = parser.parseDescriptor(new IvySettings(), new ByteArrayInputStream(buffer.toByteArray()), new BasicResource("test", false, 0, 0, false), true);
// test the number of configurations
Artifact[] artifacts = updatedMd.getAllArtifacts();
assertNotNull("Published artifacts shouldn't be null", artifacts);
assertEquals("Number of published artifacts incorrect", 4, artifacts.length);
// test that the correct configuration has been removed
for (Artifact current : artifacts) {
List<String> currentConfs = Arrays.asList(current.getConfigurations());
assertTrue("myconf2 hasn't been removed for artifact " + current.getName(), !currentConfs.contains("myconf2"));
}
}
use of org.apache.ivy.core.module.descriptor.ModuleDescriptor 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.core.module.descriptor.ModuleDescriptor in project ant-ivy by apache.
the class RepositoryManagementEngine method analyze.
/**
* Analyze data in the repository.
* <p>
* This method may take a long time to proceed. It should never be called from event dispatch
* thread in a GUI.
* </p>
*
* @throws IllegalStateException
* if the repository has not been loaded yet
* @see #load()
*/
public void analyze() {
ensureLoaded();
Message.info("\nanalyzing dependencies...");
for (ModuleDescriptor md : revisions.values()) {
for (DependencyDescriptor dd : md.getDependencies()) {
ModuleRevisionId dep = getDependency(dd);
if (dep == null) {
Message.warn("inconsistent repository: declared dependency not found: " + dd);
} else {
getDependers(dep).add(md.getModuleRevisionId());
}
}
Message.progress();
}
analyzed = true;
}
Aggregations