Search in sources :

Example 6 with IRuntimeWorkingCopy

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

the class ServerCoreBase method setupRuntime.

@Before
public void setupRuntime() throws Exception {
    if (shouldSkipBundleTests())
        return;
    assertNotNull("Expected System.getProperty(\"liferay.bundles.dir\") to not be null", System.getProperty("liferay.bundles.dir"));
    assertNotNull("Expected liferayBundlesDir to not be null", liferayBundlesDir);
    assertEquals("Expected liferayBundlesPath to exist: " + getLiferayBundlesPath().toOSString(), true, getLiferayBundlesPath().toFile().exists());
    extractRuntime(getLiferayRuntimeZip(), getLiferayRuntimeDir());
    final NullProgressMonitor npm = new NullProgressMonitor();
    final String runtimeName = getRuntimeVersion();
    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);
    final ILiferayTomcatRuntime liferayRuntime = (ILiferayTomcatRuntime) ServerCore.findRuntime(runtimeName).loadAdapter(ILiferayTomcatRuntime.class, npm);
    assertNotNull(liferayRuntime);
    final IPath portalBundleFolder = runtime.getLocation().removeLastSegments(1);
    final IPath deployPath = portalBundleFolder.append("deploy");
    final File deployFolder = deployPath.toFile();
    if (!deployFolder.exists()) {
        deployFolder.mkdir();
    }
    assertEquals("Expected the deploy folder to exist:" + deployPath.toOSString(), true, deployFolder.exists());
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IPath(org.eclipse.core.runtime.IPath) ILiferayTomcatRuntime(com.liferay.ide.server.tomcat.core.ILiferayTomcatRuntime) IRuntimeWorkingCopy(org.eclipse.wst.server.core.IRuntimeWorkingCopy) File(java.io.File) Before(org.junit.Before)

Example 7 with IRuntimeWorkingCopy

use of org.eclipse.wst.server.core.IRuntimeWorkingCopy in project webtools.servertools by eclipse.

the class TomcatRuntimeWizardFragment method enter.

public void enter() {
    if (comp != null) {
        IRuntimeWorkingCopy runtime = (IRuntimeWorkingCopy) getTaskModel().getObject(TaskModel.TASK_RUNTIME);
        comp.setRuntime(runtime);
    }
}
Also used : IRuntimeWorkingCopy(org.eclipse.wst.server.core.IRuntimeWorkingCopy)

Example 8 with IRuntimeWorkingCopy

use of org.eclipse.wst.server.core.IRuntimeWorkingCopy in project webtools.servertools by eclipse.

the class TomcatRuntimeWizardFragment method isComplete.

public boolean isComplete() {
    IRuntimeWorkingCopy runtime = (IRuntimeWorkingCopy) getTaskModel().getObject(TaskModel.TASK_RUNTIME);
    if (runtime == null)
        return false;
    IStatus status = runtime.validate(null);
    return (status == null || status.getSeverity() != IStatus.ERROR);
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) IRuntimeWorkingCopy(org.eclipse.wst.server.core.IRuntimeWorkingCopy)

Example 9 with IRuntimeWorkingCopy

use of org.eclipse.wst.server.core.IRuntimeWorkingCopy in project webtools.servertools by eclipse.

the class TomcatRuntimeLocator method getRuntimeFromDir.

protected static IRuntimeWorkingCopy getRuntimeFromDir(File dir, IProgressMonitor monitor) {
    for (int i = 0; i < runtimeTypes.length; i++) {
        try {
            IRuntimeType runtimeType = ServerCore.findRuntimeType(runtimeTypes[i]);
            String absolutePath = dir.getAbsolutePath();
            String id = absolutePath.replace(File.separatorChar, '_').replace(':', '-');
            IRuntimeWorkingCopy runtime = runtimeType.createRuntime(id, monitor);
            runtime.setName(dir.getName());
            runtime.setLocation(new Path(absolutePath));
            ITomcatRuntimeWorkingCopy wc = (ITomcatRuntimeWorkingCopy) runtime.loadAdapter(ITomcatRuntimeWorkingCopy.class, null);
            wc.setVMInstall(JavaRuntime.getDefaultVMInstall());
            IStatus status = runtime.validate(monitor);
            if (status == null || status.getSeverity() != IStatus.ERROR)
                return runtime;
            Trace.trace(Trace.FINER, "False runtime found at " + dir.getAbsolutePath() + ": " + status.getMessage());
        } catch (Exception e) {
            Trace.trace(Trace.SEVERE, "Could not find runtime", e);
        }
    }
    return null;
}
Also used : IRuntimeType(org.eclipse.wst.server.core.IRuntimeType) IRuntimeWorkingCopy(org.eclipse.wst.server.core.IRuntimeWorkingCopy)

Example 10 with IRuntimeWorkingCopy

use of org.eclipse.wst.server.core.IRuntimeWorkingCopy in project webtools.servertools by eclipse.

the class GetDelegateTestCase method createRuntime.

protected IRuntimeWorkingCopy createRuntime(String runtimeTypeId, String runtimeTypeLocation) throws CoreException {
    if (runtimeTypeId == null)
        throw new IllegalArgumentException();
    IRuntimeWorkingCopy runtimeCopy = ServerCore.findRuntimeType(runtimeTypeId).createRuntime(runtimeTypeId, null);
    runtimeCopy.setLocation(new Path(runtimeTypeLocation));
    runtimeCopy.setReadOnly(false);
    IVMInstall vmInstall = JavaRuntime.getDefaultVMInstall();
    ITomcatRuntimeWorkingCopy rwc = (ITomcatRuntimeWorkingCopy) runtimeCopy.loadAdapter(ITomcatRuntimeWorkingCopy.class, new NullProgressMonitor());
    rwc.setVMInstall(vmInstall);
    runtimeCopy.save(false, null);
    return runtimeCopy;
}
Also used : Path(org.eclipse.core.runtime.Path) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IVMInstall(org.eclipse.jdt.launching.IVMInstall) ITomcatRuntimeWorkingCopy(org.eclipse.jst.server.tomcat.core.internal.ITomcatRuntimeWorkingCopy) IRuntimeWorkingCopy(org.eclipse.wst.server.core.IRuntimeWorkingCopy)

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