Search in sources :

Example 31 with ArtifactResult

use of org.eclipse.ceylon.model.cmr.ArtifactResult in project ceylon by eclipse.

the class MavenBackupDependencyResolver method resolve.

@Override
public ModuleInfo resolve(DependencyContext context, Overrides overrides) {
    if (context.ignoreInner() == false) {
        ArtifactResult result = context.result();
        File mod = result.artifact();
        if (mod != null && IOUtils.isZipFile(mod)) {
            String name = result.name();
            int p = name.indexOf(':');
            if (p < 0) {
                p = name.lastIndexOf('.');
            }
            if (p < 0) {
                // not a Maven artifact
                return null;
            }
            String groupId = name.substring(0, p);
            String artifactId = name.substring(p + 1);
            String descriptorPath = String.format("META-INF/maven/%s/%s/pom.xml", groupId, artifactId);
            InputStream inputStream = IOUtils.findDescriptor(result, descriptorPath);
            if (inputStream != null) {
                try {
                    return resolveFromInputStream(inputStream, name, result.version(), overrides);
                } finally {
                    IOUtils.safeClose(inputStream);
                }
            }
        }
    }
    return null;
}
Also used : InputStream(java.io.InputStream) File(java.io.File) ArtifactResult(org.eclipse.ceylon.model.cmr.ArtifactResult)

Example 32 with ArtifactResult

use of org.eclipse.ceylon.model.cmr.ArtifactResult in project ceylon by eclipse.

the class MavenDependencyResolver method resolve.

@Override
public ModuleInfo resolve(DependencyContext context, Overrides overrides) {
    if (context.ignoreInner() == false) {
        ArtifactResult result = context.result();
        File mod = result.artifact();
        if (mod != null && IOUtils.isZipFile(mod)) {
            String name = result.name();
            int p = name.indexOf(':');
            if (p < 0) {
                p = name.lastIndexOf('.');
            }
            if (p < 0) {
                // not a Maven artifact
                return null;
            }
            String groupId = name.substring(0, p);
            String artifactId = name.substring(p + 1);
            String descriptorPath = String.format("META-INF/maven/%s/%s/pom.xml", groupId, artifactId);
            InputStream inputStream = IOUtils.findDescriptor(result, descriptorPath);
            if (inputStream != null) {
                try {
                    return resolveFromInputStream(inputStream, name, result.version(), overrides);
                } finally {
                    IOUtils.safeClose(inputStream);
                }
            }
        }
    }
    return null;
}
Also used : InputStream(java.io.InputStream) File(java.io.File) ArtifactResult(org.eclipse.ceylon.model.cmr.ArtifactResult)

Example 33 with ArtifactResult

use of org.eclipse.ceylon.model.cmr.ArtifactResult in project ceylon by eclipse.

the class AetherTestCase method testAetherFetchingDependenciesWithUselessProperties.

@Test
public void testAetherFetchingDependenciesWithUselessProperties() throws Throwable {
    CmrRepository repository = AetherRepository.createRepository(log, false, 60000);
    RepositoryManager manager = new SimpleRepositoryManager(repository, log);
    ArtifactResult result = manager.getArtifactResult(MavenArtifactContext.NAMESPACE, "org.springframework.cloud:spring-cloud-starter-eureka", "1.1.2.RELEASE");
    Assert.assertNotNull(result);
    File artifact = result.artifact();
    boolean exists = false;
    try {
        Assert.assertNotNull(artifact);
        Assert.assertTrue(artifact.exists());
        exists = true;
        List<ArtifactResult> deps = result.dependencies();
        Assert.assertEquals(10, deps.size());
        log.debug("deps = " + deps);
    } finally {
        if (exists) {
            // delete this one
            Assert.assertTrue(artifact.delete());
        }
    }
}
Also used : SimpleRepositoryManager(org.eclipse.ceylon.cmr.impl.SimpleRepositoryManager) RepositoryManager(org.eclipse.ceylon.cmr.api.RepositoryManager) SimpleRepositoryManager(org.eclipse.ceylon.cmr.impl.SimpleRepositoryManager) CmrRepository(org.eclipse.ceylon.cmr.api.CmrRepository) File(java.io.File) ArtifactResult(org.eclipse.ceylon.model.cmr.ArtifactResult) Test(org.junit.Test)

Example 34 with ArtifactResult

use of org.eclipse.ceylon.model.cmr.ArtifactResult in project ceylon by eclipse.

the class AetherTestCase method testFilterOverrides.

@Test
public void testFilterOverrides() throws Throwable {
    CmrRepository repository = createAetherRepository();
    RepositoryManager manager = new SimpleRepositoryManager(repository, log, RepositoryManagerBuilder.parseOverrides(getOverridesFileName()));
    ArtifactResult result = manager.getArtifactResult(MavenArtifactContext.NAMESPACE, "org.osgi:org.osgi.core", "4.0.0");
    Assert.assertNotNull(result);
    Assert.assertEquals(result.name(), "org.osgi:org.osgi.core");
    File artifact = result.artifact();
    boolean exists = false;
    try {
        Assert.assertNotNull(artifact);
        Assert.assertTrue(artifact.exists());
        exists = true;
        Assert.assertNotNull(result.filter());
        Assert.assertTrue(result.filter().accept("org/osgi/test"));
        Assert.assertFalse(result.filter().accept("org/eclipse/test"));
    } finally {
        if (exists) {
            // delete this one
            Assert.assertTrue(artifact.delete());
        }
    }
}
Also used : SimpleRepositoryManager(org.eclipse.ceylon.cmr.impl.SimpleRepositoryManager) RepositoryManager(org.eclipse.ceylon.cmr.api.RepositoryManager) SimpleRepositoryManager(org.eclipse.ceylon.cmr.impl.SimpleRepositoryManager) CmrRepository(org.eclipse.ceylon.cmr.api.CmrRepository) File(java.io.File) ArtifactResult(org.eclipse.ceylon.model.cmr.ArtifactResult) Test(org.junit.Test)

Example 35 with ArtifactResult

use of org.eclipse.ceylon.model.cmr.ArtifactResult in project ceylon by eclipse.

the class AetherTestCase method testReplaceOverrides.

@Test
public void testReplaceOverrides() throws Throwable {
    CmrRepository repository = createAetherRepository();
    RepositoryManager manager = new SimpleRepositoryManager(repository, log, RepositoryManagerBuilder.parseOverrides(getOverridesFileName()));
    ArtifactResult result = manager.getArtifactResult(MavenArtifactContext.NAMESPACE, "org.apache.camel:camel-core", "2.9.2");
    Assert.assertNotNull(result);
    Assert.assertEquals(result.name(), "org.osgi:org.osgi.core");
    File artifact = result.artifact();
    boolean exists = false;
    try {
        Assert.assertNotNull(artifact);
        Assert.assertTrue(artifact.exists());
        exists = true;
        List<ArtifactResult> deps = result.dependencies();
        Assert.assertEquals(deps.size(), 0);
    } finally {
        if (exists) {
            // delete this one
            Assert.assertTrue(artifact.delete());
        }
    }
}
Also used : SimpleRepositoryManager(org.eclipse.ceylon.cmr.impl.SimpleRepositoryManager) RepositoryManager(org.eclipse.ceylon.cmr.api.RepositoryManager) SimpleRepositoryManager(org.eclipse.ceylon.cmr.impl.SimpleRepositoryManager) CmrRepository(org.eclipse.ceylon.cmr.api.CmrRepository) File(java.io.File) ArtifactResult(org.eclipse.ceylon.model.cmr.ArtifactResult) Test(org.junit.Test)

Aggregations

ArtifactResult (org.eclipse.ceylon.model.cmr.ArtifactResult)79 File (java.io.File)40 RepositoryManager (org.eclipse.ceylon.cmr.api.RepositoryManager)32 SimpleRepositoryManager (org.eclipse.ceylon.cmr.impl.SimpleRepositoryManager)28 Test (org.junit.Test)28 ArtifactContext (org.eclipse.ceylon.cmr.api.ArtifactContext)25 IOException (java.io.IOException)17 ArrayList (java.util.ArrayList)17 CmrRepository (org.eclipse.ceylon.cmr.api.CmrRepository)15 ModuleSpec (org.eclipse.ceylon.common.ModuleSpec)13 FileOutputStream (java.io.FileOutputStream)6 InputStream (java.io.InputStream)5 ToolUsageError (org.eclipse.ceylon.common.tool.ToolUsageError)5 Module (org.eclipse.ceylon.model.typechecker.model.Module)5 LinkedList (java.util.LinkedList)4 List (java.util.List)4 ZipEntry (java.util.zip.ZipEntry)4 FileInputStream (java.io.FileInputStream)3 OutputStream (java.io.OutputStream)3 OutputStreamWriter (java.io.OutputStreamWriter)3