Search in sources :

Example 1 with ProjectTypeStep

use of com.intellij.ide.projectWizard.ProjectTypeStep in project intellij-community by JetBrains.

the class GradleProjectWizardTest method testGradleProject.

public void testGradleProject() throws Exception {
    final String projectName = "testProject";
    Project project = createProject(new Consumer<Step>() {

        @Override
        public void consume(Step step) {
            if (step instanceof ProjectTypeStep) {
                assertTrue(((ProjectTypeStep) step).setSelectedTemplate("Gradle", null));
                List<ModuleWizardStep> steps = myWizard.getSequence().getSelectedSteps();
                assertEquals(5, steps.size());
                final ProjectBuilder projectBuilder = myWizard.getProjectBuilder();
                assertInstanceOf(projectBuilder, GradleModuleBuilder.class);
                ((GradleModuleBuilder) projectBuilder).setName(projectName);
            }
        }
    });
    assertEquals(projectName, project.getName());
    Module[] modules = ModuleManager.getInstance(project).getModules();
    assertEquals(1, modules.length);
    final Module module = modules[0];
    assertTrue(ModuleRootManager.getInstance(module).isSdkInherited());
    assertEquals(projectName, module.getName());
    VirtualFile root = ProjectRootManager.getInstance(project).getContentRoots()[0];
    VirtualFile settingsScript = VfsUtilCore.findRelativeFile("settings.gradle", root);
    assertNotNull(settingsScript);
    assertEquals(String.format("rootProject.name = '%s'\n\n", projectName), StringUtil.convertLineSeparators(VfsUtilCore.loadText(settingsScript)));
    VirtualFile buildScript = VfsUtilCore.findRelativeFile("build.gradle", root);
    assertNotNull(buildScript);
    assertEquals("group '" + projectName + "'\n" + "version '1.0-SNAPSHOT'\n" + "\n" + "apply plugin: 'java'\n" + "\n" + "sourceCompatibility = 1.8\n" + "\n" + "repositories {\n" + "    mavenCentral()\n" + "}\n" + "\n" + "dependencies {\n" + "    testCompile group: 'junit', name: 'junit', version: '4.12'\n" + "}\n", StringUtil.convertLineSeparators(VfsUtilCore.loadText(buildScript)));
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) GradleModuleBuilder(org.jetbrains.plugins.gradle.service.project.wizard.GradleModuleBuilder) ProjectBuilder(com.intellij.ide.util.projectWizard.ProjectBuilder) List(java.util.List) ProjectTypeStep(com.intellij.ide.projectWizard.ProjectTypeStep) ModuleWizardStep(com.intellij.ide.util.projectWizard.ModuleWizardStep) Step(com.intellij.ide.wizard.Step) Module(com.intellij.openapi.module.Module) ProjectTypeStep(com.intellij.ide.projectWizard.ProjectTypeStep)

Aggregations

ProjectTypeStep (com.intellij.ide.projectWizard.ProjectTypeStep)1 ModuleWizardStep (com.intellij.ide.util.projectWizard.ModuleWizardStep)1 ProjectBuilder (com.intellij.ide.util.projectWizard.ProjectBuilder)1 Step (com.intellij.ide.wizard.Step)1 Module (com.intellij.openapi.module.Module)1 Project (com.intellij.openapi.project.Project)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 List (java.util.List)1 GradleModuleBuilder (org.jetbrains.plugins.gradle.service.project.wizard.GradleModuleBuilder)1