use of org.apache.ivy.core.resolve.ResolveOptions in project ant-ivy by apache.
the class Maven2LocalTest method setUp.
@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);
}
use of org.apache.ivy.core.resolve.ResolveOptions in project ant-ivy by apache.
the class URLResolverTest method setUp.
@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);
}
use of org.apache.ivy.core.resolve.ResolveOptions in project ant-ivy by apache.
the class RetrieveTest method testUnpack.
@Test
public void testUnpack() throws Exception {
ResolveOptions roptions = getResolveOptions(new String[] { "*" });
URL url = new File("test/repositories/1/packaging/module1/ivys/ivy-1.0.xml").toURI().toURL();
// normal resolve, the file goes in the cache
ResolveReport report = ivy.resolve(url, roptions);
assertFalse(report.hasError());
ModuleDescriptor md = report.getModuleDescriptor();
assertNotNull(md);
String pattern = "build/test/retrieve/[organization]/[module]/[conf]/[type]s/[artifact]-[revision](.[ext])";
ivy.retrieve(md.getModuleRevisionId(), getRetrieveOptions().setDestArtifactPattern(pattern));
File dest = new File("build/test/retrieve/packaging/module2/default/jars/module2-1.0");
assertTrue(dest.exists());
assertTrue(dest.isDirectory());
File[] jarContents = dest.listFiles();
Arrays.sort(jarContents);
assertEquals(new File(dest, "META-INF"), jarContents[0]);
assertEquals(new File(dest, "test.txt"), jarContents[1]);
assertEquals(new File(dest, "META-INF/MANIFEST.MF"), jarContents[0].listFiles()[0]);
}
use of org.apache.ivy.core.resolve.ResolveOptions in project ant-ivy by apache.
the class RetrieveTest method testUnpackSync.
@Test
public void testUnpackSync() throws Exception {
ResolveOptions roptions = getResolveOptions(new String[] { "*" });
URL url = new File("test/repositories/1/packaging/module1/ivys/ivy-1.0.xml").toURI().toURL();
// normal resolve, the file goes in the cache
ResolveReport report = ivy.resolve(url, roptions);
assertFalse(report.hasError());
ModuleDescriptor md = report.getModuleDescriptor();
assertNotNull(md);
String pattern = "build/test/retrieve/[organization]/[module]/[conf]/[type]s/[artifact]-[revision](.[ext])";
ivy.retrieve(md.getModuleRevisionId(), getRetrieveOptions().setSync(true).setDestArtifactPattern(pattern));
File dest = new File("build/test/retrieve/packaging/module2/default/jars/module2-1.0");
assertTrue(dest.exists());
assertTrue(dest.isDirectory());
File[] jarContents = dest.listFiles();
Arrays.sort(jarContents);
assertEquals(new File(dest, "META-INF"), jarContents[0]);
assertEquals(new File(dest, "test.txt"), jarContents[1]);
assertEquals(new File(dest, "META-INF/MANIFEST.MF"), jarContents[0].listFiles()[0]);
}
use of org.apache.ivy.core.resolve.ResolveOptions in project ant-ivy by apache.
the class OBRResolverTest method genericTestResolve.
private void genericTestResolve(String jarName, String conf, ModuleRevisionId[] expectedMrids, ModuleRevisionId[] expected2Mrids) throws Exception {
JarInputStream jis = new JarInputStream(new FileInputStream("test/test-repo/bundlerepo/" + jarName));
Manifest manifest = jis.getManifest();
jis.close();
BundleInfo bundleInfo = ManifestParser.parseManifest(manifest);
bundleInfo.addArtifact(new BundleArtifact(false, new File("test/test-repo/bundlerepo/" + jarName).toURI(), null));
DefaultModuleDescriptor md = BundleInfoAdapter.toModuleDescriptor(OSGiManifestParser.getInstance(), null, bundleInfo, profileProvider);
ResolveReport resolveReport = ivy.resolve(md, new ResolveOptions().setConfs(new String[] { conf }).setOutputReport(false));
assertFalse("resolve failed " + resolveReport.getAllProblemMessages(), resolveReport.hasError());
Set<ModuleRevisionId> actual = new HashSet<>();
for (Artifact artifact : resolveReport.getArtifacts()) {
actual.add(artifact.getModuleRevisionId());
}
Set<ModuleRevisionId> expected = new HashSet<>(Arrays.asList(expectedMrids));
if (expected2Mrids != null) {
// in this use case, we have two choices, let's try the second one
try {
Set<ModuleRevisionId> expected2 = new HashSet<>(Arrays.asList(expected2Mrids));
assertEquals(expected2, actual);
// test passed
return;
} catch (AssertionError e) {
// too bad, let's continue
}
}
assertEquals(expected, actual);
}
Aggregations