use of com.liferay.ide.project.core.modules.NewLiferayModuleProjectOp in project liferay-ide by liferay.
the class NewLiferayModuleProjectWizard method performPostFinish.
@Override
protected void performPostFinish() {
super.performPostFinish();
final List<IProject> projects = new ArrayList<>();
final NewLiferayModuleProjectOp op = element().nearest(NewLiferayModuleProjectOp.class);
ElementList<ProjectName> projectNames = op.getProjectNames();
for (ProjectName projectName : projectNames) {
final IProject newProject = CoreUtil.getProject(projectName.getName().content());
if (newProject != null) {
projects.add(newProject);
}
}
for (final IProject project : projects) {
try {
addToWorkingSets(project);
} catch (Exception ex) {
ProjectUI.logError("Unable to add project to working set", ex);
}
}
if (ListUtil.isNotEmpty(projects)) {
IProject finalProject = projects.get(0);
openLiferayPerspective(finalProject);
}
}
use of com.liferay.ide.project.core.modules.NewLiferayModuleProjectOp in project liferay-ide by liferay.
the class NewLiferayComponentOpTests method testNewLiferayComponentBndAndGradleForPortleActionCommandAndRest.
@Test
public void testNewLiferayComponentBndAndGradleForPortleActionCommandAndRest() throws Exception {
NewLiferayModuleProjectOp pop = NewLiferayModuleProjectOp.TYPE.instantiate();
pop.setProjectName("testGradleModuleComponentBnd");
pop.setProjectTemplateName("portlet");
pop.setProjectProvider("gradle-module");
Status modulePorjectStatus = NewLiferayModuleProjectOpMethods.execute(pop, ProgressMonitorBridge.create(new NullProgressMonitor()));
assertTrue(modulePorjectStatus.ok());
IProject modPorject = CoreUtil.getProject(pop.getProjectName().content());
modPorject.open(new NullProgressMonitor());
NewLiferayComponentOp cop = NewLiferayComponentOp.TYPE.instantiate();
cop.setProjectName(pop.getProjectName().content());
cop.setComponentClassTemplateName("PortletActionCommand");
NewLiferayComponentOpMethods.execute(cop, ProgressMonitorBridge.create(new NullProgressMonitor()));
IFile bgd = modPorject.getFile("bnd.bnd");
String bndcontent = FileUtil.readContents(bgd.getLocation().toFile(), true);
String bndConfig = "-includeresource: \\" + System.getProperty("line.separator") + "\t" + "@com.liferay.util.bridges-2.0.0.jar!/com/liferay/util/bridges/freemarker/FreeMarkerPortlet.class,\\" + System.getProperty("line.separator") + "\t" + "@com.liferay.util.taglib-2.0.0.jar!/META-INF/*.tld" + System.getProperty("line.separator");
assertTrue(bndcontent.contains(bndConfig));
IFile buildgrade = modPorject.getFile("build.gradle");
String buildgradeContent = FileUtil.readContents(buildgrade.getLocation().toFile(), true);
assertTrue(buildgradeContent.contains("compile group: \"com.liferay.portal\", name:\"com.liferay.util.bridges\", version:\"2.0.0\""));
assertTrue(buildgradeContent.contains("compile group: \"org.osgi\", name:\"org.osgi.service.component.annotations\", version:\"1.3.0\""));
NewLiferayComponentOp copRest = NewLiferayComponentOp.TYPE.instantiate();
copRest.setProjectName(pop.getProjectName().content());
copRest.setComponentClassTemplateName("RestService");
NewLiferayComponentOpMethods.execute(copRest, ProgressMonitorBridge.create(new NullProgressMonitor()));
bgd = modPorject.getFile("bnd.bnd");
bndcontent = FileUtil.readContents(bgd.getLocation().toFile(), true);
assertTrue(bndcontent.contains(bndConfig));
final String restConfig = "Require-Capability: osgi.contract; filter:=\"(&(osgi.contract=JavaJAXRS)(version=2))\"";
assertTrue(bndcontent.contains(restConfig));
buildgrade = modPorject.getFile("build.gradle");
buildgradeContent = FileUtil.readContents(buildgrade.getLocation().toFile(), true);
assertTrue(buildgradeContent.contains("compile group: \"javax.ws.rs\", name:\"javax.ws.rs-api\", version:\"2.0.1\""));
NewLiferayComponentOp copAuth = NewLiferayComponentOp.TYPE.instantiate();
copAuth.setProjectName(pop.getProjectName().content());
copAuth.setComponentClassTemplateName("Authenticator");
NewLiferayComponentOpMethods.execute(copAuth, ProgressMonitorBridge.create(new NullProgressMonitor()));
bgd = modPorject.getFile("bnd.bnd");
bndcontent = FileUtil.readContents(bgd.getLocation().toFile(), true);
bndConfig = "-includeresource: \\" + System.getProperty("line.separator") + "\t" + "@com.liferay.util.bridges-2.0.0.jar!/com/liferay/util/bridges/freemarker/FreeMarkerPortlet.class,\\" + System.getProperty("line.separator") + "\t" + "@com.liferay.util.taglib-2.0.0.jar!/META-INF/*.tld,\\" + System.getProperty("line.separator") + "\t" + "@shiro-core-1.1.0.jar";
assertTrue(bndcontent.contains(bndConfig));
buildgrade = modPorject.getFile("build.gradle");
buildgradeContent = FileUtil.readContents(buildgrade.getLocation().toFile(), true);
assertTrue(buildgradeContent.contains("compile group: \"org.apache.shiro\", name:\"shiro-core\", version:\"1.1.0\""));
NewLiferayComponentOp copStruts = NewLiferayComponentOp.TYPE.instantiate();
copStruts.setProjectName(pop.getProjectName().content());
copStruts.setComponentClassTemplateName("StrutsAction");
NewLiferayComponentOpMethods.execute(copStruts, ProgressMonitorBridge.create(new NullProgressMonitor()));
bgd = modPorject.getFile("bnd.bnd");
bndcontent = FileUtil.readContents(bgd.getLocation().toFile(), true);
bndConfig = "Web-ContextPath: /TestgradlemodulecomponentbndStrutsAction";
assertTrue(bndcontent.contains(bndConfig));
}
use of com.liferay.ide.project.core.modules.NewLiferayModuleProjectOp in project liferay-ide by liferay.
the class NewLiferayComponentOpTests method testNewLiferayComponentStrutsAction.
@Test
public void testNewLiferayComponentStrutsAction() throws Exception {
NewLiferayModuleProjectOp op = NewLiferayModuleProjectOp.TYPE.instantiate();
op.setProjectName("testGradleStrutsActionComponent");
op.setProjectTemplateName("portlet");
op.setProjectProvider("gradle-module");
Status modulePorjectStatus = NewLiferayModuleProjectOpMethods.execute(op, ProgressMonitorBridge.create(new NullProgressMonitor()));
assertTrue(modulePorjectStatus.ok());
IProject modProject = CoreUtil.getProject(op.getProjectName().content());
modProject.open(new NullProgressMonitor());
NewLiferayComponentOp cop = NewLiferayComponentOp.TYPE.instantiate();
cop.setProjectName(op.getProjectName().content());
cop.setComponentClassTemplateName("StrutsAction");
Status status = NewLiferayComponentOpMethods.execute(cop, ProgressMonitorBridge.create(new NullProgressMonitor()));
assertEquals(Status.createOkStatus(), status);
IFile javaFile = modProject.getFile("/src/main/java/testGradleStrutsActionComponent" + "/portlet/TestgradlestrutsactioncomponentStrutsAction.java");
assertTrue(javaFile.exists());
String javaFileContent = FileUtil.readContents(javaFile.getLocation().toFile(), true);
assertTrue(javaFileContent.contains("osgi.web.symbolicname=testGradleStrutsActionComponent"));
IFile jspFile = modProject.getFile("/src/main/resources/META-INF/resources" + "/testgradlestrutsactioncomponentstrutsaction/html/portal/testgradlestrutsactioncomponent.jsp");
assertTrue(jspFile.exists());
String jspFileContent = FileUtil.readContents(jspFile.getLocation().toFile(), true);
assertTrue(jspFileContent.contains("/testgradlestrutsactioncomponentstrutsaction/html/init.jsp"));
}
use of com.liferay.ide.project.core.modules.NewLiferayModuleProjectOp in project liferay-ide by liferay.
the class NewLiferayModuleProjectOpTests method testNewLiferayModuleProjectDefaultValueServiceIsListeningToProjectTemplateName.
@Test
@Ignore
public void testNewLiferayModuleProjectDefaultValueServiceIsListeningToProjectTemplateName() throws Exception {
NewLiferayModuleProjectOp op = NewLiferayModuleProjectOp.TYPE.instantiate();
op.setProjectName("my.test.project");
op.setProjectTemplateName("activator");
assertEquals("MyTestProject", op.getComponentName().content(true));
op.setProjectTemplateName("portlet");
assertEquals("MyTestProject", op.getComponentName().content(true));
op.setProjectTemplateName("mvc-portlet");
assertEquals("MyTestProject", op.getComponentName().content(true));
op.setProjectTemplateName("service");
assertEquals("MyTestProject", op.getComponentName().content(true));
op.setProjectTemplateName("service-wrapper");
assertEquals("MyTestProject", op.getComponentName().content(true));
op.setProjectTemplateName("service-builder");
assertEquals("MyTestProject", op.getComponentName().content(true));
}
use of com.liferay.ide.project.core.modules.NewLiferayModuleProjectOp in project liferay-ide by liferay.
the class NewLiferayModuleProjectOpTests method testNewLiferayModuleProjectDefaultValueServiceDashes.
@Test
@Ignore
public void testNewLiferayModuleProjectDefaultValueServiceDashes() throws Exception {
NewLiferayModuleProjectOp op = NewLiferayModuleProjectOp.TYPE.instantiate();
op.setProjectName("my-test-project");
op.setProjectTemplateName("portlet");
assertEquals("MyTestProject", op.getComponentName().content(true));
}
Aggregations