Example usage for com.google.gwt.eclipse.core.properties GWTProjectProperties setEntryPointModules

List of usage examples for com.google.gwt.eclipse.core.properties GWTProjectProperties setEntryPointModules

Introduction

In this page you can find the example usage for com.google.gwt.eclipse.core.properties GWTProjectProperties setEntryPointModules.

Prototype

public static void setEntryPointModules(IProject project, List<String> modules) throws BackingStoreException 

Source Link

Usage

From source file:org.jboss.tools.maven.gwt.GWTProjectConfigurator.java

License:Open Source License

private void configureInternal(IMavenProjectFacade facade, IProgressMonitor monitor) throws CoreException {

    IPreferenceStore store = Activator.getDefault().getPreferenceStore();
    boolean configureGWT = store.getBoolean(Activator.CONFIGURE_GWT);
    log.debug("GWT Entry Point Modules configuration is {}", configureGWT ? "enabled" : "disabled");
    if (configureGWT && facade.getMavenProject().getPlugin(GWT_WAR_MAVEN_PLUGIN_KEY) != null) {

        IProject project = facade.getProject();
        String projectName = project.getName();
        IJavaProject javaProject = JavaCore.create(project);
        if (javaProject != null && javaProject.exists()) {

            Plugin pluginConfig = facade.getMavenProject().getPlugin(GWT_WAR_MAVEN_PLUGIN_KEY);

            if (pluginConfig == null) {
                //nothing to do
                return;
            }/*from   w ww  .  java 2s .c o m*/
            log.debug("Configure Entry Point Modules for GWT Project {}", projectName);

            List<String> modNames = findModules(pluginConfig, javaProject);

            try {
                List<String> oldModNames = GWTProjectProperties.getEntryPointModules(project);
                if (oldModNames == null || !oldModNames.equals(modNames)) {
                    GWTProjectProperties.setEntryPointModules(project, modNames);
                }
            } catch (BackingStoreException e) {
                logError("Exception in Maven GWT Configurator, cannot set entry point modules", e);
            }

            log.debug("Configure Output location for GWT Project {}", projectName);
            IFolder m2ewtpFolder = project.getFolder("target/m2e-wtp/web-resources/");
            IPath fullpath = null;
            IFolder outputfolder = null;
            if (!runsInplace(pluginConfig) && m2ewtpFolder.exists()) {
                fullpath = m2ewtpFolder.getFullPath();
                outputfolder = m2ewtpFolder;
            } else {
                fullpath = ProjectHome.getFirstWebContentPath(project);
                if (fullpath != null) {
                    outputfolder = project.getWorkspace().getRoot().getFolder(fullpath);
                }
            }
            if (fullpath == null) {
                log.warn("Can't find output folder for project {}. GWT Configuration incomplete", projectName);
                return;
            }
            try {
                IPath lastUsedWarOutLocation = WebAppProjectProperties.getLastUsedWarOutLocation(project);
                if (!fullpath.equals(lastUsedWarOutLocation)) {
                    WebAppProjectProperties.setLastUsedWarOutLocation(project, fullpath);
                }
            } catch (BackingStoreException e) {
                logError("Exception in Maven GWT Configurator, cannot set war output location", e);
            }
            if (isErraiProject(facade)) {
                setErraiVmParams(project,
                        outputfolder.getFolder("WEB-INF/classes").getProjectRelativePath().toPortableString());
            }

        } else {
            log.debug("Skip configurator for non Java project {}", projectName);
        }
    }
}