Search in sources :

Example 16 with CeylonCompileJsTool

use of org.eclipse.ceylon.compiler.js.CeylonCompileJsTool in project ceylon by eclipse.

the class CompileJsToolTest method testDefaultModule.

@Test
public void testDefaultModule() throws Exception {
    FileUtil.delete(new File("build/test-modules"));
    ToolModel<CeylonCompileJsTool> tool = pluginLoader.loadToolModel("compile-js");
    Assert.assertNotNull(tool);
    CeylonCompileJsTool jsc = pluginFactory.bindArguments(tool, getMainTool(), args("--source=src/test/resources/doc", "--resource=src/test/resources/res_test", "default"));
    jsc.run();
    checkCompilerResult("build/test-modules/default", "default");
    checkResources("build/test-modules/default", "default", "test.txt", "another_test.txt", "subdir/third.txt", "ROOT/inroot.txt", "ALTROOT/altroot.txt");
    checkExcludedResources("build/test-modules/default", "default", "m1res.txt", "m1/m1res.txt", "m1/ROOT/m1root.txt", "ROOT/m1root.txt", "m1/ALTROOT/altrootm1.txt");
}
Also used : CeylonCompileJsTool(org.eclipse.ceylon.compiler.js.CeylonCompileJsTool) File(java.io.File) Test(org.junit.Test)

Example 17 with CeylonCompileJsTool

use of org.eclipse.ceylon.compiler.js.CeylonCompileJsTool in project ceylon by eclipse.

the class CompileJsToolTest method testModuleWithAltRoot.

@Test
public void testModuleWithAltRoot() throws Exception {
    FileUtil.delete(new File("build/test-modules"));
    ToolModel<CeylonCompileJsTool> tool = pluginLoader.loadToolModel("compile-js");
    Assert.assertNotNull(tool);
    CeylonCompileJsTool jsc = pluginFactory.bindArguments(tool, getMainTool(), args("--source=src/test/resources/loader/pass1", "--resource=src/test/resources/res_test", "--resource-root=ALTROOT", "m1"));
    jsc.run();
    checkCompilerResult("build/test-modules/m1/0.1", "m1-0.1");
    checkResources("build/test-modules/m1/0.1", "m1-0.1", "altrootm1.txt", "m1/m1res.txt");
    checkExcludedResources("build/test-modules/m1/0.1", "m1-0.1", "test.txt", "another_test.txt", "subdir/third.txt", "ALTROOT/altroot.txt", "ROOT/inroot.txt");
}
Also used : CeylonCompileJsTool(org.eclipse.ceylon.compiler.js.CeylonCompileJsTool) File(java.io.File) Test(org.junit.Test)

Example 18 with CeylonCompileJsTool

use of org.eclipse.ceylon.compiler.js.CeylonCompileJsTool in project ceylon by eclipse.

the class RunJsTest method testResources.

@Test
public void testResources() throws Exception {
    // Compile a module with resources
    CeylonCompileJsTool compiler = new CeylonCompileJsTool();
    compiler.setRepositoryAsStrings(Arrays.asList("build/runtime"));
    compiler.setSource(Arrays.asList(new File("src/test/resources/doc")));
    compiler.setSkipSrcArchive(true);
    compiler.setResource(Arrays.asList(new File("src/test/resources/res_test")));
    compiler.setModule(Arrays.asList("default"));
    compiler.setOut("build/modules");
    compiler.run();
    // Run it, just to make sure the resources were exploded
    CeylonRunJsTool runner = new CeylonRunJsTool();
    runner.setModuleVersion("default");
    runner.setRun("run");
    runner.setRepositoryAsStrings(Arrays.asList("build/runtime", "build/modules"));
    runner.run();
    Assert.assertTrue("test.txt is missing", new File("build/modules/default/module-resources/test.txt").exists());
    Assert.assertTrue("another_test.txt is missing", new File("build/modules/default/module-resources/another_test.txt").exists());
    Assert.assertTrue("third.txt is missing", new File("build/modules/default/module-resources/subdir/third.txt").exists());
}
Also used : CeylonRunJsTool(org.eclipse.ceylon.compiler.js.CeylonRunJsTool) CeylonCompileJsTool(org.eclipse.ceylon.compiler.js.CeylonCompileJsTool) File(java.io.File) Test(org.junit.Test)

Example 19 with CeylonCompileJsTool

use of org.eclipse.ceylon.compiler.js.CeylonCompileJsTool in project ceylon by eclipse.

the class JavaScriptCompilerImpl method compile.

@Override
public boolean compile(CompilerOptions options, CompilationListener listener) {
    CeylonCompileJsTool tool = new CeylonCompileJsTool();
    if (options.getWorkingDirectory() != null) {
        tool.setCwd(new File(options.getWorkingDirectory()));
    }
    if (options.isVerbose())
        tool.setVerbose("");
    tool.setOffline(options.isOffline());
    tool.setTimeout(options.getTimeout());
    tool.setEncoding(options.getEncoding());
    tool.setNoDefRepos(options.isNoDefaultRepositories());
    try {
        tool.setRepositoryAsStrings(options.getUserRepositories());
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    tool.setSystemRepository(options.getSystemRepository());
    tool.setOut(options.getOutputRepository());
    tool.setSource(options.getSourcePath());
    tool.setResource(options.getResourcePath());
    if (options.getResourceRootName() != null) {
        tool.setResourceRoot(options.getResourceRootName());
    }
    // just mix them all
    List<String> moduleOrFile = new ArrayList<String>();
    moduleOrFile.addAll(options.getModules());
    moduleOrFile.addAll(fileToStringList(options.getFiles()));
    tool.setModule(moduleOrFile);
    tool.setDiagnosticListener(adapt(listener));
    tool.setThrowOnError(true);
    // FIXME: allow the user to capture stdout
    if (!options.isVerbose()) {
        // make the tool shut the hell up
        tool.setOut(new NullWriter());
    }
    try {
        tool.run();
    } catch (CompilerErrorException e) {
        return false;
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return true;
}
Also used : CeylonCompileJsTool(org.eclipse.ceylon.compiler.js.CeylonCompileJsTool) CompilerErrorException(org.eclipse.ceylon.compiler.js.CompilerErrorException) ArrayList(java.util.ArrayList) File(java.io.File) CompilerErrorException(org.eclipse.ceylon.compiler.js.CompilerErrorException)

Aggregations

File (java.io.File)19 CeylonCompileJsTool (org.eclipse.ceylon.compiler.js.CeylonCompileJsTool)19 Test (org.junit.Test)18 ArrayList (java.util.ArrayList)1 CeylonRunJsTool (org.eclipse.ceylon.compiler.js.CeylonRunJsTool)1 CompilerErrorException (org.eclipse.ceylon.compiler.js.CompilerErrorException)1 DiagnosticListener (org.eclipse.ceylon.compiler.js.DiagnosticListener)1