Search in sources :

Example 1 with ImportLiferayModuleProjectOp

use of com.liferay.ide.project.core.modules.ImportLiferayModuleProjectOp in project liferay-ide by liferay.

the class ImportLiferayModuleProjectOpTest method testImportGradleModuleProject.

@Test
public void testImportGradleModuleProject() throws Exception {
    String projectName = "testGradleProject";
    String projectLocation = unzipFile(projectName);
    ImportLiferayModuleProjectOp importOp = ImportLiferayModuleProjectOp.TYPE.instantiate();
    importOp.setLocation(projectLocation);
    assertEquals("gradle", importOp.getBuildType().text(false));
    assertTrue(importOp.validation().ok());
    assertTrue(importOp.execute(ProgressMonitorBridge.create(new NullProgressMonitor())).ok());
    IProject project = ProjectUtil.getProject(projectName);
    assertTrue(project.exists());
    importOp = ImportLiferayModuleProjectOp.TYPE.instantiate();
    importOp.setLocation(projectLocation);
    assertEquals("A project with that name already exists.", importOp.validation().message());
    projectLocation = unzipFile("gradle-liferay-workspace");
    importOp.setLocation(projectLocation);
    assertEquals("Can't import Liferay Workspace, please use Import Liferay Workspace Project wizard.", importOp.validation().message());
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ImportLiferayModuleProjectOp(com.liferay.ide.project.core.modules.ImportLiferayModuleProjectOp) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test)

Example 2 with ImportLiferayModuleProjectOp

use of com.liferay.ide.project.core.modules.ImportLiferayModuleProjectOp in project liferay-ide by liferay.

the class PortalSourceLookupTests method setUpTest.

@Before
public void setUpTest() throws Exception {
    Stream.of(CoreUtil.getAllProjects()).forEach(this::deleteProject);
    Assert.assertEquals(0, CoreUtil.getAllProjects().length);
    Stream.of(ServerCore.getServers()).forEach(this::deleteServer);
    Assert.assertEquals(0, ServerCore.getServers().length);
    Stream.of(getPortalServerLaunchConfigurations()).forEach(this::deleteLaunchConfig);
    Assert.assertEquals(0, getPortalServerLaunchConfigurations().length);
    File tempDir = tempFolder.getRoot();
    TestUtil.copyDir(new File("test-projects/debug-parent"), tempDir);
    ImportLiferayModuleProjectOp op = ImportLiferayModuleProjectOp.TYPE.instantiate();
    op.setLocation(tempDir.getAbsolutePath());
    op.execute(ProgressMonitorBridge.create(new NullProgressMonitor()));
    TestUtil.waitForBuildAndValidation();
    Assert.assertTrue(CoreUtil.getProject("debug-lib").exists());
    Assert.assertTrue(CoreUtil.getProject("debug-test").exists());
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ImportLiferayModuleProjectOp(com.liferay.ide.project.core.modules.ImportLiferayModuleProjectOp) File(java.io.File) Before(org.junit.Before)

Example 3 with ImportLiferayModuleProjectOp

use of com.liferay.ide.project.core.modules.ImportLiferayModuleProjectOp in project liferay-ide by liferay.

the class CustomJspConverter method doExecute.

public void doExecute(String[] projectPaths, String[] projectNames, String targetPath, boolean liferayWorkspace) {
    Job job = new WorkspaceJob("Converting Jsp hook to fragments...") {

        @Override
        public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
            IStatus retval = Status.OK_STATUS;
            try {
                convertJspHookProject(projectPaths, projectNames, targetPath, monitor, liferayWorkspace);
                String[] projectPaths = getConvertResult(resultPrefix);
                if (ListUtil.isNotEmpty(projectPaths)) {
                    for (String path : projectPaths) {
                        ImportLiferayModuleProjectOp importOp = ImportLiferayModuleProjectOp.TYPE.instantiate();
                        importOp.setLocation(path);
                        if (importOp.validation().severity() != org.eclipse.sapphire.modeling.Status.Severity.ERROR) {
                            ImportLiferayModuleProjectOpMethods.execute(importOp, ProgressMonitorBridge.create(monitor));
                        }
                    }
                    refreshUI();
                }
            } catch (Exception e) {
                retval = ProjectUI.createErrorStatus("Error in convert jsp", e);
            }
            return retval;
        }
    };
    try {
        IProgressService progressService = PlatformUI.getWorkbench().getProgressService();
        progressService.showInDialog(Display.getDefault().getActiveShell(), job);
        job.schedule();
    } catch (Exception e) {
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IStatus(org.eclipse.core.runtime.IStatus) ImportLiferayModuleProjectOp(com.liferay.ide.project.core.modules.ImportLiferayModuleProjectOp) IProgressService(org.eclipse.ui.progress.IProgressService) WorkspaceJob(org.eclipse.core.resources.WorkspaceJob) WorkspaceJob(org.eclipse.core.resources.WorkspaceJob) Job(org.eclipse.core.runtime.jobs.Job) CoreException(org.eclipse.core.runtime.CoreException) SAXException(org.xml.sax.SAXException) IOException(java.io.IOException)

Example 4 with ImportLiferayModuleProjectOp

use of com.liferay.ide.project.core.modules.ImportLiferayModuleProjectOp in project liferay-ide by liferay.

the class ImportLiferayModuleProjectOpTest method testImportMavenModuleProject.

@Test
public void testImportMavenModuleProject() throws Exception {
    String projectName = "testMavenProjects";
    String projectLocation = unzipFile(projectName);
    ImportLiferayModuleProjectOp importOp = ImportLiferayModuleProjectOp.TYPE.instantiate();
    importOp.setLocation(projectLocation);
    assertEquals("maven", importOp.getBuildType().text(false));
    assertTrue(importOp.validation().ok());
    assertTrue(importOp.execute(ProgressMonitorBridge.create(new NullProgressMonitor())).ok());
    IProject project = ProjectUtil.getProject(projectName);
    assertTrue(project.exists());
    importOp = ImportLiferayModuleProjectOp.TYPE.instantiate();
    importOp.setLocation(projectLocation);
    assertEquals("A project with that name already exists.", importOp.validation().message());
    projectLocation = unzipFile("maven-liferay-workspace");
    importOp.setLocation(projectLocation);
    assertEquals("Can't import Liferay Workspace, please use Import Liferay Workspace Project wizard.", importOp.validation().message());
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ImportLiferayModuleProjectOp(com.liferay.ide.project.core.modules.ImportLiferayModuleProjectOp) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test)

Aggregations

ImportLiferayModuleProjectOp (com.liferay.ide.project.core.modules.ImportLiferayModuleProjectOp)4 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)3 IProject (org.eclipse.core.resources.IProject)2 Test (org.junit.Test)2 File (java.io.File)1 IOException (java.io.IOException)1 WorkspaceJob (org.eclipse.core.resources.WorkspaceJob)1 CoreException (org.eclipse.core.runtime.CoreException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 IStatus (org.eclipse.core.runtime.IStatus)1 Job (org.eclipse.core.runtime.jobs.Job)1 IProgressService (org.eclipse.ui.progress.IProgressService)1 Before (org.junit.Before)1 SAXException (org.xml.sax.SAXException)1