Search in sources :

Example 1 with DependencyResolver

use of org.eclipse.ceylon.cmr.api.DependencyResolver 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)

Example 2 with DependencyResolver

use of org.eclipse.ceylon.cmr.api.DependencyResolver in project ceylon by eclipse.

the class Configuration method getResolvers.

public static DependencyResolvers getResolvers(RepositoryManager manager) {
    DependencyResolvers resolvers = new DependencyResolvers();
    resolvers.addResolver(BytecodeUtils.INSTANCE);
    DependencyResolver jsResolver = getJavaScriptResolver();
    if (jsResolver != null) {
        resolvers.addResolver(jsResolver);
    }
    resolvers.addResolver(PropertiesDependencyResolver.INSTANCE);
    resolvers.addResolver(XmlDependencyResolver.INSTANCE);
    if (usesMaven(manager)) {
        DependencyResolver mavenResolver = getMavenResolver();
        if (mavenResolver != null) {
            resolvers.addResolver(mavenResolver);
        }
    }
    resolvers.addResolver(OSGiDependencyResolver.INSTANCE);
    DependencyResolver npmResolver = getNpmResolver();
    if (npmResolver != null) {
        resolvers.addResolver(npmResolver);
    }
    return resolvers;
}
Also used : DependencyResolvers(org.eclipse.ceylon.cmr.api.DependencyResolvers) DependencyResolver(org.eclipse.ceylon.cmr.api.DependencyResolver)

Example 3 with DependencyResolver

use of org.eclipse.ceylon.cmr.api.DependencyResolver in project ceylon by eclipse.

the class Configuration method getResolver.

private static DependencyResolver getResolver(String className) {
    try {
        ClassLoader cl = Configuration.class.getClassLoader();
        DependencyResolver resolver = (DependencyResolver) cl.loadClass(className).newInstance();
        return resolver;
    } catch (Throwable t) {
        Logger.getLogger(Configuration.class.getName()).warning(String.format("Cannot add resolver %s - %s", className, t));
    }
    return null;
}
Also used : DependencyResolver(org.eclipse.ceylon.cmr.api.DependencyResolver)

Aggregations

DependencyResolver (org.eclipse.ceylon.cmr.api.DependencyResolver)3 File (java.io.File)1 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 DependencyResolvers (org.eclipse.ceylon.cmr.api.DependencyResolvers)1 ModuleInfo (org.eclipse.ceylon.cmr.api.ModuleInfo)1 RepositoryManager (org.eclipse.ceylon.cmr.api.RepositoryManager)1 CeylonRepoManagerBuilder (org.eclipse.ceylon.cmr.ceylon.CeylonUtils.CeylonRepoManagerBuilder)1 MavenDependencyResolver (org.eclipse.ceylon.cmr.maven.MavenDependencyResolver)1 Test (org.junit.Test)1