Search in sources :

Example 41 with IRuntimeWorkingCopy

use of org.eclipse.wst.server.core.IRuntimeWorkingCopy in project liferay-ide by liferay.

the class MavenModuleFragmentProjectTests method testNewModuleFragmentProjectOpProject.

@Test
public void testNewModuleFragmentProjectOpProject() throws Exception {
    NewModuleFragmentOp op = NewModuleFragmentOp.TYPE.instantiate();
    final String runtimeName = "liferay-portal-7.0";
    final NullProgressMonitor npm = new NullProgressMonitor();
    IRuntime runtime = ServerCore.findRuntime(runtimeName);
    if (runtime == null) {
        final IRuntimeWorkingCopy runtimeWC = ServerCore.findRuntimeType(getRuntimeId()).createRuntime(runtimeName, npm);
        runtimeWC.setName(runtimeName);
        runtimeWC.setLocation(getLiferayRuntimeDir());
        runtime = runtimeWC.save(true, npm);
    }
    assertNotNull(runtime);
    List<String> bundles = ServerUtil.getModuleFileListFrom70Server(runtime);
    assertNotNull(bundles);
    for (String hostOsgiBundle : bundles) {
        if (hostOsgiBundle.contains("com.liferay.asset.display.web")) {
            op.setProjectName("test-gradle-module-fragment");
            op.setProjectProvider("gradle-module-fragment");
            op.setLiferayRuntimeName(runtimeName);
            op.setHostOsgiBundle(hostOsgiBundle);
            OverrideFilePath overrideFilePath = op.getOverrideFiles().insert();
            overrideFilePath.setValue("META-INF/resources/view.jsp");
            Status gradleExeStatus = NewModuleFragmentOpMethods.execute(op, ProgressMonitorBridge.create(new NullProgressMonitor()));
            assertTrue(gradleExeStatus.ok());
            IProject existedGradleProject = CoreUtil.getProject(op.getProjectName().content());
            assertNotNull(existedGradleProject);
            IFile gradleFile = existedGradleProject.getFile("build.gradle");
            assertTrue(gradleFile.exists());
            IFile overrideFile = existedGradleProject.getFile("src/main/resources/META-INF/resources/view.jsp");
            assertTrue(overrideFile.exists());
        }
        if (hostOsgiBundle.contains("com.liferay.login.web")) {
            op.setProjectName("test-maven-module-fragment");
            op.setProjectProvider("maven-module-fragment");
            op.setLiferayRuntimeName(runtimeName);
            op.setHostOsgiBundle(hostOsgiBundle);
            OverrideFilePath file = op.getOverrideFiles().insert();
            file.setValue("META-INF/resources/login.jsp");
            Status mavenExeStatus = NewModuleFragmentOpMethods.execute(op, ProgressMonitorBridge.create(new NullProgressMonitor()));
            assertTrue(mavenExeStatus.ok());
            IProject existedMavenProject = CoreUtil.getProject(op.getProjectName().content());
            assertNotNull(existedMavenProject);
            IFile pomFile = existedMavenProject.getFile("pom.xml");
            assertTrue(pomFile.exists());
            IFile overrideFile1 = existedMavenProject.getFile("src/main/resources/META-INF/resources/login.jsp");
            assertTrue(overrideFile1.exists());
        }
    }
}
Also used : Status(org.eclipse.sapphire.modeling.Status) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFile(org.eclipse.core.resources.IFile) OverrideFilePath(com.liferay.ide.project.core.modules.fragment.OverrideFilePath) NewModuleFragmentOp(com.liferay.ide.project.core.modules.fragment.NewModuleFragmentOp) IRuntimeWorkingCopy(org.eclipse.wst.server.core.IRuntimeWorkingCopy) IProject(org.eclipse.core.resources.IProject) IRuntime(org.eclipse.wst.server.core.IRuntime) Test(org.junit.Test)

Aggregations

IRuntimeWorkingCopy (org.eclipse.wst.server.core.IRuntimeWorkingCopy)41 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)16 IRuntime (org.eclipse.wst.server.core.IRuntime)13 IRuntimeType (org.eclipse.wst.server.core.IRuntimeType)12 CoreException (org.eclipse.core.runtime.CoreException)9 IServerWorkingCopy (org.eclipse.wst.server.core.IServerWorkingCopy)9 IServerType (org.eclipse.wst.server.core.IServerType)8 IPath (org.eclipse.core.runtime.IPath)6 IStatus (org.eclipse.core.runtime.IStatus)6 Path (org.eclipse.core.runtime.Path)6 Test (org.junit.Test)6 PortalRuntime (com.liferay.ide.server.core.portal.PortalRuntime)5 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)4 NewModuleFragmentOp (com.liferay.ide.project.core.modules.fragment.NewModuleFragmentOp)2 OverrideFilePath (com.liferay.ide.project.core.modules.fragment.OverrideFilePath)2 HashMap (java.util.HashMap)2 IFile (org.eclipse.core.resources.IFile)2 IProject (org.eclipse.core.resources.IProject)2 GenericServerRuntime (org.eclipse.jst.server.generic.core.internal.GenericServerRuntime)2 ITomcatRuntimeWorkingCopy (org.eclipse.jst.server.tomcat.core.internal.ITomcatRuntimeWorkingCopy)2