Search in sources :

Example 1 with CeylonNewTool

use of org.eclipse.ceylon.tools.new_.CeylonNewTool in project ceylon by eclipse.

the class NewProjectToolTests method testHelloWorldCwd.

@Test
public void testHelloWorldCwd() throws Exception {
    ToolModel<CeylonNewTool> model = pluginLoader.loadToolModel("new");
    Assert.assertNotNull(model);
    Assert.assertTrue(model.isPorcelain());
    Path tmpPath = Files.createTempDirectory("ceylon-new-");
    File tmpDir = tmpPath.toFile();
    File srcTemplates = new File("../dist/templates");
    File dstTemplates = new File(tmpDir, "templates");
    FileUtil.copyAll(srcTemplates, dstTemplates);
    try {
        CeylonNewTool tool = pluginFactory.bindArguments(model, getMainTool(), args("--cwd", tmpDir.getAbsolutePath(), "--from=templates", "hello-world", "--module-name=org.example.hello", "--module-version=1", "--ant=true", "--eclipse=true", "--eclipse-project-name=hello", "target"));
        runTool(tool);
        assertFile(new File(tmpDir, "target/source/org/example/hello/module.ceylon"));
        assertFile(new File(tmpDir, "target/source/org/example/hello/package.ceylon"));
        assertFile(new File(tmpDir, "target/source/org/example/hello/run.ceylon"));
        assertFile(new File(tmpDir, "target/build.xml"));
        assertFile(new File(tmpDir, "target/.classpath"));
        assertFile(new File(tmpDir, "target/.project"));
        assertDir(new File(tmpDir, "target/.settings"));
    } finally {
        delete(tmpDir);
    }
}
Also used : Path(java.nio.file.Path) CeylonNewTool(org.eclipse.ceylon.tools.new_.CeylonNewTool) File(java.io.File) Test(org.junit.Test)

Example 2 with CeylonNewTool

use of org.eclipse.ceylon.tools.new_.CeylonNewTool in project ceylon by eclipse.

the class NewProjectToolTests method testHelloWorldNoAntNoEclipseCompiles.

@Test
public void testHelloWorldNoAntNoEclipseCompiles() throws Exception {
    ToolModel<CeylonNewTool> newModel = pluginLoader.loadToolModel("new");
    Assert.assertNotNull(newModel);
    Assert.assertTrue(newModel.isPorcelain());
    Path tmpPath = Files.createTempDirectory("ceylon-new-");
    File tmpDir = tmpPath.toFile();
    try {
        CeylonNewTool newTool = pluginFactory.bindArguments(newModel, getMainTool(), args("--from=../dist/templates", "hello-world", "--module-name=org.example.hello", "--module-version=1", "--ant=false", "--eclipse=false", tmpDir.getAbsolutePath()));
        runTool(newTool);
        ToolModel<CeylonCompileTool> compileModel = pluginLoader.loadToolModel("compile");
        Assert.assertNotNull(compileModel);
        CeylonCompileTool compileTool = pluginFactory.bindArguments(compileModel, getMainTool(), toolOptions("--src=" + tmpDir.getAbsolutePath() + "/source", "--out=" + tmpDir.getAbsolutePath(), "org.example.hello"));
        runTool(compileTool);
    } finally {
        delete(tmpDir);
    }
}
Also used : Path(java.nio.file.Path) CeylonCompileTool(org.eclipse.ceylon.compiler.CeylonCompileTool) CeylonNewTool(org.eclipse.ceylon.tools.new_.CeylonNewTool) File(java.io.File) Test(org.junit.Test)

Example 3 with CeylonNewTool

use of org.eclipse.ceylon.tools.new_.CeylonNewTool in project ceylon by eclipse.

the class NewProjectToolTests method testHelloWorld.

@Test
public void testHelloWorld() throws Exception {
    ToolModel<CeylonNewTool> model = pluginLoader.loadToolModel("new");
    Assert.assertNotNull(model);
    Assert.assertTrue(model.isPorcelain());
    Path tmpPath = Files.createTempDirectory("ceylon-new-");
    File tmpDir = tmpPath.toFile();
    try {
        CeylonNewTool tool = pluginFactory.bindArguments(model, getMainTool(), args("--from=../dist/templates", "hello-world", "--module-name=org.example.hello", "--module-version=1", "--ant=true", "--eclipse=true", "--eclipse-project-name=hello", tmpDir.getAbsolutePath()));
        runTool(tool);
        assertFile(new File(tmpDir, "source/org/example/hello/module.ceylon"));
        assertFile(new File(tmpDir, "source/org/example/hello/package.ceylon"));
        assertFile(new File(tmpDir, "source/org/example/hello/run.ceylon"));
        assertFile(new File(tmpDir, "build.xml"));
        assertFile(new File(tmpDir, ".classpath"));
        assertFile(new File(tmpDir, ".project"));
        assertDir(new File(tmpDir, ".settings"));
    } finally {
        delete(tmpDir);
    }
}
Also used : Path(java.nio.file.Path) CeylonNewTool(org.eclipse.ceylon.tools.new_.CeylonNewTool) File(java.io.File) Test(org.junit.Test)

Example 4 with CeylonNewTool

use of org.eclipse.ceylon.tools.new_.CeylonNewTool in project ceylon by eclipse.

the class NewProjectToolTests method testHelloWorldNoAntNoEclipse.

@Test
public void testHelloWorldNoAntNoEclipse() throws Exception {
    ToolModel<CeylonNewTool> model = pluginLoader.loadToolModel("new");
    Assert.assertNotNull(model);
    Assert.assertTrue(model.isPorcelain());
    Path tmpPath = Files.createTempDirectory("ceylon-new-");
    File tmpDir = tmpPath.toFile();
    try {
        CeylonNewTool tool = pluginFactory.bindArguments(model, getMainTool(), args("--from=../dist/templates", "hello-world", "--module-name=org.example.hello", "--module-version=1", "--ant=false", "--eclipse=false", tmpDir.getAbsolutePath()));
        runTool(tool);
        assertFile(new File(tmpDir, "source/org/example/hello/module.ceylon"));
        assertFile(new File(tmpDir, "source/org/example/hello/package.ceylon"));
        assertFile(new File(tmpDir, "source/org/example/hello/run.ceylon"));
        assertNotExists(new File(tmpDir, "build.xml"));
        assertNotExists(new File(tmpDir, ".classpath"));
        assertNotExists(new File(tmpDir, ".project"));
        assertNotExists(new File(tmpDir, ".settings"));
    } finally {
        delete(tmpDir);
    }
}
Also used : Path(java.nio.file.Path) CeylonNewTool(org.eclipse.ceylon.tools.new_.CeylonNewTool) File(java.io.File) Test(org.junit.Test)

Example 5 with CeylonNewTool

use of org.eclipse.ceylon.tools.new_.CeylonNewTool in project ceylon by eclipse.

the class NewProjectToolTests method testKeywordsInModuleName.

@Test
public void testKeywordsInModuleName() throws Exception {
    ToolModel<CeylonNewTool> model = pluginLoader.loadToolModel("new");
    Assert.assertNotNull(model);
    Assert.assertTrue(model.isPorcelain());
    Path tmpPath = Files.createTempDirectory("ceylon-new-");
    File tmpDir = tmpPath.toFile();
    try {
        CeylonNewTool tool = pluginFactory.bindArguments(model, getMainTool(), args("--from=../dist/templates", "hello-world", "--module-name=long.module", "--module-version=1", "--ant=false", "--eclipse=false", tmpDir.getAbsolutePath()));
        runTool(tool);
        File moduleFile = new File(tmpDir, "source/long/module/module.ceylon");
        assertFile(moduleFile);
        File packageFile = new File(tmpDir, "source/long/module/package.ceylon");
        assertFile(packageFile);
        assertFile(new File(tmpDir, "source/long/module/run.ceylon"));
        Pattern pattern = Pattern.compile(Pattern.quote("long.\\imodule"));
        assertMatchInFile(moduleFile, pattern);
        assertMatchInFile(packageFile, pattern);
    } finally {
        delete(tmpDir);
    }
}
Also used : Path(java.nio.file.Path) Pattern(java.util.regex.Pattern) CeylonNewTool(org.eclipse.ceylon.tools.new_.CeylonNewTool) File(java.io.File) Test(org.junit.Test)

Aggregations

File (java.io.File)5 Path (java.nio.file.Path)5 CeylonNewTool (org.eclipse.ceylon.tools.new_.CeylonNewTool)5 Test (org.junit.Test)5 Pattern (java.util.regex.Pattern)1 CeylonCompileTool (org.eclipse.ceylon.compiler.CeylonCompileTool)1