Search in sources :

Example 1 with ImportLiferayWorkspaceOp

use of com.liferay.ide.project.core.workspace.ImportLiferayWorkspaceOp in project liferay-ide by liferay.

the class ImportWorkspaceProjectTests method testImportLiferayWorkspaceInitBundle.

@Test
public void testImportLiferayWorkspaceInitBundle() throws Exception {
    IWorkspace ws = ResourcesPlugin.getWorkspace();
    IWorkspaceRoot root = ws.getRoot();
    File src = new File("projects/testWorkspace");
    File dst = new File(root.getLocation().toFile(), src.getName());
    TestUtil.copyDir(src, dst);
    ImportLiferayWorkspaceOp op = ImportLiferayWorkspaceOp.TYPE.instantiate();
    op.setWorkspaceLocation(dst.getAbsolutePath());
    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);
    final NullProgressMonitor monitor = new NullProgressMonitor();
    op.execute(ProgressMonitorBridge.create(monitor));
    IProject eeProject = CoreUtil.getProject("testWorkspace");
    assertNotNull(eeProject);
    Util.waitForBuildAndValidation();
    eeProject.refreshLocal(IResource.DEPTH_INFINITE, monitor);
    final IFolder bundlesFolder = eeProject.getFolder("bundles");
    assertTrue(bundlesFolder.exists());
}
Also used : ImportLiferayWorkspaceOp(com.liferay.ide.project.core.workspace.ImportLiferayWorkspaceOp) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) IWorkspace(org.eclipse.core.resources.IWorkspace) File(java.io.File) IProject(org.eclipse.core.resources.IProject) IFolder(org.eclipse.core.resources.IFolder) Test(org.junit.Test)

Example 2 with ImportLiferayWorkspaceOp

use of com.liferay.ide.project.core.workspace.ImportLiferayWorkspaceOp in project liferay-ide by liferay.

the class AllBladeSamplesPublishTest method importAllBladeSamples.

@BeforeClass
public static void importAllBladeSamples() throws Exception {
    Util.deleteAllWorkspaceProjects();
    ImportLiferayWorkspaceOp op = ImportLiferayWorkspaceOp.TYPE.instantiate();
    File projectDir = copyTestProjectToWorkspace("projects/all-blade-samples");
    op.setWorkspaceLocation(projectDir.getCanonicalPath());
    op.setProvisionLiferayBundle(true);
    op.setServerName(WORKSPACE_SERVER_NAME);
    final NullProgressMonitor monitor = new NullProgressMonitor();
    op.execute(ProgressMonitorBridge.create(monitor));
    Util.waitForBuildAndValidation();
    IProject rootProject = CoreUtil.getWorkspaceRoot().getProject("all-blade-samples");
    assertNotNull(rootProject);
    assertTrue(rootProject.exists());
    assertLiferayProject("blade.portlet.jsp");
    assertLiferayProject("blade.gogo");
    IServer wsServer = ServerUtil.getServer(WORKSPACE_SERVER_NAME);
    assertNotNull(wsServer);
    long timeoutExpiredMs = System.currentTimeMillis() + 300000;
    wsServer.start("run", monitor);
    while (true) {
        assertEquals(wsServer.getServerState(), IServer.STATE_STARTING, wsServer.getServerState());
        Thread.sleep(500);
        if (wsServer.getServerState() == IServer.STATE_STARTED || System.currentTimeMillis() >= timeoutExpiredMs) {
            break;
        }
    }
    assertEquals(wsServer.getServerState(), IServer.STATE_STARTED, wsServer.getServerState());
}
Also used : ImportLiferayWorkspaceOp(com.liferay.ide.project.core.workspace.ImportLiferayWorkspaceOp) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IServer(org.eclipse.wst.server.core.IServer) File(java.io.File) IProject(org.eclipse.core.resources.IProject) BeforeClass(org.junit.BeforeClass)

Example 3 with ImportLiferayWorkspaceOp

use of com.liferay.ide.project.core.workspace.ImportLiferayWorkspaceOp in project liferay-ide by liferay.

the class ImportMavenLiferayWorkspaceOpTests method testImportMavenLiferayWorkspaceInitBundleSetUrl.

@Test
public void testImportMavenLiferayWorkspaceInitBundleSetUrl() throws Exception {
    ImportLiferayWorkspaceOp op = ImportLiferayWorkspaceOp.TYPE.instantiate();
    URL wsZipUrl = Platform.getBundle("com.liferay.ide.maven.core.tests").getEntry("projects/maven-liferay-workspace-bundleUrl.zip");
    String bundleUrl = "https://cdn.lfrs.sl/releases.liferay.com/portal/7.0.4-ga5/liferay-ce-portal-tomcat-7.0-ga5-20171018150113838.zip";
    String existUrl = "http://www.example.com/";
    String emailConfig = "<emailAddress>example@liferay.com</emailAddress>";
    String projectName = "maven-liferay-workspace";
    File wsZipFile = new File(FileLocator.toFileURL(wsZipUrl).getFile());
    IPath workspaceLocation = CoreUtil.getWorkspaceRoot().getLocation();
    String projectLocation = workspaceLocation.append(projectName).toPortableString();
    ZipUtil.unzip(wsZipFile, workspaceLocation.toFile());
    File wsFolder = new File(workspaceLocation.toFile(), projectName);
    File pomFile = new File(projectLocation, "pom.xml");
    assertTrue(pomFile.exists());
    String content = FileUtil.readContents(pomFile);
    assertTrue(content.contains(existUrl));
    assertTrue(content.contains(emailConfig));
    op.setWorkspaceLocation(wsFolder.getAbsolutePath());
    op.setProvisionLiferayBundle(true);
    op.setBundleUrl(bundleUrl);
    op.execute(new ProgressMonitor());
    content = FileUtil.readContents(pomFile);
    File bundleDir = new File(projectLocation, "bundles");
    assertTrue(bundleDir.exists());
    assertFalse(content.contains(existUrl));
    assertTrue(content.contains(bundleUrl));
    assertTrue(content.contains(emailConfig));
    IProject project = CoreUtil.getProject("maven-liferay-workspace");
    project.delete(true, true, new NullProgressMonitor());
}
Also used : ImportLiferayWorkspaceOp(com.liferay.ide.project.core.workspace.ImportLiferayWorkspaceOp) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ProgressMonitor(org.eclipse.sapphire.modeling.ProgressMonitor) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IPath(org.eclipse.core.runtime.IPath) File(java.io.File) URL(java.net.URL) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test)

Example 4 with ImportLiferayWorkspaceOp

use of com.liferay.ide.project.core.workspace.ImportLiferayWorkspaceOp in project liferay-ide by liferay.

the class ImportLiferayWorkspaceWizard method performPostFinish.

@Override
protected void performPostFinish() {
    super.performPostFinish();
    final ImportLiferayWorkspaceOp op = element().nearest(ImportLiferayWorkspaceOp.class);
    Path projectPath = op.getWorkspaceLocation().content();
    final IProject newProject = CoreUtil.getProject(projectPath.lastSegment());
    try {
        addToWorkingSets(newProject);
    } catch (Exception ex) {
        ProjectUI.logError("Unable to add project to working set", ex);
    }
    openLiferayPerspective(newProject);
    ProjectExplorerLayoutUtil.setNested(true);
}
Also used : ImportLiferayWorkspaceOp(com.liferay.ide.project.core.workspace.ImportLiferayWorkspaceOp) Path(org.eclipse.sapphire.modeling.Path) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException)

Example 5 with ImportLiferayWorkspaceOp

use of com.liferay.ide.project.core.workspace.ImportLiferayWorkspaceOp in project liferay-ide by liferay.

the class ImportLiferayWorkspaceFromInstallerAction method run.

@Override
public void run(IIntroSite site, Properties params) {
    Location platformLocation = Platform.getInstallLocation();
    File location = new File(platformLocation.getURL().getFile());
    if (Platform.getOS().equals(Platform.OS_MACOSX)) {
        location = location.getParentFile().getParentFile();
    }
    IPath path = new Path(location.getAbsolutePath());
    File workspaceDir = path.append("../liferay-workspace").toFile();
    if (!workspaceDir.exists()) {
        MessageDialog.openInformation(site.getShell(), "Liferay", "Can't import liferay workspace.\nDirectory \"" + workspaceDir.getAbsolutePath() + "\" doesn't exist.");
        return;
    }
    Job job = new WorkspaceJob("Importing Liferay Workspace...") {

        @Override
        public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
            ImportLiferayWorkspaceWizard wizard = new ImportLiferayWorkspaceWizard();
            ImportLiferayWorkspaceOp op = wizard.element().nearest(ImportLiferayWorkspaceOp.class);
            op.setWorkspaceLocation(workspaceDir.getAbsolutePath());
            op.setProvisionLiferayBundle(true);
            if (op.validation().ok()) {
                op.execute(ProgressMonitorBridge.create(monitor));
                return Status.OK_STATUS;
            } else {
                return StatusBridge.create(op.validation());
            }
        }
    };
    job.schedule();
    _openLiferayPerspective();
    ProjectExplorerLayoutUtil.setNested(true);
    IntroPlugin.closeIntro();
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) ImportLiferayWorkspaceOp(com.liferay.ide.project.core.workspace.ImportLiferayWorkspaceOp) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IPath(org.eclipse.core.runtime.IPath) WorkspaceJob(org.eclipse.core.resources.WorkspaceJob) Job(org.eclipse.core.runtime.jobs.Job) WorkspaceJob(org.eclipse.core.resources.WorkspaceJob) File(java.io.File) ImportLiferayWorkspaceWizard(com.liferay.ide.project.ui.workspace.ImportLiferayWorkspaceWizard) Location(org.eclipse.osgi.service.datalocation.Location)

Aggregations

ImportLiferayWorkspaceOp (com.liferay.ide.project.core.workspace.ImportLiferayWorkspaceOp)9 File (java.io.File)8 IProject (org.eclipse.core.resources.IProject)7 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)6 Test (org.junit.Test)6 URL (java.net.URL)3 IWorkspace (org.eclipse.core.resources.IWorkspace)3 IWorkspaceRoot (org.eclipse.core.resources.IWorkspaceRoot)3 ProgressMonitor (org.eclipse.sapphire.modeling.ProgressMonitor)3 IPath (org.eclipse.core.runtime.IPath)2 Status (org.eclipse.sapphire.modeling.Status)2 IServer (org.eclipse.wst.server.core.IServer)2 ImportLiferayWorkspaceWizard (com.liferay.ide.project.ui.workspace.ImportLiferayWorkspaceWizard)1 IFolder (org.eclipse.core.resources.IFolder)1 WorkspaceJob (org.eclipse.core.resources.WorkspaceJob)1 CoreException (org.eclipse.core.runtime.CoreException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 Path (org.eclipse.core.runtime.Path)1 Job (org.eclipse.core.runtime.jobs.Job)1 Location (org.eclipse.osgi.service.datalocation.Location)1