Search in sources :

Example 6 with RepositoryManager

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

the class ModuleLoaderTest method testModuleLoader.

@Test
public void testModuleLoader() throws ModuleNotFoundException {
    CmrRepository repository = AetherRepository.createRepository(log, false, 60000);
    RepositoryManager manager = new SimpleRepositoryManager(repository, log);
    Map<String, String> extraModules = new HashMap<>();
    extraModules.put("org.springframework.boot:spring-boot-starter-web", "1.3.5.RELEASE");
    extraModules.put("org.springframework.boot:spring-boot-starter-undertow", "1.3.5.RELEASE");
    extraModules.put("org.springframework.boot:spring-boot-starter-data-jpa", "1.3.5.RELEASE");
    extraModules.put("org.springframework.cloud:spring-cloud-starter-eureka", "1.1.2.RELEASE");
    extraModules.put("org.postgresql:postgresql", "9.4.1208");
    extraModules.put("org.liquibase:liquibase-core", "3.4.2");
    TestableModuleLoader moduleLoader = new TestableModuleLoader(manager, null, extraModules, false);
    moduleLoader.loadModule("org.liquibase:liquibase-core", "3.4.2", ModuleScope.RUNTIME);
    // Check that we got the latest version
    Assert.assertEquals("4.2.6.RELEASE", moduleLoader.getModuleVersion("org.springframework:spring-core"));
    // Check that this one did not get removed
    Assert.assertEquals("4.2.6.RELEASE", moduleLoader.getModuleVersion("org.springframework:spring-context"));
    // Those two should not be there
    Assert.assertNull(moduleLoader.getModuleVersion("javax.servlet:servlet-api"));
    Assert.assertNull(moduleLoader.getModuleVersion("org.springframework:spring"));
    // Check that we got the runtime dep
    Assert.assertEquals("3.3.6.Final", moduleLoader.getModuleVersion("org.jboss.xnio:xnio-nio"));
    moduleLoader.cleanup();
    moduleLoader.loadModule("org.liquibase:liquibase-core", "3.4.2", ModuleScope.COMPILE);
    // Check that we got the latest version
    Assert.assertEquals("4.2.6.RELEASE", moduleLoader.getModuleVersion("org.springframework:spring-core"));
    // Check that this one did not get removed
    Assert.assertEquals("4.2.6.RELEASE", moduleLoader.getModuleVersion("org.springframework:spring-context"));
    // Those two should not be there
    Assert.assertNull(moduleLoader.getModuleVersion("javax.servlet:servlet-api"));
    Assert.assertNull(moduleLoader.getModuleVersion("org.springframework:spring"));
    // Check that we have no runtime dep
    Assert.assertNull(moduleLoader.getModuleVersion("org.jboss.xnio:xnio-nio"));
}
Also used : SimpleRepositoryManager(org.eclipse.ceylon.cmr.impl.SimpleRepositoryManager) HashMap(java.util.HashMap) SimpleRepositoryManager(org.eclipse.ceylon.cmr.impl.SimpleRepositoryManager) RepositoryManager(org.eclipse.ceylon.cmr.api.RepositoryManager) CmrRepository(org.eclipse.ceylon.cmr.api.CmrRepository) Test(org.junit.Test)

Example 7 with RepositoryManager

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

the class Main method main.

/**
 * Files that are not under a proper module structure are
 * placed under a <nomodule> module.
 */
public static void main(String[] args) throws Exception {
    if (args.length == 0) {
        System.err.println("Usage Main <directoryNames>");
        System.exit(-1);
        return;
    }
    RepositoryManager repositoryManager = CeylonUtils.repoManager().systemRepo("../dist/dist/repo").logger(new LeakingLogger()).buildManager();
    String verbose = System.getProperties().getProperty("verbose");
    // ClosableVirtualFile latestZippedLanguageSourceFile =
    // MainHelper.getLatestZippedLanguageSourceFile();
    TypeCheckerBuilder tcb = new TypeCheckerBuilder().setRepositoryManager(repositoryManager).verbose("true".equals(verbose)).statistics(true);
    // .addSrcDirectory(latestZippedLanguageSourceFile);
    for (String path : args) {
        tcb.addSrcDirectory(new File(path));
    }
    tcb.getTypeChecker().process();
// latestZippedLanguageSourceFile.close();
}
Also used : LeakingLogger(org.eclipse.ceylon.compiler.typechecker.io.cmr.impl.LeakingLogger) RepositoryManager(org.eclipse.ceylon.cmr.api.RepositoryManager) TypeCheckerBuilder(org.eclipse.ceylon.compiler.typechecker.TypeCheckerBuilder) File(java.io.File)

Example 8 with RepositoryManager

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

the class MainForLanguage method main.

/**
 * Files that are not under a proper module structure are
 * placed under a <nomodule> module.
 */
public static void main(String[] args) throws Exception {
    ClosableVirtualFile latestZippedLanguageSourceFile = MainHelper.getLatestZippedLanguageSourceFile();
    RepositoryManager repositoryManager = CeylonUtils.repoManager().systemRepo("../dist/dist/repo").logger(new LeakingLogger()).buildManager();
    TypeChecker typeChecker = new TypeCheckerBuilder().verbose(false).addSrcDirectory(latestZippedLanguageSourceFile).setRepositoryManager(repositoryManager).getTypeChecker();
    typeChecker.process();
    latestZippedLanguageSourceFile.close();
    if (typeChecker.getErrors() > 0) {
        System.exit(1);
    }
}
Also used : ClosableVirtualFile(org.eclipse.ceylon.compiler.typechecker.io.ClosableVirtualFile) TypeChecker(org.eclipse.ceylon.compiler.typechecker.TypeChecker) LeakingLogger(org.eclipse.ceylon.compiler.typechecker.io.cmr.impl.LeakingLogger) RepositoryManager(org.eclipse.ceylon.cmr.api.RepositoryManager) TypeCheckerBuilder(org.eclipse.ceylon.compiler.typechecker.TypeCheckerBuilder)

Example 9 with RepositoryManager

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

the class MainForJsTest method main.

public static void main(String[] args) throws Exception {
    String distRepo = "../dist/dist/repo";
    final Options opts = new Options().addRepo(distRepo).outRepo("build/test/proto");
    System.out.println("Typechecking Ceylon test code...");
    JsModuleManagerFactory.setVerbose(true);
    TypeCheckerBuilder tcb = new TypeCheckerBuilder().verbose(false).moduleManagerFactory(new JsModuleManagerFactory(null)).usageWarnings(false);
    final ArrayList<File> excludes = new ArrayList<>();
    final ArrayList<File> resfiles = new ArrayList<>();
    final ArrayList<File> resdirs = new ArrayList<>();
    for (String dir : args) {
        final File d = new File(dir.charAt(1) == ':' ? dir.substring(2) : dir);
        if (dir.startsWith("X:")) {
            excludes.add(d);
        } else if (dir.startsWith("R:")) {
            resdirs.add(d);
        } else if (dir.startsWith("r:")) {
            resfiles.add(d);
        } else if (dir.startsWith("c:")) {
            opts.cwd(d);
        } else {
            tcb.addSrcDirectory(d);
            opts.addSrcDir(d);
        }
    }
    final RepositoryManager repoman = CeylonUtils.repoManager().cwd(opts.getCwd()).systemRepo(opts.getSystemRepo()).userRepos(opts.getRepos()).outRepo(opts.getOutRepo()).buildManager();
    tcb.setRepositoryManager(repoman);
    final TypeChecker typeChecker = tcb.getTypeChecker();
    for (File x : excludes) {
        String ap = x.getPath();
        // Fix for Windows
        if ('/' != File.separatorChar) {
            ap = ap.replace(File.separatorChar, '/');
        }
        for (PhasedUnit pu : typeChecker.getPhasedUnits().getPhasedUnits()) {
            if (pu.getUnit().getFullPath().startsWith(ap)) {
                typeChecker.getPhasedUnits().removePhasedUnitForRelativePath(pu.getPathRelativeToSrcDir());
            }
        }
    }
    TypeCache.doWithoutCaching(new Runnable() {

        @Override
        public void run() {
            typeChecker.process();
        }
    });
    if (typeChecker.getErrors() > 0) {
        System.exit(1);
    }
    System.out.println("Compiling in prototype style");
    opts.resourceDirs(resdirs);
    JsCompiler jsc = new JsCompiler(typeChecker, opts).stopOnErrors(true);
    ArrayList<File> sources = new ArrayList<>();
    for (String dir : args) {
        // The arg is src/test/ceylon for example
        addFilesToList(new File(dir), sources);
    }
    Collections.sort(sources);
    jsc.setSourceFiles(sources);
    jsc.setResourceFiles(resfiles);
    PrintWriter writer = new PrintWriter(System.out);
    if (!jsc.generate()) {
        jsc.printErrorsAndCount(writer);
    }
}
Also used : Options(org.eclipse.ceylon.compiler.js.util.Options) JsModuleManagerFactory(org.eclipse.ceylon.compiler.js.loader.JsModuleManagerFactory) TypeChecker(org.eclipse.ceylon.compiler.typechecker.TypeChecker) ArrayList(java.util.ArrayList) TypeCheckerBuilder(org.eclipse.ceylon.compiler.typechecker.TypeCheckerBuilder) PhasedUnit(org.eclipse.ceylon.compiler.typechecker.context.PhasedUnit) RepositoryManager(org.eclipse.ceylon.cmr.api.RepositoryManager) File(java.io.File) JsCompiler(org.eclipse.ceylon.compiler.js.JsCompiler) PrintWriter(java.io.PrintWriter)

Example 10 with RepositoryManager

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

the class TestModuleManager method loadJsModel.

private static void loadJsModel() {
    if (jstc == null) {
        System.out.println("Pass 2: Loading model from JS");
        final RepositoryManager repoman = CeylonUtils.repoManager().cwd(options.getCwd()).systemRepo(options.getSystemRepo()).userRepos(options.getRepos()).outRepo(options.getOutRepo()).buildManager();
        // .verbose(true);
        TypeCheckerBuilder tcb = new TypeCheckerBuilder().usageWarnings(false);
        tcb.moduleManagerFactory(new JsModuleManagerFactory((String) null));
        tcb.addSrcDirectory(new java.io.File("src/test/resources/loader/pass2"));
        tcb.setRepositoryManager(repoman);
        jstc = tcb.getTypeChecker();
        jstc.process();
    }
}
Also used : JsModuleManagerFactory(org.eclipse.ceylon.compiler.js.loader.JsModuleManagerFactory) RepositoryManager(org.eclipse.ceylon.cmr.api.RepositoryManager) TypeCheckerBuilder(org.eclipse.ceylon.compiler.typechecker.TypeCheckerBuilder)

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