use of com.liferay.ide.project.core.modules.NewLiferayModuleProjectOp in project liferay-ide by liferay.
the class MavenModuleProjectTests method testNewLiferayComponentBndAndMavenForPortleActionCommandAndRest.
@Test
public void testNewLiferayComponentBndAndMavenForPortleActionCommandAndRest() throws Exception {
NewLiferayModuleProjectOp pop = NewLiferayModuleProjectOp.TYPE.instantiate();
pop.setProjectName("testMavenModuleComponentBnd");
pop.setProjectTemplateName("portlet");
pop.setProjectProvider("maven-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 pomFile = modPorject.getFile(IMavenConstants.POM_FILE_NAME);
final IMaven maven = MavenPlugin.getMaven();
Model model = maven.readModel(pomFile.getLocation().toFile());
List<Dependency> dependencies = model.getDependencies();
boolean hasDependency = false;
for (Dependency de : dependencies) {
String managementKey = de.getManagementKey();
if (managementKey.equals("com.liferay.portal:com.liferay.util.bridges:jar")) {
hasDependency = true;
break;
}
}
assertTrue(hasDependency);
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));
model = maven.readModel(pomFile.getLocation().toFile());
dependencies = model.getDependencies();
hasDependency = false;
for (Dependency de : dependencies) {
String managementKey = de.getManagementKey();
if (managementKey.equals("javax.ws.rs:javax.ws.rs-api:jar")) {
hasDependency = true;
break;
}
}
assertTrue(hasDependency);
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));
model = maven.readModel(pomFile.getLocation().toFile());
dependencies = model.getDependencies();
hasDependency = false;
for (Dependency de : dependencies) {
String managementKey = de.getManagementKey();
if (managementKey.equals("org.apache.shiro:shiro-core:jar")) {
hasDependency = true;
break;
}
}
assertTrue(hasDependency);
}
use of com.liferay.ide.project.core.modules.NewLiferayModuleProjectOp in project liferay-ide by liferay.
the class MavenModuleProjectTests method testNewLiferayModuleProjectDefaultLocation.
@Test
public void testNewLiferayModuleProjectDefaultLocation() throws Exception {
final URL wsZipUrl = Platform.getBundle("com.liferay.ide.maven.core.tests").getEntry("projects/gradle-liferay-workspace.zip");
final File wsZipFile = new File(FileLocator.toFileURL(wsZipUrl).getFile());
File eclipseWorkspaceLocation = CoreUtil.getWorkspaceRoot().getLocation().toFile();
ZipUtil.unzip(wsZipFile, eclipseWorkspaceLocation);
File wsFolder = new File(eclipseWorkspaceLocation, "gradle-liferay-workspace");
importExistingProject(wsFolder, new NullProgressMonitor());
NewLiferayModuleProjectOp op = NewLiferayModuleProjectOp.TYPE.instantiate();
op.setProjectName("my-test-project");
op.setProjectTemplateName("mvc-portlet");
op.setProjectProvider("maven-module");
// don't put maven type project inside liferay-workspace
assertTrue(op.getLocation().content().toFile().equals(eclipseWorkspaceLocation));
op.setProjectProvider("gradle-module");
op.setProjectTemplateName("theme");
// put gradle type theme project inside liferay-workspace/wars
assertTrue(op.getLocation().content().toPortableString().contains("gradle-liferay-workspace/wars"));
op.setProjectTemplateName("mvc-portlet");
// put gradle type project inside liferay-workspace/modules
assertTrue(op.getLocation().content().toPortableString().contains("gradle-liferay-workspace/modules"));
IProject project = CoreUtil.getProject("gradle-liferay-workspace");
if (project != null && project.isAccessible() && project.exists()) {
project.delete(true, true, new NullProgressMonitor());
}
op.setProjectTemplateName("service-builder");
// no liferay-workspace
assertTrue(op.getLocation().content().toFile().equals(eclipseWorkspaceLocation));
}
use of com.liferay.ide.project.core.modules.NewLiferayModuleProjectOp in project liferay-ide by liferay.
the class MavenModuleProjectTests method testProjectTemplateSimulationPanelEntry.
@Test
public void testProjectTemplateSimulationPanelEntry() throws Exception {
NewLiferayModuleProjectOp op = NewLiferayModuleProjectOp.TYPE.instantiate();
op.setProjectName("simulation-panel-entry-test");
op.setProjectProvider("maven-module");
op.setProjectTemplateName("simulation-panel-entry");
createAndBuild(op);
}
use of com.liferay.ide.project.core.modules.NewLiferayModuleProjectOp in project liferay-ide by liferay.
the class MavenModuleProjectTests method testProjectTemplateContentTargetingRule.
@Test
public void testProjectTemplateContentTargetingRule() throws Exception {
NewLiferayModuleProjectOp op = NewLiferayModuleProjectOp.TYPE.instantiate();
op.setProjectName("content-targeting-rule-test");
op.setProjectProvider("maven-module");
op.setProjectTemplateName("content-targeting-rule");
createAndBuild(op);
}
use of com.liferay.ide.project.core.modules.NewLiferayModuleProjectOp in project liferay-ide by liferay.
the class MavenModuleProjectTests method testProjectTemplateControlMenuEntry.
@Test
public void testProjectTemplateControlMenuEntry() throws Exception {
NewLiferayModuleProjectOp op = NewLiferayModuleProjectOp.TYPE.instantiate();
op.setProjectName("control-menu-entry-test");
op.setProjectProvider("maven-module");
op.setProjectTemplateName("control-menu-entry");
createAndBuild(op);
}
Aggregations