Search in sources :

Example 1 with NewLiferayWorkspaceOp

use of com.liferay.ide.project.core.workspace.NewLiferayWorkspaceOp in project liferay-ide by liferay.

the class LiferayWorkspaceUtilTests method testLiferayWorkspaceUtil.

@Test
public void testLiferayWorkspaceUtil() throws Exception {
    NewLiferayWorkspaceOp op = NewLiferayWorkspaceOp.TYPE.instantiate();
    op.setWorkspaceName("test-liferay-workspace");
    if (op.validation().ok()) {
        op.execute(new ProgressMonitor());
    }
    IProject workspaceProject = CoreUtil.getProject("test-liferay-workspace");
    assertTrue(workspaceProject != null);
    assertTrue(workspaceProject.exists());
    String workspaceLocation = workspaceProject.getLocation().toPortableString();
    String homeValue = LiferayWorkspaceUtil.getHomeDir(workspaceLocation);
    assertTrue(homeValue.equals("bundles"));
    String modulesValue = LiferayWorkspaceUtil.getModulesDir(workspaceProject);
    assertTrue(modulesValue.equals("modules"));
    String pluginSdkValue = LiferayWorkspaceUtil.getPluginsSDKDir(workspaceLocation);
    assertTrue(pluginSdkValue.equals("plugins-sdk"));
    String themesValue = LiferayWorkspaceUtil.getThemesDir(workspaceProject);
    assertTrue(themesValue.equals("themes"));
    String warsValue = LiferayWorkspaceUtil.getWarsDirs(workspaceProject)[0];
    assertTrue(warsValue.equals("wars"));
    File propertiesFile = new File(workspaceLocation + "/gradle.properties");
    Properties prop = PropertiesUtil.loadProperties(propertiesFile);
    prop.setProperty(LiferayWorkspaceUtil.LIFERAY_WORKSPACE_HOME_DIR, "bundles1");
    prop.setProperty(LiferayWorkspaceUtil.LIFERAY_WORKSPACE_MODULES_DIR, "tests,modules");
    prop.setProperty(LiferayWorkspaceUtil.LIFERAY_WORKSPACE_PLUGINS_SDK_DIR, "plugins-sdk1");
    prop.setProperty(LiferayWorkspaceUtil.LIFERAY_WORKSPACE_THEMES_DIR, "themes1");
    prop.setProperty(LiferayWorkspaceUtil.LIFERAY_WORKSPACE_WARS_DIR, "test1,wars1,");
    PropertiesUtil.saveProperties(prop, propertiesFile);
    workspaceProject.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
    homeValue = LiferayWorkspaceUtil.getHomeDir(workspaceLocation);
    assertTrue(homeValue.equals("bundles1"));
    modulesValue = LiferayWorkspaceUtil.getModulesDir(workspaceProject);
    assertTrue(modulesValue.equals("tests"));
    pluginSdkValue = LiferayWorkspaceUtil.getPluginsSDKDir(workspaceLocation);
    assertTrue(pluginSdkValue.equals("plugins-sdk1"));
    themesValue = LiferayWorkspaceUtil.getThemesDir(workspaceProject);
    assertTrue(themesValue.equals("themes1"));
    warsValue = LiferayWorkspaceUtil.getWarsDirs(workspaceProject)[0];
    assertTrue(warsValue.equals("test1"));
    workspaceProject.delete(true, true, new NullProgressMonitor());
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ProgressMonitor(org.eclipse.sapphire.modeling.ProgressMonitor) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) NewLiferayWorkspaceOp(com.liferay.ide.project.core.workspace.NewLiferayWorkspaceOp) Properties(java.util.Properties) File(java.io.File) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test)

Example 2 with NewLiferayWorkspaceOp

use of com.liferay.ide.project.core.workspace.NewLiferayWorkspaceOp in project liferay-ide by liferay.

the class NewLiferayWorkspaceOpTests method testNewLiferayWorkspaceOp.

@Test
public void testNewLiferayWorkspaceOp() throws Exception {
    ILiferayProjectImporter importer = LiferayCore.getImporter("gradle");
    File eclipseWorkspaceLocation = CoreUtil.getWorkspaceRoot().getLocation().toFile();
    URL projectZipUrl = Platform.getBundle("com.liferay.ide.project.core.tests").getEntry("projects/existingProject.zip");
    final File projectZipFile = new File(FileLocator.toFileURL(projectZipUrl).getFile());
    ZipUtil.unzip(projectZipFile, eclipseWorkspaceLocation);
    File projectFolder = new File(eclipseWorkspaceLocation, "existingProject");
    waitForBuildAndValidation();
    importer.importProjects(projectFolder.getAbsolutePath(), new NullProgressMonitor());
    NewLiferayWorkspaceOp op = NewLiferayWorkspaceOp.TYPE.instantiate();
    op.setWorkspaceName("existingProject");
    String message = op.validation().message();
    assertNotNull(message);
    assertEquals("A project with that name(ignore case) already exists.", message);
    op.setWorkspaceName("ExistingProject");
    message = op.validation().message();
    assertTrue(message.equals("A project with that name(ignore case) already exists."));
    String projectName = "test-liferay-workspace";
    IPath workspaceLocation = CoreUtil.getWorkspaceRoot().getLocation();
    op.setWorkspaceName(projectName);
    op.setUseDefaultLocation(false);
    op.setLocation(workspaceLocation.toPortableString());
    op.execute(new ProgressMonitor());
    String wsLocation = workspaceLocation.append(projectName).toPortableString();
    File wsFile = new File(wsLocation);
    assertTrue(wsFile.exists());
    assertTrue(LiferayWorkspaceUtil.isValidWorkspaceLocation(wsLocation));
    File propertiesFile = new File(wsFile, "gradle.properties");
    Properties prop = PropertiesUtil.loadProperties(propertiesFile);
    prop.setProperty(LiferayWorkspaceUtil.LIFERAY_WORKSPACE_WARS_DIR, "wars,wars2");
    PropertiesUtil.saveProperties(prop, propertiesFile);
    NewLiferayModuleProjectOp moduleProjectOp = NewLiferayModuleProjectOp.TYPE.instantiate();
    moduleProjectOp.setProjectName("testThemeWarDefault");
    moduleProjectOp.setProjectTemplateName("theme");
    moduleProjectOp.execute(new ProgressMonitor());
    waitForBuildAndValidation();
    assertTrue(CoreUtil.getProject("testThemeWarDefault").exists());
    moduleProjectOp = NewLiferayModuleProjectOp.TYPE.instantiate();
    moduleProjectOp.setProjectName("testThemeWarNotDefault");
    moduleProjectOp.setProjectTemplateName("theme");
    moduleProjectOp.setUseDefaultLocation(false);
    moduleProjectOp.setLocation(wsLocation + "/wars");
    moduleProjectOp.execute(new ProgressMonitor());
    waitForBuildAndValidation();
    assertTrue(CoreUtil.getProject("testThemeWarNotDefault").exists());
    moduleProjectOp = NewLiferayModuleProjectOp.TYPE.instantiate();
    moduleProjectOp.setProjectName("testThemeWar2");
    moduleProjectOp.setProjectTemplateName("theme");
    moduleProjectOp.setUseDefaultLocation(false);
    moduleProjectOp.setLocation(wsLocation + "/wars2");
    moduleProjectOp.execute(new ProgressMonitor());
    waitForBuildAndValidation();
    assertTrue(CoreUtil.getProject("testThemeWar2").exists());
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ProgressMonitor(org.eclipse.sapphire.modeling.ProgressMonitor) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) NewLiferayWorkspaceOp(com.liferay.ide.project.core.workspace.NewLiferayWorkspaceOp) ILiferayProjectImporter(com.liferay.ide.core.ILiferayProjectImporter) IPath(org.eclipse.core.runtime.IPath) NewLiferayModuleProjectOp(com.liferay.ide.project.core.modules.NewLiferayModuleProjectOp) Properties(java.util.Properties) File(java.io.File) URL(java.net.URL) Test(org.junit.Test)

Example 3 with NewLiferayWorkspaceOp

use of com.liferay.ide.project.core.workspace.NewLiferayWorkspaceOp in project liferay-ide by liferay.

the class NewLiferayWorkspaceWizard method performPostFinish.

@Override
protected void performPostFinish() {
    super.performPostFinish();
    final NewLiferayWorkspaceOp op = element().nearest(NewLiferayWorkspaceOp.class);
    final IProject newProject = CoreUtil.getProject(op.getWorkspaceName().content());
    try {
        addToWorkingSets(newProject);
    } catch (Exception ex) {
        ProjectUI.logError("Unable to add project to working set", ex);
    }
    openLiferayPerspective(newProject);
    ProjectExplorerLayoutUtil.setNested(true);
}
Also used : NewLiferayWorkspaceOp(com.liferay.ide.project.core.workspace.NewLiferayWorkspaceOp) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException)

Example 4 with NewLiferayWorkspaceOp

use of com.liferay.ide.project.core.workspace.NewLiferayWorkspaceOp in project liferay-ide by liferay.

the class NewMavenLiferayWorkspaceOpTests method testNewMavenLiferayWorkspaceInitBundle.

@Test
public void testNewMavenLiferayWorkspaceInitBundle() throws Exception {
    NewLiferayWorkspaceOp op = NewLiferayWorkspaceOp.TYPE.instantiate();
    String projectName = "test-liferay-workspace";
    IPath workspaceLocation = CoreUtil.getWorkspaceRoot().getLocation();
    op.setWorkspaceName(projectName);
    op.setUseDefaultLocation(false);
    op.setLocation(workspaceLocation.toPortableString());
    op.setProjectProvider("maven-liferay-workspace");
    op.setProvisionLiferayBundle(true);
    String bundleUrl = op.getBundleUrl().content(true);
    assertEquals("https://cdn.lfrs.sl/releases.liferay.com/portal/7.0.4-ga5/liferay-ce-portal-tomcat-7.0-ga5-20171018150113838.zip", bundleUrl);
    op.execute(new ProgressMonitor());
    String projectLocation = workspaceLocation.append(projectName).toPortableString();
    File pomFile = new File(projectLocation, "pom.xml");
    assertTrue(pomFile.exists());
    File bundleDir = new File(projectLocation, "bundles");
    assertTrue(bundleDir.exists());
    String content = FileUtil.readContents(pomFile);
    assertTrue(content.contains("com.liferay.portal.tools.bundle.support"));
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ProgressMonitor(org.eclipse.sapphire.modeling.ProgressMonitor) NewLiferayWorkspaceOp(com.liferay.ide.project.core.workspace.NewLiferayWorkspaceOp) IPath(org.eclipse.core.runtime.IPath) File(java.io.File) Test(org.junit.Test)

Example 5 with NewLiferayWorkspaceOp

use of com.liferay.ide.project.core.workspace.NewLiferayWorkspaceOp in project liferay-ide by liferay.

the class NewMavenLiferayWorkspaceOpTests method testNewMavenLiferayWorkspaceOp.

@Test
public void testNewMavenLiferayWorkspaceOp() throws Exception {
    NewLiferayWorkspaceOp op = NewLiferayWorkspaceOp.TYPE.instantiate();
    String projectName = "test-liferay-workspace";
    IPath workspaceLocation = CoreUtil.getWorkspaceRoot().getLocation();
    op.setWorkspaceName(projectName);
    op.setUseDefaultLocation(false);
    op.setLocation(workspaceLocation.toPortableString());
    op.setProjectProvider("maven-liferay-workspace");
    op.execute(new ProgressMonitor());
    String projectLocation = workspaceLocation.append(projectName).toPortableString();
    File pomFile = new File(projectLocation, "pom.xml");
    assertTrue(pomFile.exists());
    String content = FileUtil.readContents(pomFile);
    assertTrue(content.contains("com.liferay.portal.tools.bundle.support"));
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ProgressMonitor(org.eclipse.sapphire.modeling.ProgressMonitor) NewLiferayWorkspaceOp(com.liferay.ide.project.core.workspace.NewLiferayWorkspaceOp) IPath(org.eclipse.core.runtime.IPath) File(java.io.File) Test(org.junit.Test)

Aggregations

NewLiferayWorkspaceOp (com.liferay.ide.project.core.workspace.NewLiferayWorkspaceOp)6 File (java.io.File)5 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)5 ProgressMonitor (org.eclipse.sapphire.modeling.ProgressMonitor)5 Test (org.junit.Test)5 IPath (org.eclipse.core.runtime.IPath)4 Properties (java.util.Properties)2 IProject (org.eclipse.core.resources.IProject)2 ILiferayProjectImporter (com.liferay.ide.core.ILiferayProjectImporter)1 NewLiferayModuleProjectOp (com.liferay.ide.project.core.modules.NewLiferayModuleProjectOp)1 URL (java.net.URL)1 CoreException (org.eclipse.core.runtime.CoreException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1