Search in sources :

Example 1 with FileRepository

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);
    }
}
Also used : FileRepository(org.apache.ivy.plugins.repository.file.FileRepository) URLResource(org.apache.ivy.plugins.repository.url.URLResource) ResolvedResource(org.apache.ivy.plugins.resolver.util.ResolvedResource) MDResolvedResource(org.apache.ivy.plugins.resolver.util.MDResolvedResource) ResolvedResource(org.apache.ivy.plugins.resolver.util.ResolvedResource) MDResolvedResource(org.apache.ivy.plugins.resolver.util.MDResolvedResource) Resource(org.apache.ivy.plugins.repository.Resource) FileResource(org.apache.ivy.plugins.repository.file.FileResource) URLResource(org.apache.ivy.plugins.repository.url.URLResource) FileResource(org.apache.ivy.plugins.repository.file.FileResource) URISyntaxException(java.net.URISyntaxException) File(java.io.File) URI(java.net.URI) URL(java.net.URL)

Example 2 with FileRepository

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]);
}
Also used : FileRepository(org.apache.ivy.plugins.repository.file.FileRepository) File(java.io.File) Test(org.junit.Test)

Example 3 with FileRepository

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;
}
Also used : CopyProgressEvent(org.apache.ivy.util.CopyProgressEvent) FileRepository(org.apache.ivy.plugins.repository.file.FileRepository) RepositoryCopyProgressListener(org.apache.ivy.plugins.repository.RepositoryCopyProgressListener) FileSystemResolver(org.apache.ivy.plugins.resolver.FileSystemResolver)

Example 4 with FileRepository

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);
}
Also used : FileRepository(org.apache.ivy.plugins.repository.file.FileRepository) File(java.io.File) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Aggregations

FileRepository (org.apache.ivy.plugins.repository.file.FileRepository)4 File (java.io.File)3 Test (org.junit.Test)2 FileInputStream (java.io.FileInputStream)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 URL (java.net.URL)1 RepositoryCopyProgressListener (org.apache.ivy.plugins.repository.RepositoryCopyProgressListener)1 Resource (org.apache.ivy.plugins.repository.Resource)1 FileResource (org.apache.ivy.plugins.repository.file.FileResource)1 URLResource (org.apache.ivy.plugins.repository.url.URLResource)1 FileSystemResolver (org.apache.ivy.plugins.resolver.FileSystemResolver)1 MDResolvedResource (org.apache.ivy.plugins.resolver.util.MDResolvedResource)1 ResolvedResource (org.apache.ivy.plugins.resolver.util.ResolvedResource)1 CopyProgressEvent (org.apache.ivy.util.CopyProgressEvent)1