Example usage for com.google.gwt.eclipse.core.compile GWTCompileRunner compileWithCancellationSupport

List of usage examples for com.google.gwt.eclipse.core.compile GWTCompileRunner compileWithCancellationSupport

Introduction

In this page you can find the example usage for com.google.gwt.eclipse.core.compile GWTCompileRunner compileWithCancellationSupport.

Prototype

public static void compileWithCancellationSupport(IJavaProject javaProject, IPath warLocation,
        GWTCompileSettings settings, OutputStream consoleOutputStream, IProcessReceiver processReceiver,
        IProgressMonitor monitor, ProgressMonitorCanceledWatcher.Listener cancellationListener)
        throws IOException, InterruptedException, CoreException, OperationCanceledException 

Source Link

Usage

From source file:com.google.gdt.eclipse.suite.launch.SpeedTracerLaunchDelegate.java

License:Open Source License

private void performGwtCompile(IProject project, File extraDir, List<String> modules, IPath warOutLocation,
        IProgressMonitor monitor) throws CoreException, IOException, InterruptedException {

    monitor.beginTask("Performing GWT compile...", 100);

    try {//from   w w  w. j a  v  a  2s .com
        GWTCompileSettings compileSettings = GWTProjectProperties.getGwtCompileSettings(project);
        compileSettings.setEntryPointModules(
                !modules.isEmpty() ? modules : GWTProjectProperties.getEntryPointModules(project));
        compileSettings.setExtraArgs("-extra " + StringUtilities.quote(extraDir.getAbsolutePath()) + " -gen "
                + StringUtilities.quote(
                        GWTPreferences.computeSpeedTracerGeneratedFolderPath(warOutLocation).toOSString()));

        // Get a message console for GWT compiler output
        CustomMessageConsole messageConsole = showGwtCompilationConsole(project);
        OutputStream consoleOutputStream = messageConsole.newMessageStream();

        TerminateProcessAction terminateAction = new TerminateProcessAction();
        messageConsole.setTerminateAction(terminateAction);

        try {
            GWTCompileRunner.compileWithCancellationSupport(JavaCore.create(project), warOutLocation,
                    compileSettings, consoleOutputStream, terminateAction, monitor, terminateAction);
        } finally {
            try {
                assert (consoleOutputStream != null);
                consoleOutputStream.close();
            } catch (IOException e) {
                // Ignore IOExceptions during stream close
            }
        }

        // refresh so that eclipse picks up on the gen files 
        project.refreshLocal(IResource.DEPTH_INFINITE, null);

    } finally {
        monitor.done();
    }
}

From source file:com.myeclipsedev.gdt.eclipse.ui.internal.wizard.ExportWarOp.java

License:Open Source License

@Override
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {

    try {//w  ww.j  a  v a2s  . c  o  m
        // Remember the compilation settings for next time
        GWTProjectProperties.setGwtCompileSettings(project, compileSettings);
    } catch (BackingStoreException e) {
        // Failed to save project properties
        ExportActivator.logError(e);
    }

    final String taskName = GWTCompileRunner.computeTaskName(project);

    // Get a message console for GWT compiler output

    CustomMessageConsole messageConsole = MessageConsoleUtilities.getMessageConsole(taskName, null);

    TerminateProcessAction terminateAction = new TerminateProcessAction();
    messageConsole.setTerminateAction(terminateAction);

    messageConsole.activate();
    OutputStream consoleOutputStream = messageConsole.newMessageStream();

    try {
        IPath warLocation = null;

        if (WebAppUtilities.isWebApp(project)) {
            /*
             * First, check the additional compiler arguments to see if the
             * user specified the -war option manually. If not, use the
             * project's managed WAR output directory (if set) or failing
             * that, prompt for a file-system path.
             */
            if (!compileSettings.getExtraArgs().contains("-war")) {
                warLocation = WebAppUtilities.getWarOutLocationOrPrompt(project);
                if (warLocation == null) {
                    // User canceled the dialog
                    return Status.OK_STATUS;
                }
            }
        }

        GWTCompileRunner.compileWithCancellationSupport(JavaCore.create(project), warLocation, compileSettings,
                consoleOutputStream, terminateAction, new SubProgressMonitor(monitor, 100), terminateAction);

        exportWar(monitor);

        return Status.OK_STATUS;

    } catch (IOException e) {
        ExportActivator.logError(e);
        throw new CoreException(
                new Status(IStatus.ERROR, ExportActivator.PLUGIN_ID, e.getLocalizedMessage(), e));
    } catch (InterruptedException e) {
        ExportActivator.logError(e);
        throw new CoreException(
                new Status(IStatus.ERROR, ExportActivator.PLUGIN_ID, e.getLocalizedMessage(), e));
    } catch (OperationCanceledException e) {
        // Ignore since the user canceled
        return Status.OK_STATUS;
    } catch (CoreException e) {
        ExportActivator.logError(e);
        return e.getStatus();
    } catch (ArchiveSaveFailureException e) {
        ExportActivator.logError(e);
        throw new CoreException(
                new Status(IStatus.ERROR, ExportActivator.PLUGIN_ID, e.getLocalizedMessage(), e));
    } finally {
        terminateAction.setEnabled(false);
        monitor.done();
        try {
            assert (consoleOutputStream != null);
            consoleOutputStream.close();
        } catch (IOException e) {
            // Ignore IOExceptions during stream close
        }
    }

}