use of org.apache.ivy.core.module.descriptor.ModuleDescriptor in project ant-ivy by apache.
the class ResolveTest method testFromCache2.
@Test
public void testFromCache2() throws Exception {
// mod1.1 depends on mod1.2
Ivy ivy = ivyTestCache();
// set up repository
FileUtil.forceDelete(new File("build/testCache2"));
File art = new File("build/testCache2/mod1.2-2.0.jar");
FileUtil.copy(new File("test/repositories/1/org1/mod1.2/jars/mod1.2-2.0.jar"), art, null);
// we first do a simple resolve so that module is in cache
ResolveReport report = ivy.resolve(new File("test/repositories/1/org1/mod1.1/ivys/ivy-1.0.xml"), getResolveOptions(new String[] { "*" }));
assertFalse(report.hasError());
// now we clean the repository to simulate repo not available (network pb for instance)
FileUtil.forceDelete(new File("build/testCache2"));
// now do a new resolve: it should use cached data
report = ivy.resolve(new File("test/repositories/1/org1/mod1.1/ivys/ivy-1.0.xml"), getResolveOptions(new String[] { "*" }));
assertFalse(report.hasError());
ModuleDescriptor md = report.getModuleDescriptor();
ModuleRevisionId mrid = ModuleRevisionId.newInstance("org1", "mod1.1", "1.0");
assertEquals(mrid, md.getModuleRevisionId());
assertTrue(getResolvedIvyFileInCache(ivy, mrid).exists());
// dependencies
assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org1", "mod1.2", "2.0")).exists());
assertTrue(getArchiveFileInCache("org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists());
}
use of org.apache.ivy.core.module.descriptor.ModuleDescriptor in project ant-ivy by apache.
the class ResolveTest method testResolveTransitiveDisabled.
@Test
public void testResolveTransitiveDisabled() throws Exception {
// mod2.1 depends on mod1.1 which depends on mod1.2
ResolveReport report = ivy.resolve(new File("test/repositories/1/org2/mod2.1/ivys/ivy-0.3.xml"), getResolveOptions(new String[] { "*" }).setTransitive(false));
assertNotNull(report);
ModuleDescriptor md = report.getModuleDescriptor();
assertNotNull(md);
ModuleRevisionId mrid = ModuleRevisionId.newInstance("org2", "mod2.1", "0.3");
assertEquals(mrid, md.getModuleRevisionId());
assertTrue(getResolvedIvyFileInCache(mrid).exists());
// dependencies
assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org1", "mod1.1", "1.0")).exists());
assertTrue(getArchiveFileInCache("org1", "mod1.1", "1.0", "mod1.1", "jar", "jar").exists());
assertFalse(getIvyFileInCache(ModuleRevisionId.newInstance("org1", "mod1.2", "2.0")).exists());
assertFalse(getArchiveFileInCache("org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists());
}
use of org.apache.ivy.core.module.descriptor.ModuleDescriptor in project ant-ivy by apache.
the class ResolveTest method testNamespaceMapping.
@Test
public void testNamespaceMapping() throws Exception {
// the dependency is in another namespace
Ivy ivy = new Ivy();
ivy.configure(new File("test/repositories/namespace/ivysettings.xml"));
ResolveReport report = ivy.resolve(ResolveTest.class.getResource("ivy-namespace.xml"), getResolveOptions(new String[] { "*" }));
assertNotNull(report);
ModuleDescriptor md = report.getModuleDescriptor();
assertNotNull(md);
ModuleRevisionId mrid = ModuleRevisionId.newInstance("apache", "namespace", "1.0");
assertEquals(mrid, md.getModuleRevisionId());
assertTrue(getResolvedIvyFileInCache(mrid).exists());
// ivy file
File ivyFile = getIvyFileInCache(ModuleRevisionId.newInstance("systemorg", "systemmod", "1.0"));
assertTrue(ivyFile.exists());
ModuleDescriptor parsedMD = XmlModuleDescriptorParser.getInstance().parseDescriptor(ivy.getSettings(), ivyFile.toURI().toURL(), true);
assertEquals("systemorg", parsedMD.getModuleRevisionId().getOrganisation());
assertEquals("systemmod", parsedMD.getModuleRevisionId().getName());
// dependencies
assertTrue(getArchiveFileInCache(ivy, "systemorg", "systemmod", "1.0", "A", "jar", "jar").exists());
}
use of org.apache.ivy.core.module.descriptor.ModuleDescriptor in project ant-ivy by apache.
the class ResolveTest method testResolveMaven2Classifiers.
/**
* Test case for IVY-418.
*
* @throws Exception if something goes wrong
* @see <a href="https://issues.apache.org/jira/browse/IVY-418">IVY-418</a>
*/
@Test
public void testResolveMaven2Classifiers() throws Exception {
// test-classifier depends on test-classified with classifier asl
Ivy ivy = new Ivy();
ivy.configure(new File("test/repositories/m2/ivysettings.xml"));
ResolveReport report = ivy.resolve(new File("test/repositories/m2/org/apache/test-classifier/1.0/test-classifier-1.0.pom"), getResolveOptions(new String[] { "*" }));
assertNotNull(report);
ModuleDescriptor md = report.getModuleDescriptor();
assertNotNull(md);
ModuleRevisionId mrid = ModuleRevisionId.newInstance("org.apache", "test-classifier", "1.0");
assertEquals(mrid, md.getModuleRevisionId());
assertTrue(getResolvedIvyFileInCache(mrid).exists());
// dependencies
assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org.apache", "test-classified", "1.0")).exists());
Map<String, String> cmap = new HashMap<>();
cmap.put("classifier", "asl");
assertTrue(getArchiveFileInCache(ivy, "org.apache", "test-classified", /* branch */
null, "1.0", "test-classified", "jar", "jar", cmap).exists());
}
use of org.apache.ivy.core.module.descriptor.ModuleDescriptor in project ant-ivy by apache.
the class ResolveTest method testResolveWithExcludesArtifacts4.
@Test
public void testResolveWithExcludesArtifacts4() throws Exception {
// mod2.3 depends on mod2.1 and excludes artifacts with regexp matcher
ResolveReport report = ivy.resolve(new File("test/repositories/1/org2/mod2.3/ivys/ivy-0.6.4.xml"), getResolveOptions(new String[] { "*" }));
assertNotNull(report);
ModuleDescriptor md = report.getModuleDescriptor();
assertNotNull(md);
ModuleRevisionId mrid = ModuleRevisionId.newInstance("org2", "mod2.3", "0.6.4");
assertEquals(mrid, md.getModuleRevisionId());
assertTrue(getResolvedIvyFileInCache(mrid).exists());
assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org2", "mod2.1", "0.3")).exists());
assertTrue(getArchiveFileInCache("org2", "mod2.1", "0.3", "art21A", "jar", "jar").exists());
assertFalse(getArchiveFileInCache("org2", "mod2.1", "0.3", "art21B", "jar", "jar").exists());
assertFalse(getArchiveFileInCache("org2", "mod2.1", "0.3", "mod2.1", "jar", "jar").exists());
}
Aggregations