Example usage for com.google.gwt.eclipse.core.launch GWTLaunchConfiguration getEntryPointModules

List of usage examples for com.google.gwt.eclipse.core.launch GWTLaunchConfiguration getEntryPointModules

Introduction

In this page you can find the example usage for com.google.gwt.eclipse.core.launch GWTLaunchConfiguration getEntryPointModules.

Prototype

public static List<String> getEntryPointModules(ILaunchConfiguration launchConfiguration) throws CoreException 

Source Link

Usage

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

License:Open Source License

@Override
public boolean buildForLaunch(ILaunchConfiguration config, String mode, IProgressMonitor originalMonitor)
        throws CoreException, OperationCanceledException {

    boolean performGwtCompile = LaunchConfigurationAttributeUtilities.getBoolean(config,
            SpeedTracerLaunchConfiguration.Attribute.PERFORM_GWT_COMPILE);
    if (!performGwtCompile) {
        return super.buildForLaunch(config, mode, originalMonitor);
    }//from   ww  w .  ja  v a 2s  . c  om

    SubMonitor subMonitor = SubMonitor.convert(originalMonitor);
    try {
        IJavaProject javaProject = getJavaProject(config);
        if (javaProject == null) {
            abortLaunch("The project is not a Java project.");
        }

        IProject project = javaProject.getProject();

        IPath warOutLocation = null;

        List<String> args = LaunchConfigurationProcessorUtilities.parseProgramArgs(config);
        WarParser parser = WarArgumentProcessor.WarParser.parse(args, javaProject);
        if (parser.isWarDirValid) {
            warOutLocation = new Path(parser.resolvedUnverifiedWarDir);
        }

        if (warOutLocation == null) {
            warOutLocation = WebAppUtilities.getWarOutLocationOrPrompt(project);

            if (warOutLocation == null) {
                throw new OperationCanceledException("Speed Tracer launch canceled by the user");
            }

            // TODO: Copied from WebAppLaunchDelegate. We need to unify these two.
            WarArgumentProcessor warArgProcessor = new WarArgumentProcessor();
            warArgProcessor.setWarDirFromLaunchConfigCreation(warOutLocation.toOSString());

            ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
            LaunchConfigurationProcessorUtilities.updateViaProcessor(warArgProcessor, wc);
            wc.doSave();
        }

        boolean needsGenFilesOrSymbolManifest = needsGenFiles(warOutLocation)
                || needsSymbolManifest(warOutLocation);
        long curStamp = ProjectChangeTimestampTracker.getProjectTimestamp(project);
        if (curStamp == ProjectChangeTimestampTracker.getTimestampFromKey(project,
                PREVIOUS_ST_BUILD_PROJECT_CHANGE_STAMP_KEY) && !needsGenFilesOrSymbolManifest) {
            // No source change, do not re-build
            printToCompilationConsole(project,
                    "Skipping GWT compilation since no relevant changes have occurred since the last Speed Tracer session.");
            return super.buildForLaunch(config, mode, originalMonitor);
        }

        if (needsGenFilesOrSymbolManifest) {
            printToCompilationConsole(project,
                    "Recompiling because generated files or symbol manifests for Speed Tracer are missing.");
        }

        File extraDir = createTempExtraDir();

        try {
            subMonitor.setTaskName("Performing GWT compile");
            List<String> modules = GWTLaunchConfiguration.getEntryPointModules(config);
            performGwtCompile(project, extraDir, modules, warOutLocation, subMonitor.newChild(70));
        } catch (OperationCanceledException e) {
            abortLaunchBecauseUserCancellation();
        } catch (Throwable e) {
            GdtPlugin.getLogger().logError(e, "Could not perform GWT compile");
            abortLaunch("Could not perform GWT compile, see logs for details.");
        }

        if (originalMonitor.isCanceled()) {
            abortLaunchBecauseUserCancellation();
        }

        try {
            // Generate the symbol manifest AFTER the compile, since the compile
            // wipes away ST artifacts
            subMonitor.setTaskName("Generating Speed Tracer symbol manifest");
            generateSymbolManifest(project, extraDir, warOutLocation);
        } catch (IOException e) {
            abortLaunch("Could not generate the symbol manifest file required by Speed Tracer.");
        }

        if (originalMonitor.isCanceled()) {
            abortLaunchBecauseUserCancellation();
        }

        extraDir.delete();

        /*
         * wtp publish
         */
        try {
            WebAppLaunchDelegate.maybePublishModulesToWarDirectory(config, subMonitor, javaProject, true);
        } catch (IOException e) {
            GdtPlugin.getLogger().logError(e, "Could not perform a WTP publish.");
        }

        // Build was successful, mark this last successful build
        project.setPersistentProperty(PREVIOUS_ST_BUILD_PROJECT_CHANGE_STAMP_KEY, String.valueOf(curStamp));

        final int amountOfWorkForSuperBuildForLaunch = 30;
        subMonitor.setWorkRemaining(amountOfWorkForSuperBuildForLaunch);
        return super.buildForLaunch(config, mode, subMonitor.newChild(amountOfWorkForSuperBuildForLaunch));

    } finally {
        if (originalMonitor != null) {
            originalMonitor.done();
        }
    }
}