Search in sources :

Example 1 with CeylonClasspathTool

use of com.redhat.ceylon.tools.classpath.CeylonClasspathTool in project ceylon-compiler by ceylon.

the class CeylonModuleRunner method runModuleInNewJvm.

protected void runModuleInNewJvm(String module, String version, String runClass) throws Exception {
    String path = System.getProperty("java.home") + File.separator + "bin" + File.separator + "java";
    String moduleSpec = Module.DEFAULT_MODULE_NAME.equals(module) ? module : (module + "/" + version);
    CeylonClasspathTool cpTool = new CeylonClasspathTool();
    cpTool.setModule(moduleSpec);
    cpTool.setRepositoryAsStrings(Arrays.asList(outRepo.getAbsolutePath()));
    cpTool.setSystemRepository("../ceylon-dist/dist/repo");
    cpTool.setNoDefRepos(true);
    cpTool.setOffline(true);
    StringBuilder sb = new StringBuilder();
    cpTool.setOut(sb);
    cpTool.run();
    String classpath = sb.toString();
    ProcessBuilder processBuilder = new ProcessBuilder(path, "-cp", classpath, Main.class.getName(), moduleSpec, runClass);
    processBuilder.inheritIO();
    Process process = processBuilder.start();
    int exit = process.waitFor();
    Assert.assertTrue(exit == 0);
}
Also used : CeylonClasspathTool(com.redhat.ceylon.tools.classpath.CeylonClasspathTool) Main(com.redhat.ceylon.compiler.java.runtime.Main)

Example 2 with CeylonClasspathTool

use of com.redhat.ceylon.tools.classpath.CeylonClasspathTool in project ceylon-compiler by ceylon.

the class ClasspathToolTests method testMissingModule.

@Test
public void testMissingModule() throws Exception {
    ToolModel<CeylonClasspathTool> model = pluginLoader.loadToolModel("classpath");
    Assert.assertNotNull(model);
    CeylonClasspathTool tool = pluginFactory.bindArguments(model, getMainTool(), Collections.<String>singletonList("naskduhqwedmansd"));
    try {
        tool.run();
        Assert.fail();
    } catch (ToolUsageError x) {
        Assert.assertTrue(x.getMessage().contains("Module naskduhqwedmansd not found"));
    }
}
Also used : ToolUsageError(com.redhat.ceylon.common.tool.ToolUsageError) CeylonClasspathTool(com.redhat.ceylon.tools.classpath.CeylonClasspathTool) Test(org.junit.Test)

Example 3 with CeylonClasspathTool

use of com.redhat.ceylon.tools.classpath.CeylonClasspathTool in project ceylon-compiler by ceylon.

the class ClasspathToolTests method testModuleNameAlone.

@Test
public void testModuleNameAlone() throws Exception {
    ToolModel<CeylonClasspathTool> model = pluginLoader.loadToolModel("classpath");
    Assert.assertNotNull(model);
    CeylonClasspathTool tool = pluginFactory.bindArguments(model, getMainTool(), Collections.<String>singletonList("ceylon.language"));
    StringBuilder b = new StringBuilder();
    tool.setOut(b);
    tool.run();
    String cp = b.toString();
    Assert.assertTrue(cp.contains("ceylon.language-" + Versions.CEYLON_VERSION_NUMBER + ".car"));
}
Also used : CeylonClasspathTool(com.redhat.ceylon.tools.classpath.CeylonClasspathTool) Test(org.junit.Test)

Example 4 with CeylonClasspathTool

use of com.redhat.ceylon.tools.classpath.CeylonClasspathTool in project ceylon-compiler by ceylon.

the class ClasspathToolTests method testRecursiveDependencies.

@Test
public void testRecursiveDependencies() throws Exception {
    ToolModel<CeylonClasspathTool> model = pluginLoader.loadToolModel("classpath");
    Assert.assertNotNull(model);
    CeylonClasspathTool tool = pluginFactory.bindArguments(model, getMainTool(), Arrays.asList("io.cayla.web/0.3.0"));
    try {
        tool.run();
    } catch (ToolError err) {
        Assert.assertEquals("Module conflict error prevented classpath generation: try running \"ceylon info --suggest-override io.cayla.web/0.3.0\" to display an override file you can use with \"ceylon classpath --overrides override.xml io.cayla.web/0.3.0\" or try with \"ceylon classpath --force io.cayla.web/0.3.0\" to select the latest versions", err.getMessage());
    }
}
Also used : ToolError(com.redhat.ceylon.common.tool.ToolError) CeylonClasspathTool(com.redhat.ceylon.tools.classpath.CeylonClasspathTool) Test(org.junit.Test)

Example 5 with CeylonClasspathTool

use of com.redhat.ceylon.tools.classpath.CeylonClasspathTool in project ceylon-compiler by ceylon.

the class ClasspathToolTests method testRecursiveDependenciesOverride.

@Test
public void testRecursiveDependenciesOverride() throws Exception {
    ToolModel<CeylonClasspathTool> model = pluginLoader.loadToolModel("classpath");
    Assert.assertNotNull(model);
    CeylonClasspathTool tool = pluginFactory.bindArguments(model, getMainTool(), Arrays.asList("--overrides", getPackagePath() + "/overrides.xml", "io.cayla.web/0.3.0"));
    StringBuilder b = new StringBuilder();
    tool.setOut(b);
    tool.run();
    String cp = b.toString();
    Assert.assertTrue(cp.contains("org.jboss.logging-3.1.3.GA.jar"));
    Assert.assertFalse(cp.contains("org.jboss.logging-3.1.2.GA.jar"));
}
Also used : CeylonClasspathTool(com.redhat.ceylon.tools.classpath.CeylonClasspathTool) Test(org.junit.Test)

Aggregations

CeylonClasspathTool (com.redhat.ceylon.tools.classpath.CeylonClasspathTool)8 Test (org.junit.Test)7 ToolUsageError (com.redhat.ceylon.common.tool.ToolUsageError)2 OptionArgumentException (com.redhat.ceylon.common.tool.OptionArgumentException)1 ToolError (com.redhat.ceylon.common.tool.ToolError)1 Main (com.redhat.ceylon.compiler.java.runtime.Main)1