Search in sources :

Example 11 with FileSystemResolver

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());
}
Also used : ConfigurationResolveReport(org.apache.ivy.core.report.ConfigurationResolveReport) ResolveReport(org.apache.ivy.core.report.ResolveReport) Ivy(org.apache.ivy.Ivy) JarFile(java.util.jar.JarFile) File(java.io.File) FileSystemResolver(org.apache.ivy.plugins.resolver.FileSystemResolver) Test(org.junit.Test)

Example 12 with FileSystemResolver

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);
}
Also used : IvySettings(org.apache.ivy.core.settings.IvySettings) File(java.io.File) FileInputStream(java.io.FileInputStream) FileSystemResolver(org.apache.ivy.plugins.resolver.FileSystemResolver) Test(org.junit.Test)

Example 13 with FileSystemResolver

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;
}
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 14 with FileSystemResolver

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());
}
Also used : ResolveData(org.apache.ivy.core.resolve.ResolveData) RepositoryCacheManager(org.apache.ivy.core.cache.RepositoryCacheManager) DualResolver(org.apache.ivy.plugins.resolver.DualResolver) IvySettings(org.apache.ivy.core.settings.IvySettings) File(java.io.File) Ivy(org.apache.ivy.Ivy) ResolveOptions(org.apache.ivy.core.resolve.ResolveOptions) FileSystemResolver(org.apache.ivy.plugins.resolver.FileSystemResolver) Before(org.junit.Before)

Example 15 with FileSystemResolver

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");
}
Also used : EventManager(org.apache.ivy.core.event.EventManager) IvySettings(org.apache.ivy.core.settings.IvySettings) IOException(java.io.IOException) Artifact(org.apache.ivy.core.module.descriptor.Artifact) DefaultModuleDescriptor(org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor) File(java.io.File) FileSystemResolver(org.apache.ivy.plugins.resolver.FileSystemResolver) Test(org.junit.Test)

Aggregations

FileSystemResolver (org.apache.ivy.plugins.resolver.FileSystemResolver)18 Test (org.junit.Test)14 File (java.io.File)11 ModuleDescriptorParserRegistryTest (org.apache.ivy.plugins.parser.ModuleDescriptorParserRegistryTest)7 ChainResolver (org.apache.ivy.plugins.resolver.ChainResolver)6 DependencyResolver (org.apache.ivy.plugins.resolver.DependencyResolver)6 Ivy (org.apache.ivy.Ivy)5 JarFile (java.util.jar.JarFile)4 ConfigurationResolveReport (org.apache.ivy.core.report.ConfigurationResolveReport)4 ResolveReport (org.apache.ivy.core.report.ResolveReport)4 IvySettings (org.apache.ivy.core.settings.IvySettings)3 Artifact (org.apache.ivy.core.module.descriptor.Artifact)2 ModuleRevisionId (org.apache.ivy.core.module.id.ModuleRevisionId)2 DualResolver (org.apache.ivy.plugins.resolver.DualResolver)2 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 RepositoryCacheManager (org.apache.ivy.core.cache.RepositoryCacheManager)1