Search in sources :

Example 1 with MavenDependencyResolver

use of org.eclipse.ceylon.cmr.maven.MavenDependencyResolver in project ceylon by eclipse.

the class ResolverTestCase method testMavenDependecyResolver.

@Test
public void testMavenDependecyResolver() throws Exception {
    final MavenDependencyResolver resolver = new MavenDependencyResolver();
    doTest(new Tester() {

        public void run(CmrRepository repository, final File artifact) {
            ModuleInfo infos = resolver.resolve(new TestArtifactResult(repository, "org.apache.camel:camel-core", "2.9.2", artifact), null);
            Assert.assertNotNull(infos);
            Assert.assertEquals(String.valueOf(infos), 3, infos.getDependencies().size());
        }
    });
}
Also used : ModuleInfo(org.eclipse.ceylon.cmr.api.ModuleInfo) MavenDependencyResolver(org.eclipse.ceylon.cmr.maven.MavenDependencyResolver) CmrRepository(org.eclipse.ceylon.cmr.api.CmrRepository) File(java.io.File) Test(org.junit.Test)

Example 2 with MavenDependencyResolver

use of org.eclipse.ceylon.cmr.maven.MavenDependencyResolver in project ceylon by eclipse.

the class CMRTests method testMavenFileResolver.

@Test
public void testMavenFileResolver() throws ZipException, IOException {
    CeylonRepoManagerBuilder builder = CeylonUtils.repoManager();
    RepositoryManager repository = builder.buildManager();
    String groupId = "javax.el";
    String artifactId = "javax.el-api";
    String version = "3.0.0";
    String coord = groupId + ":" + artifactId;
    File artifact = repository.getArtifact(MavenArtifactContext.NAMESPACE, coord, version);
    Assert.assertNotNull(artifact);
    try (ZipFile zf = new ZipFile(artifact)) {
        String descriptorPath = String.format("META-INF/maven/%s/%s/pom.xml", groupId, artifactId);
        ZipEntry entry = zf.getEntry(descriptorPath);
        Assert.assertNotNull(entry);
        try (InputStream is = zf.getInputStream(entry)) {
            DependencyResolver resolver = new MavenDependencyResolver();
            ModuleInfo info = resolver.resolveFromInputStream(is, coord, version, null);
            Assert.assertNotNull(info);
            // FIXME: find one with dependencies
            System.err.println(info.getDependencies());
        }
    }
}
Also used : ZipFile(java.util.zip.ZipFile) ModuleInfo(org.eclipse.ceylon.cmr.api.ModuleInfo) CeylonRepoManagerBuilder(org.eclipse.ceylon.cmr.ceylon.CeylonUtils.CeylonRepoManagerBuilder) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) ZipEntry(java.util.zip.ZipEntry) MavenDependencyResolver(org.eclipse.ceylon.cmr.maven.MavenDependencyResolver) RepositoryManager(org.eclipse.ceylon.cmr.api.RepositoryManager) JarFile(java.util.jar.JarFile) ZipFile(java.util.zip.ZipFile) File(java.io.File) MavenDependencyResolver(org.eclipse.ceylon.cmr.maven.MavenDependencyResolver) DependencyResolver(org.eclipse.ceylon.cmr.api.DependencyResolver) Test(org.junit.Test)

Aggregations

File (java.io.File)2 ModuleInfo (org.eclipse.ceylon.cmr.api.ModuleInfo)2 MavenDependencyResolver (org.eclipse.ceylon.cmr.maven.MavenDependencyResolver)2 Test (org.junit.Test)2 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 JarFile (java.util.jar.JarFile)1 ZipEntry (java.util.zip.ZipEntry)1 ZipFile (java.util.zip.ZipFile)1 CmrRepository (org.eclipse.ceylon.cmr.api.CmrRepository)1 DependencyResolver (org.eclipse.ceylon.cmr.api.DependencyResolver)1 RepositoryManager (org.eclipse.ceylon.cmr.api.RepositoryManager)1 CeylonRepoManagerBuilder (org.eclipse.ceylon.cmr.ceylon.CeylonUtils.CeylonRepoManagerBuilder)1