use of org.apache.ivy.plugins.repository.file.FileRepository in project ant-ivy by apache.
the class BasicResolver method getArtifactRef.
protected ResolvedResource getArtifactRef(Artifact artifact, Date date) {
IvyContext.getContext().set(getName() + ".artifact", artifact);
try {
ResolvedResource ret = findArtifactRef(artifact, date);
if (ret == null && artifact.getUrl() != null) {
URL url = artifact.getUrl();
Message.verbose("\tusing url for " + artifact + ": " + url);
logArtifactAttempt(artifact, url.toExternalForm());
Resource resource;
if ("file".equals(url.getProtocol())) {
File f;
try {
f = new File(new URI(url.toExternalForm()));
} catch (URISyntaxException e) {
// unexpected, try to get the best of it
f = new File(url.getPath());
}
resource = new FileResource(new FileRepository(), f);
} else {
resource = new URLResource(url, this.getTimeoutConstraint());
}
ret = new ResolvedResource(resource, artifact.getModuleRevisionId().getRevision());
}
return ret;
} finally {
IvyContext.getContext().set(getName() + ".artifact", null);
}
}
use of org.apache.ivy.plugins.repository.file.FileRepository in project ant-ivy by apache.
the class ResolverHelperTest method testListTokenValuesForIvy1238.
@Test
public void testListTokenValuesForIvy1238() {
FileRepository rep = new FileRepository(new File(".").getAbsoluteFile());
String[] revisions = ResolverHelper.listTokenValues(rep, "test/repositories/IVY-1238/ivy-org/modA/v[revision]/ivy.xml", "revision");
assertNotNull(revisions);
assertEquals(2, revisions.length);
Arrays.sort(revisions);
assertEquals("1.0", revisions[0]);
assertEquals("2.0", revisions[1]);
}
use of org.apache.ivy.plugins.repository.file.FileRepository 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.repository.file.FileRepository in project ant-ivy by apache.
the class BundleRepoTest method testFileRepo.
@Test
public void testFileRepo() throws Exception {
RepositoryManifestIterable it = new RepositoryManifestIterable(new FileRepository(bundlerepo.getAbsoluteFile()));
BundleRepoDescriptor repo = new BundleRepoDescriptor(bundlerepo.toURI(), ExecutionEnvironmentProfileProvider.getInstance());
repo.populate(it.iterator());
BundleRepoDescriptor repo2 = OBRXMLParser.parse(bundlerepo.toURI(), new FileInputStream(new File(bundlerepo, "repo.xml")));
assertEquals(repo, repo2);
}
Aggregations