use of org.apache.ivy.plugins.resolver.FileSystemResolver in project ant-ivy by apache.
the class ResolveTest method testResolveRequiresDescriptor.
@Test
public void testResolveRequiresDescriptor() throws Exception {
// mod1.1 depends on mod1.2, mod1.2 has no ivy file
Ivy ivy = new Ivy();
ivy.configure(new File("test/repositories/ivysettings.xml"));
((FileSystemResolver) ivy.getSettings().getResolver("1")).setDescriptor(FileSystemResolver.DESCRIPTOR_REQUIRED);
ResolveReport report = ivy.resolve(new File("test/repositories/1/org1/mod1.1/ivys/ivy-1.0.xml"), getResolveOptions(new String[] { "*" }));
assertNotNull(report);
assertTrue(report.hasError());
}
use of org.apache.ivy.plugins.resolver.FileSystemResolver in project ant-ivy by apache.
the class BundleRepoTest method testResolver.
@Test
public void testResolver() throws Exception {
FileSystemResolver fileSystemResolver = new FileSystemResolver();
fileSystemResolver.setName("test");
fileSystemResolver.addIvyPattern(ivyrepo.getAbsolutePath() + "/[organisation]/[module]/[revision]/ivy.xml");
fileSystemResolver.addArtifactPattern(ivyrepo.getAbsolutePath() + "/[organisation]/[module]/[revision]/[type]s/[artifact]-[revision].[ext]");
fileSystemResolver.setSettings(new IvySettings());
ResolverManifestIterable it = new ResolverManifestIterable(fileSystemResolver);
BundleRepoDescriptor repo = new BundleRepoDescriptor(ivyrepo.toURI(), ExecutionEnvironmentProfileProvider.getInstance());
repo.populate(it.iterator());
BundleRepoDescriptor repo2 = OBRXMLParser.parse(ivyrepo.toURI(), new FileInputStream(new File(ivyrepo, "repo.xml")));
assertEquals(repo, repo2);
}
use of org.apache.ivy.plugins.resolver.FileSystemResolver in project ant-ivy by apache.
the class ArtifactLockStrategyTest method createSlowResolver.
private FileSystemResolver createSlowResolver(IvySettings settings, final int sleep) {
FileSystemResolver resolver = new FileSystemResolver();
resolver.setRepositoryCacheManager(newCacheManager(settings));
resolver.setRepository(new FileRepository() {
private RepositoryCopyProgressListener progress = new RepositoryCopyProgressListener(this) {
public void progress(CopyProgressEvent evt) {
super.progress(evt);
// makes the file copy longer to test concurrency issues
sleepSilently(sleep);
}
};
protected RepositoryCopyProgressListener getProgressListener() {
return progress;
}
});
resolver.setName("test");
resolver.setSettings(settings);
resolver.addIvyPattern(settings.getBaseDir() + "/test/repositories/1/[organisation]/[module]/[type]s/[artifact]-[revision].[ext]");
resolver.addArtifactPattern(settings.getBaseDir() + "/test/repositories/1/[organisation]/[module]/[type]s/[artifact]-[revision].[ext]");
return resolver;
}
use of org.apache.ivy.plugins.resolver.FileSystemResolver in project ant-ivy by apache.
the class OBRResolverTest method setUp.
@Before
public void setUp() throws Exception {
settings = new IvySettings();
bundleResolver = new OBRResolver();
bundleResolver.setRepoXmlFile(new File("test/test-repo/bundlerepo/repo.xml").getAbsolutePath());
bundleResolver.setName("bundle");
bundleResolver.setSettings(settings);
settings.addResolver(bundleResolver);
bundleUrlResolver = new OBRResolver();
bundleUrlResolver.setRepoXmlURL(new File("test/test-repo/bundlerepo/repo.xml").toURI().toURL().toExternalForm());
bundleUrlResolver.setName("bundleurl");
bundleUrlResolver.setSettings(settings);
settings.addResolver(bundleUrlResolver);
dualResolver = new DualResolver();
OBRResolver resolver = new OBRResolver();
resolver.setRepoXmlFile(new File("test/test-repo/ivyrepo/repo.xml").getAbsolutePath());
resolver.setName("dual-bundle");
resolver.setSettings(settings);
dualResolver.add(resolver);
dualResolver.setName("dual");
File ivyrepo = new File("test/test-repo/ivyrepo");
FileSystemResolver fileSystemResolver = new FileSystemResolver();
fileSystemResolver.addIvyPattern(ivyrepo.getAbsolutePath() + "/[organisation]/[module]/[revision]/ivy.xml");
fileSystemResolver.addArtifactPattern(ivyrepo.getAbsolutePath() + "/[organisation]/[module]/[revision]/[type]s/[artifact]-[revision].[ext]");
fileSystemResolver.setName("dual-file");
fileSystemResolver.setSettings(settings);
dualResolver.add(fileSystemResolver);
settings.addResolver(dualResolver);
settings.setDefaultResolver("bundle");
cache = new File("build/cache");
cache.mkdirs();
settings.setDefaultCache(cache);
ivy = new Ivy();
ivy.setSettings(settings);
ivy.bind();
ivy.getResolutionCacheManager().clean();
RepositoryCacheManager[] caches = settings.getRepositoryCacheManagers();
for (RepositoryCacheManager cache : caches) {
cache.clean();
}
data = new ResolveData(ivy.getResolveEngine(), new ResolveOptions());
}
use of org.apache.ivy.plugins.resolver.FileSystemResolver in project ant-ivy by apache.
the class PublishEngineTest method testAtomicity.
@Test
public void testAtomicity() throws Exception {
IvySettings settings = new IvySettings();
final PublishEngine engine = new PublishEngine(settings, new EventManager());
final int[] counter = new int[] { 0 };
final DefaultModuleDescriptor md = DefaultModuleDescriptor.newDefaultInstance(ModuleRevisionId.parse("#A;1.0"));
final FileSystemResolver resolver = new FileSystemResolver() {
public void publish(Artifact artifact, File src, boolean overwrite) throws IOException {
super.publish(artifact, src, overwrite);
synchronized (PublishEngineTest.this) {
counter[0]++;
}
sleepSilently(50);
synchronized (PublishEngineTest.this) {
counter[0]++;
}
}
};
resolver.setName("test");
resolver.setSettings(settings);
String publishRepoDir = new File("build/test/publish/repo").getAbsolutePath();
resolver.addIvyPattern(publishRepoDir + "/[module]/[revision]/[artifact].[ext]");
resolver.addArtifactPattern(publishRepoDir + "/[module]/[revision]/[artifact].[ext]");
FileUtil.copy(new File("test/repositories/1/org1/mod1.1/jars/mod1.1-1.0.jar"), new File("build/test/publish/module/A.jar"), null);
XmlModuleDescriptorWriter.write(md, new File("build/test/publish/module/ivy.xml"));
resolveAndAssertNotFound(settings, resolver, "#A;latest.integration", "before publishing");
// run publish asynchronously
new Thread() {
public void run() {
try {
engine.publish(md, Collections.singletonList("build/test/publish/module/[artifact].[ext]"), resolver, new PublishOptions().setSrcIvyPattern("build/test/publish/module/[artifact].[ext]"));
synchronized (PublishEngineTest.this) {
counter[0]++;
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}.start();
while (true) {
sleepSilently(5);
synchronized (this) {
if (counter[0] == 5) {
break;
} else if (counter[0] < 4) {
resolveAndAssertNotFound(settings, resolver, "#A;latest.integration", "after " + (counter[0] / 2) + " artifacts published");
}
}
}
resolveAndAssertFound(settings, resolver, "#A;1.0");
}
Aggregations