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());
}
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());
}
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);
}
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"));
}
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"));
}
Aggregations