Search in sources :

Example 51 with RepositoryManager

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

the class TestModelMethodsAndAttributes method initTypechecker.

public static void initTypechecker() {
    if (model == null) {
        final RepositoryManager repoman = CeylonUtils.repoManager().systemRepo("../dist/dist/repo").outRepo("test-modules").buildManager();
        tc = new TypeCheckerBuilder().addSrcDirectory(new File("src/test/resources/modeltests")).setRepositoryManager(repoman).getTypeChecker();
        tc.process();
    }
}
Also used : RepositoryManager(org.eclipse.ceylon.cmr.api.RepositoryManager) TypeCheckerBuilder(org.eclipse.ceylon.compiler.typechecker.TypeCheckerBuilder) File(java.io.File)

Example 52 with RepositoryManager

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

the class TestSiteVariance method typeChecker.

private TypeChecker typeChecker(Options opts) {
    final RepositoryManager repoman = CeylonUtils.repoManager().userRepos(opts.getRepos()).outRepo(opts.getOutRepo()).buildManager();
    final TypeCheckerBuilder builder = new TypeCheckerBuilder().moduleManagerFactory(new JsModuleManagerFactory("UTF-8"));
    for (File sd : opts.getSrcDirs()) {
        builder.addSrcDirectory(sd);
    }
    builder.setRepositoryManager(repoman);
    final TypeChecker tc = builder.getTypeChecker();
    JsModuleManagerFactory.setVerbose(true);
    tc.process();
    return tc;
}
Also used : JsModuleManagerFactory(org.eclipse.ceylon.compiler.js.loader.JsModuleManagerFactory) TypeChecker(org.eclipse.ceylon.compiler.typechecker.TypeChecker) RepositoryManager(org.eclipse.ceylon.cmr.api.RepositoryManager) TypeCheckerBuilder(org.eclipse.ceylon.compiler.typechecker.TypeCheckerBuilder) File(java.io.File)

Example 53 with RepositoryManager

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

the class LanguageCompiler method initProcessAnnotations.

@Override
public void initProcessAnnotations(Iterable<? extends Processor> processors) {
    java.util.List<String> aptModules = options.getMulti(Option.CEYLONAPT);
    if (aptModules != null) {
        CeyloncFileManager dfm = (CeyloncFileManager) fileManager;
        RepositoryManager repositoryManager = dfm.getRepositoryManager();
        final Set<ModuleSpec> visited = new HashSet<>();
        StatusPrinterAptProgressListener progressListener = null;
        if (sp != null) {
            progressListener = new StatusPrinterAptProgressListener(sp) {

                @Override
                protected long getNumberOfModulesResolved() {
                    return visited.size();
                }
            };
            sp.clearLine();
            sp.log("Starting APT resolving");
        }
        for (String aptModule : aptModules) {
            ModuleSpec moduleSpec = ModuleSpec.parse(aptModule);
            addDependenciesToAptPath(repositoryManager, moduleSpec, visited, progressListener);
        }
        if (sp != null) {
            sp.clearLine();
            sp.log("Done APT resolving");
        }
        // we only run APT if asked explicitly with the --apt flag
        super.initProcessAnnotations(processors);
    }
// else don't do anything, which will leave the "processAnnotations" field to false
}
Also used : ModuleSpec(org.eclipse.ceylon.common.ModuleSpec) RepositoryManager(org.eclipse.ceylon.cmr.api.RepositoryManager) HashSet(java.util.HashSet)

Example 54 with RepositoryManager

use of org.eclipse.ceylon.cmr.api.RepositoryManager 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 55 with RepositoryManager

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

the class CallbackTestCase method doTest.

protected void doTest(ArtifactContext context, TestArtifactCallback callback) throws Exception {
    String repoURL = "http://jboss-as7-modules-repository.googlecode.com/svn/trunk/ceylon";
    try {
        new URL(repoURL).openStream();
    } catch (Exception e) {
        log.error(String.format("Cannot connect to repo %s - %s", repoURL, e));
        // probably not on the internet?
        return;
    }
    RepositoryManagerBuilder builder = getRepositoryManagerBuilder(false, 60000, java.net.Proxy.NO_PROXY);
    RemoteContentStore rcs = new RemoteContentStore(repoURL, log, false, 60000, java.net.Proxy.NO_PROXY);
    CmrRepository repo = new DefaultRepository(rcs.createRoot());
    RepositoryManager manager = builder.addRepository(repo).buildRepository();
    try {
        File file = manager.getArtifact(context);
        Assert.assertNotNull(file);
        Assert.assertTrue(callback.size > 0);
        Assert.assertEquals(callback.size, callback.current);
    } catch (Exception re) {
        Assert.assertNotNull(callback.ts);
        Assert.assertNotNull(callback.err);
        Assert.assertEquals(callback.ts, callback.err.getMessage());
    } finally {
        manager.removeArtifact(null, name, version);
        // test if remove really works
        testSearchResults("org.eclipse.fizbiz", ModuleQuery.Type.JVM, new ModuleSearchResult.ModuleDetails[0]);
    }
}
Also used : RepositoryManagerBuilder(org.eclipse.ceylon.cmr.api.RepositoryManagerBuilder) DefaultRepository(org.eclipse.ceylon.cmr.impl.DefaultRepository) RepositoryManager(org.eclipse.ceylon.cmr.api.RepositoryManager) RemoteContentStore(org.eclipse.ceylon.cmr.impl.RemoteContentStore) CmrRepository(org.eclipse.ceylon.cmr.api.CmrRepository) File(java.io.File) ModuleSearchResult(org.eclipse.ceylon.cmr.api.ModuleSearchResult) URL(java.net.URL)

Aggregations

RepositoryManager (org.eclipse.ceylon.cmr.api.RepositoryManager)95 Test (org.junit.Test)71 SimpleRepositoryManager (org.eclipse.ceylon.cmr.impl.SimpleRepositoryManager)68 File (java.io.File)47 ArtifactResult (org.eclipse.ceylon.model.cmr.ArtifactResult)32 CmrRepository (org.eclipse.ceylon.cmr.api.CmrRepository)26 ArtifactContext (org.eclipse.ceylon.cmr.api.ArtifactContext)23 ModuleDetails (org.eclipse.ceylon.cmr.api.ModuleSearchResult.ModuleDetails)14 TypeCheckerBuilder (org.eclipse.ceylon.compiler.typechecker.TypeCheckerBuilder)11 RepositoryManagerBuilder (org.eclipse.ceylon.cmr.api.RepositoryManagerBuilder)8 HashMap (java.util.HashMap)7 TypeChecker (org.eclipse.ceylon.compiler.typechecker.TypeChecker)7 ByteArrayInputStream (java.io.ByteArrayInputStream)5 ArrayList (java.util.ArrayList)5 JsModuleManagerFactory (org.eclipse.ceylon.compiler.js.loader.JsModuleManagerFactory)5 ModuleSearchResult (org.eclipse.ceylon.cmr.api.ModuleSearchResult)4 CeylonRepoManagerBuilder (org.eclipse.ceylon.cmr.ceylon.CeylonUtils.CeylonRepoManagerBuilder)4 IOException (java.io.IOException)3 Manifest (java.util.jar.Manifest)3 DefaultRepository (org.eclipse.ceylon.cmr.impl.DefaultRepository)3