Search in sources :

Example 51 with ILaunchConfiguration

use of org.eclipse.debug.core.ILaunchConfiguration in project liferay-ide by liferay.

the class SDKHelper method runTarget.

public void runTarget(IPath buildFile, String targets, Map<String, String> properties, boolean separateJRE, String workingDir) throws CoreException {
    if (isLaunchRunning()) {
        throw new IllegalStateException("Existing launch in progress");
    }
    currentBuildFile = buildFile;
    currentTargets = targets;
    ILaunchConfiguration launchConfig = createLaunchConfiguration(buildFile, targets, properties, separateJRE, workingDir);
    launch(launchConfig, ILaunchManager.RUN_MODE, _monitor);
    currentBuildFile = null;
    currentTargets = null;
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration)

Example 52 with ILaunchConfiguration

use of org.eclipse.debug.core.ILaunchConfiguration in project liferay-ide by liferay.

the class PortalSourcePathComputerDelegate method addSourceContainers.

private void addSourceContainers(ILaunchConfiguration configuration, IProgressMonitor monitor, final List<ISourceContainer> sourceContainers, IProject project) {
    String projectName = project.getName();
    try {
        ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
        ILaunchConfigurationType launchConfigurationType = manager.getLaunchConfigurationType("org.eclipse.jdt.launching.localJavaApplication");
        ILaunchConfigurationWorkingCopy sourceLookupConfig = launchConfigurationType.newInstance(null, configuration.getName());
        sourceLookupConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, projectName);
        ISourceContainer[] computedSourceContainers = super.computeSourceContainers(sourceLookupConfig, monitor);
        Stream.of(computedSourceContainers).filter(computedSourceContainer -> !sourceContainers.contains(computedSourceContainer)).forEach(sourceContainers::add);
    } catch (CoreException e) {
        LiferayServerCore.logError("Unable to add source container for project " + projectName, e);
    }
}
Also used : JavaSourcePathComputer(org.eclipse.jdt.launching.sourcelookup.containers.JavaSourcePathComputer) DebugPlugin(org.eclipse.debug.core.DebugPlugin) IServer(org.eclipse.wst.server.core.IServer) LiferayServerCore(com.liferay.ide.server.core.LiferayServerCore) CoreException(org.eclipse.core.runtime.CoreException) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType) ILaunchManager(org.eclipse.debug.core.ILaunchManager) ArrayList(java.util.ArrayList) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) LiferayCore(com.liferay.ide.core.LiferayCore) ServerUtil(org.eclipse.wst.server.core.ServerUtil) List(java.util.List) Stream(java.util.stream.Stream) IProject(org.eclipse.core.resources.IProject) ISourceContainer(org.eclipse.debug.core.sourcelookup.ISourceContainer) IWorkspaceProject(com.liferay.ide.core.IWorkspaceProject) IJavaLaunchConfigurationConstants(org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants) CoreException(org.eclipse.core.runtime.CoreException) ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType) ILaunchManager(org.eclipse.debug.core.ILaunchManager) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) ISourceContainer(org.eclipse.debug.core.sourcelookup.ISourceContainer)

Example 53 with ILaunchConfiguration

use of org.eclipse.debug.core.ILaunchConfiguration in project liferay-ide by liferay.

the class PortalSourcePathComputerDelegate method computeSourceContainers.

@Override
public ISourceContainer[] computeSourceContainers(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException {
    final List<ISourceContainer> sourceContainers = new ArrayList<ISourceContainer>();
    final IServer server = ServerUtil.getServer(configuration);
    IWorkspaceProject workspaceProject = LiferayCore.create(IWorkspaceProject.class, server);
    if (workspaceProject != null) {
        addSourceContainers(configuration, monitor, sourceContainers, workspaceProject.getProject());
    }
    Stream.of(server.getModules()).map(module -> LiferayCore.create(module.getProject())).filter(liferayProject -> liferayProject != null).forEach(liferayProject -> addSourceContainers(configuration, monitor, sourceContainers, liferayProject.getProject()));
    return sourceContainers.toArray(new ISourceContainer[0]);
}
Also used : JavaSourcePathComputer(org.eclipse.jdt.launching.sourcelookup.containers.JavaSourcePathComputer) DebugPlugin(org.eclipse.debug.core.DebugPlugin) IServer(org.eclipse.wst.server.core.IServer) LiferayServerCore(com.liferay.ide.server.core.LiferayServerCore) CoreException(org.eclipse.core.runtime.CoreException) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType) ILaunchManager(org.eclipse.debug.core.ILaunchManager) ArrayList(java.util.ArrayList) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) LiferayCore(com.liferay.ide.core.LiferayCore) ServerUtil(org.eclipse.wst.server.core.ServerUtil) List(java.util.List) Stream(java.util.stream.Stream) IProject(org.eclipse.core.resources.IProject) ISourceContainer(org.eclipse.debug.core.sourcelookup.ISourceContainer) IWorkspaceProject(com.liferay.ide.core.IWorkspaceProject) IJavaLaunchConfigurationConstants(org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants) IServer(org.eclipse.wst.server.core.IServer) ArrayList(java.util.ArrayList) ISourceContainer(org.eclipse.debug.core.sourcelookup.ISourceContainer) IWorkspaceProject(com.liferay.ide.core.IWorkspaceProject)

Example 54 with ILaunchConfiguration

use of org.eclipse.debug.core.ILaunchConfiguration in project liferay-ide by liferay.

the class PortalSourceLookupTests method testPortalSourcePathComputerDelegateDefaults.

@Test
public void testPortalSourcePathComputerDelegateDefaults() throws Exception {
    IServer portalServer = createPortalServer();
    addProjectToServer(CoreUtil.getLiferayProject("debug-lib"), portalServer);
    addProjectToServer(CoreUtil.getLiferayProject("debug-test"), portalServer);
    ILaunchConfiguration launchConfig = portalServer.getLaunchConfiguration(true, _NPM);
    ISourcePathComputer sourcePathComputer = getPortalSourcePathComputer(launchConfig);
    Assert.assertNotNull(sourcePathComputer);
    ISourceContainer[] sourceContainers = sourcePathComputer.computeSourceContainers(launchConfig, new NullProgressMonitor());
    Assert.assertNotNull(sourceContainers);
    Assert.assertEquals(2, Stream.of(sourceContainers).filter(sourceContainer -> sourceContainer instanceof JavaProjectSourceContainer).count());
    Assert.assertTrue(Stream.of(sourceContainers).filter(sourceContainer -> sourceContainer instanceof PackageFragmentRootSourceContainer).map(sourceContainer -> ((PackageFragmentRootSourceContainer) sourceContainer).getPath()).anyMatch(path -> path.lastSegment().endsWith("commons-io-2.5.jar")));
}
Also used : DebugPlugin(org.eclipse.debug.core.DebugPlugin) IServerType(org.eclipse.wst.server.core.IServerType) CoreUtil(com.liferay.ide.core.util.CoreUtil) CoreException(org.eclipse.core.runtime.CoreException) ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) TestUtil(com.liferay.ide.core.tests.TestUtil) JavaProjectSourceContainer(org.eclipse.jdt.launching.sourcelookup.containers.JavaProjectSourceContainer) PortalServer(com.liferay.ide.server.core.portal.PortalServer) IProject(org.eclipse.core.resources.IProject) IModule(org.eclipse.wst.server.core.IModule) Before(org.junit.Before) ProgressMonitorBridge(org.eclipse.sapphire.platform.ProgressMonitorBridge) IServer(org.eclipse.wst.server.core.IServer) BundleFactoryDelegate(com.liferay.ide.project.core.BundleFactoryDelegate) ImportLiferayModuleProjectOp(com.liferay.ide.project.core.modules.ImportLiferayModuleProjectOp) Test(org.junit.Test) File(java.io.File) ILaunchManager(org.eclipse.debug.core.ILaunchManager) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ISourcePathComputer(org.eclipse.debug.core.sourcelookup.ISourcePathComputer) Stream(java.util.stream.Stream) Rule(org.junit.Rule) ServerCore(org.eclipse.wst.server.core.ServerCore) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ISourceContainer(org.eclipse.debug.core.sourcelookup.ISourceContainer) Assert(org.junit.Assert) PackageFragmentRootSourceContainer(org.eclipse.jdt.launching.sourcelookup.containers.PackageFragmentRootSourceContainer) TemporaryFolder(org.junit.rules.TemporaryFolder) IServerWorkingCopy(org.eclipse.wst.server.core.IServerWorkingCopy) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IServer(org.eclipse.wst.server.core.IServer) ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) ISourcePathComputer(org.eclipse.debug.core.sourcelookup.ISourcePathComputer) PackageFragmentRootSourceContainer(org.eclipse.jdt.launching.sourcelookup.containers.PackageFragmentRootSourceContainer) ISourceContainer(org.eclipse.debug.core.sourcelookup.ISourceContainer) JavaProjectSourceContainer(org.eclipse.jdt.launching.sourcelookup.containers.JavaProjectSourceContainer) Test(org.junit.Test)

Example 55 with ILaunchConfiguration

use of org.eclipse.debug.core.ILaunchConfiguration in project liferay-ide by liferay.

the class CreateHelper method runTarget.

public void runTarget(IPath createFile, ArrayList<String> arguments, String workingDir) throws CoreException {
    if (isLaunchRunning()) {
        throw new IllegalStateException("Existing launch in progress");
    }
    currentCreateFile = createFile;
    currentCreateFile.toFile().setExecutable(true);
    ILaunchConfiguration launchConfig = createLaunchConfiguration(createFile, arguments, workingDir);
    int exitValue = launch(launchConfig, ILaunchManager.RUN_MODE, _monitor);
    if (exitValue > 0) {
        throw new CoreException(SDKCorePlugin.createErrorStatus("create script failed with error code " + exitValue));
    }
    currentCreateFile = null;
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) CoreException(org.eclipse.core.runtime.CoreException)

Aggregations

ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)275 CoreException (org.eclipse.core.runtime.CoreException)100 ILaunchConfigurationWorkingCopy (org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)79 Test (org.junit.Test)72 ILaunchConfigurationType (org.eclipse.debug.core.ILaunchConfigurationType)51 ILaunchManager (org.eclipse.debug.core.ILaunchManager)41 ArrayList (java.util.ArrayList)37 ILaunch (org.eclipse.debug.core.ILaunch)37 IPath (org.eclipse.core.runtime.IPath)20 IProject (org.eclipse.core.resources.IProject)19 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)17 IStatus (org.eclipse.core.runtime.IStatus)16 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)16 IEditorPart (org.eclipse.ui.IEditorPart)15 IProcess (org.eclipse.debug.core.model.IProcess)14 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)14 IFile (org.eclipse.core.resources.IFile)13 Status (org.eclipse.core.runtime.Status)13 CachegrindViewPart (org.eclipse.linuxtools.internal.valgrind.cachegrind.CachegrindViewPart)13 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)11