Search in sources :

Example 1 with CeylonClasspathTool

use of org.eclipse.ceylon.tools.classpath.CeylonClasspathTool in project ceylon by eclipse.

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.setModules(Arrays.asList(moduleSpec));
    cpTool.setRepositoryAsStrings(Arrays.asList(outRepo.getAbsolutePath()));
    cpTool.setSystemRepository("../dist/dist/repo");
    cpTool.setNoDefRepos(true);
    cpTool.setOffline(true);
    StringBuilder sb = new StringBuilder();
    cpTool.setOut(sb);
    cpTool.initialize(null);
    cpTool.run();
    String classpath = sb.toString();
    List<String> args = new ArrayList<String>(Arrays.asList(path, "-cp", classpath));
    // args.add("-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y");
    if (JDKUtils.jdk.providesVersion(JDK.JDK9.version)) {
        args.add("-XaddExports:java.base/sun.reflect.annotation=ALL-UNNAMED");
    }
    args.add("org.eclipse.ceylon.compiler.java.runtime.Main");
    args.add(moduleSpec);
    args.add(runClass);
    ProcessBuilder processBuilder = new ProcessBuilder(args);
    processBuilder.inheritIO();
    Process process = processBuilder.start();
    int exit = process.waitFor();
    Assert.assertTrue(exit == 0);
}
Also used : ArrayList(java.util.ArrayList) CeylonClasspathTool(org.eclipse.ceylon.tools.classpath.CeylonClasspathTool)

Example 2 with CeylonClasspathTool

use of org.eclipse.ceylon.tools.classpath.CeylonClasspathTool in project ceylon by eclipse.

the class ClasspathToolTests method testNoArgs.

@Test
public void testNoArgs() throws Exception {
    ToolModel<CeylonClasspathTool> model = pluginLoader.loadToolModel("classpath");
    Assert.assertNotNull(model);
    try {
        CeylonClasspathTool tool = pluginFactory.bindArguments(model, getMainTool(), Collections.<String>emptyList());
        Assert.fail();
    } catch (OptionArgumentException e) {
    // asserting this is thrown
    }
}
Also used : OptionArgumentException(org.eclipse.ceylon.common.tool.OptionArgumentException) CeylonClasspathTool(org.eclipse.ceylon.tools.classpath.CeylonClasspathTool) Test(org.junit.Test)

Example 3 with CeylonClasspathTool

use of org.eclipse.ceylon.tools.classpath.CeylonClasspathTool in project ceylon by eclipse.

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(), toolOptions("io.cayla.web/0.3.0"));
    try {
        tool.run();
    } catch (ToolError err) {
        Assert.assertEquals("Module conflict error prevented classpath generation: try running \"ceylon info --print-overrides 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(org.eclipse.ceylon.common.tool.ToolError) CeylonClasspathTool(org.eclipse.ceylon.tools.classpath.CeylonClasspathTool) Test(org.junit.Test)

Example 4 with CeylonClasspathTool

use of org.eclipse.ceylon.tools.classpath.CeylonClasspathTool in project ceylon by eclipse.

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(), toolOptions("naskduhqwedmansd"));
    try {
        tool.run();
        Assert.fail();
    } catch (ToolUsageError x) {
        Assert.assertTrue(x.getMessage().contains("Module naskduhqwedmansd not found"));
    }
}
Also used : ToolUsageError(org.eclipse.ceylon.common.tool.ToolUsageError) CeylonClasspathTool(org.eclipse.ceylon.tools.classpath.CeylonClasspathTool) Test(org.junit.Test)

Example 5 with CeylonClasspathTool

use of org.eclipse.ceylon.tools.classpath.CeylonClasspathTool in project ceylon by eclipse.

the class ClasspathToolTests method testRecursiveDependenciesForce.

@Test
public void testRecursiveDependenciesForce() throws Exception {
    ToolModel<CeylonClasspathTool> model = pluginLoader.loadToolModel("classpath");
    Assert.assertNotNull(model);
    CeylonClasspathTool tool = pluginFactory.bindArguments(model, getMainTool(), toolOptions("--force", "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(org.eclipse.ceylon.tools.classpath.CeylonClasspathTool) Test(org.junit.Test)

Aggregations

CeylonClasspathTool (org.eclipse.ceylon.tools.classpath.CeylonClasspathTool)9 Test (org.junit.Test)8 ToolUsageError (org.eclipse.ceylon.common.tool.ToolUsageError)2 ArrayList (java.util.ArrayList)1 OptionArgumentException (org.eclipse.ceylon.common.tool.OptionArgumentException)1 ToolError (org.eclipse.ceylon.common.tool.ToolError)1 Ignore (org.junit.Ignore)1