org.eclipse.wst.common.project.facet.core.ProjectFacetsManager Java Examples

The following examples show how to use org.eclipse.wst.common.project.facet.core.ProjectFacetsManager. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AppEngineStandardProjectDetector.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
@Override
public void configure(ProjectConfigurationRequest request, IProgressMonitor monitor)
    throws CoreException {
  IProject project = request.getProject();
  IFacetedProject facetedProject = ProjectFacetsManager.create(project);
  if (facetedProject == null || facetedProject.hasProjectFacet(AppEngineStandardFacet.FACET)) {
    return;
  }
  IFile appEngineWebXml =
      AppEngineConfigurationUtil.findConfigurationFile(
          project, new Path("appengine-web.xml")); // $NON-NLS-1$
  if (appEngineWebXml == null || !appEngineWebXml.exists()) {
    return;
  }
  AppEngineStandardFacet.installAppEngineFacet(facetedProject, true, monitor);
}
 
Example #2
Source File: StandardFacetInstallationTest.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
@Test
public void testStandardFacetInstallation() throws IOException, CoreException {
  projects = ProjectUtils.importProjects(getClass(),
      "projects/test-dynamic-web-project.zip", true /* checkBuildErrors */, null);
  assertEquals(1, projects.size());
  IProject project = projects.values().iterator().next();
  IFacetedProject facetedProject = ProjectFacetsManager.create(project);
  // verify that the appengine-web.xml is installed in the dynamic web root folder
  AppEngineStandardFacet.installAppEngineFacet(facetedProject, true, null);
  IFile correctAppEngineWebXml = project.getFile("war/WEB-INF/appengine-web.xml");
  IFile wrongAppEngineWebXml = project.getFile("src/main/webapp/WEB-INF/appengine-web.xml");
  assertTrue(correctAppEngineWebXml.exists());
  assertFalse(wrongAppEngineWebXml.exists());

  ProjectUtils.waitForProjects(project); // App Engine runtime is added via a Job, so wait.
  IRuntime primaryRuntime = facetedProject.getPrimaryRuntime();
  assertTrue(AppEngineStandardFacet.isAppEngineStandardRuntime(primaryRuntime));
}
 
Example #3
Source File: ImportNativeAppEngineStandardProjectTest.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
@Test
public void testImportAppEngineStandardJava8_from1_3_1() throws IOException, CoreException {
  assertFalse(projectExists("AESv8"));
  ZipUtil.extractZip(new URL(
      "platform:/plugin/com.google.cloud.tools.eclipse.integration.appengine/test-projects/cte-1_3_1-appengine-standard-java8.zip"),
      tempFolder.getRoot());
  project = SwtBotAppEngineActions.importNativeProject(bot, "AESv8", tempFolder.getRoot());
  assertTrue(project.exists());

  IStatus updateStatus = updateContainers(project);
  ProjectUtils.waitUntilNoBuildErrors(project);
  verifyImportedProject(project, updateStatus);
  
  IFacetedProject facetedProject = ProjectFacetsManager.create(project);
  assertNotNull("should be a faceted project", facetedProject);

  IProjectFacetVersion appEngineFacetVersion =
      facetedProject.getProjectFacetVersion(AppEngineStandardFacet.FACET);
  assertNotNull("Project does not have AES facet", appEngineFacetVersion);
  assertEquals("Project should have AES Java 8", "JRE8",
      appEngineFacetVersion.getVersionString());
  assertEquals(JavaFacet.VERSION_1_8, facetedProject.getProjectFacetVersion(JavaFacet.FACET));
  assertEquals(WebFacetUtils.WEB_31,
      facetedProject.getProjectFacetVersion(WebFacetUtils.WEB_FACET));
}
 
Example #4
Source File: ImportNativeAppEngineStandardProjectTest.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
@Test
public void testImportAppEngineStandardJava7_from1_3_1() throws IOException, CoreException {
  assertFalse(projectExists("AESv7"));
  ZipUtil.extractZip(new URL(
      "platform:/plugin/com.google.cloud.tools.eclipse.integration.appengine/test-projects/cte-1_3_1-appengine-standard-java7.zip"),
      tempFolder.getRoot());
  project = SwtBotAppEngineActions.importNativeProject(bot, "AESv7", tempFolder.getRoot());
  assertTrue(project.exists());

  IStatus updateStatus = updateContainers(project);
  verifyImportedProject(project, updateStatus);
  
  IFacetedProject facetedProject = ProjectFacetsManager.create(project);
  assertNotNull("should be a faceted project", facetedProject);

  IProjectFacetVersion appEngineFacetVersion =
      facetedProject.getProjectFacetVersion(AppEngineStandardFacet.FACET);
  assertNotNull("Project does not have AES facet", appEngineFacetVersion);
  assertEquals("Project should have AES Java 7", "JRE7",
      appEngineFacetVersion.getVersionString());
  assertEquals(JavaFacet.VERSION_1_7, facetedProject.getProjectFacetVersion(JavaFacet.FACET));
  assertEquals(WebFacetUtils.WEB_25,
      facetedProject.getProjectFacetVersion(WebFacetUtils.WEB_FACET));
}
 
Example #5
Source File: XmlSourceValidator.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
/**
 * Validates a given {@link IDocument} if the project has the App Engine Standard facet.
 */
@Override
public void validate(IValidationContext helper, IReporter reporter) throws ValidationException {
  IProject project = getProject(helper);
  try {
    IFacetedProject facetedProject = ProjectFacetsManager.create(project);
    if (facetedProject != null && AppEngineStandardFacet.hasFacet(facetedProject)) {
      String encoding = getDocumentEncoding(document);
      byte[] bytes = document.get().getBytes(encoding);
      IFile source = getFile(helper);
      validate(reporter, source, bytes);
    }
  } catch (IOException | CoreException ex) {
    logger.log(Level.SEVERE, ex.getMessage());
  }
}
 
Example #6
Source File: GpeConvertCommandHandler.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
  try {
    IProject project = ProjectFromSelectionHelper.getFirstProject(event);
    if (project == null) {
      throw new NullPointerException(
          "Convert menu should not be enabled for non-project resources");
    }

    IFacetedProject facetedProject = ProjectFacetsManager.create(project,
        true /* convert to faceted project if necessary */, null /* no monitor here */);
    if (AppEngineStandardFacet.hasFacet(facetedProject)) {
      throw new IllegalStateException(
          "Convert menu should not be enabled for App Engine standard projects");
    }

    GpeConvertJob job = new GpeConvertJob(facetedProject);
    job.setUser(true);
    job.schedule();
  } catch (CoreException ex) {
    StatusUtil.setErrorStatus(this, "Failed to convert to a faceted project", ex);
  }
  return null; // Must return null per method Javadoc.
}
 
Example #7
Source File: GpeConversionTest.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
private void convertGpeProject(URL zipFile)
    throws CoreException, IOException, InterruptedException {
  Map<String, IProject> projects =
      ProjectUtils.importProjects(zipFile, false /* checkBuildErrors */, null);
  assertEquals(1, projects.size());
  project = projects.values().iterator().next();
  IFacetedProject facetedProject = ProjectFacetsManager.create(project,
      true /* convert to faceted project if necessary */, null /* no monitor here */);

  Job conversionJob = new AppEngineStandardProjectConvertJob(facetedProject);
  conversionJob.schedule();
  conversionJob.join();
  assertTrue("conversion should not have failed", conversionJob.getResult().isOK());

  // ensure facet versions haven't been downgraded
  assertEquals(JavaFacet.VERSION_1_7, facetedProject.getProjectFacetVersion(JavaFacet.FACET));
  assertEquals(WebFacetUtils.WEB_25,
      facetedProject.getProjectFacetVersion(WebFacetUtils.WEB_FACET));
  assertEquals(AppEngineStandardFacet.JRE7,
      facetedProject.getProjectFacetVersion(AppEngineStandardFacet.FACET));
}
 
Example #8
Source File: XmlSourceValidatorTest.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
@Test
public void testNoErrorOnNonFacetedProject() throws CoreException, ValidationException {
  IProject project = nonFacetedProject.getProject();
  assertNull("project should have not been faceted", ProjectFacetsManager.create(project));

  project.getFolder("folder").create(true, true, null);
  project.getFile("folder/file.ext").create(new ByteArrayInputStream(new byte[0]), true, null);
  assertTrue(project.getFile("folder/file.ext").exists());

  IValidationContext validationContext = mock(IValidationContext.class);
  when(validationContext.getURIs()).thenReturn(
      new String[] {project.getName() + "/folder/file.ext"});

  new XmlSourceValidator().validate(validationContext, reporter);
  // Should not throw NPE and exit normally.
}
 
Example #9
Source File: TestProjectCreator.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
private void addFacets() throws CoreException {
  if (makeFaceted) {
    facetedProject = ProjectFacetsManager.create(project, true, null);
  }
  if (projectFacetVersions.isEmpty()) {
    return;
  }

  FacetUtil facetUtil = new FacetUtil(facetedProject);
  for (IProjectFacetVersion projectFacetVersion : projectFacetVersions) {
    facetUtil.addFacetToBatch(projectFacetVersion, null);
  }
  facetUtil.install(null);

  if (facetedProject.hasProjectFacet(AppEngineStandardFacet.FACET)) {
    // App Engine runtime is added via a Job, so wait.
    ProjectUtils.waitForProjects(project);
  }

  if (facetedProject.hasProjectFacet(JavaFacet.FACET)) {
    javaProject = JavaCore.create(project);
    assertTrue(javaProject.exists());
  }
}
 
Example #10
Source File: DeployPropertyPage.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
/**
 * Displays the appropriate deploy preferences panel based on the project's facet configuration.
 */
private void evaluateFacetConfiguration() {
  if (databindingSupport != null) {
    databindingSupport.dispose();
  }
  if (facetedProject != null && AppEngineStandardFacet.hasFacet(facetedProject)) {
    createStandardPanelIfNeeded();
    showPanel(standardPreferencesPanel);
  } else if (facetedProject != null
      && ProjectFacetsManager.isProjectFacetDefined(AppEngineFlexWarFacet.ID)
      && AppEngineFlexWarFacet.hasFacet(facetedProject)) {
    createFlexPanelIfNeeded();
    showPanel(flexPreferencesPanel);
  } else {
    createBlankPanelIfNeeded();
    showPanel(blankPreferencesPanel);
  }
}
 
Example #11
Source File: DeployPropertyPage.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
@Override
protected Control createContents(Composite parent) {
  container = new SharedScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL) {};
  container.setExpandHorizontal(true);
  container.setExpandVertical(true);
  container.setLayout(new GridLayout());

  IProject project = AdapterUtil.adapt(getElement(), IProject.class);

  try {
    facetedProject = ProjectFacetsManager.create(project);
  } catch (CoreException ex) {
    logger.log(Level.WARNING, ex.getMessage());
    return container;
  }

  GridDataFactory.fillDefaults().grab(true, true).applyTo(container);
  evaluateFacetConfiguration();
  return container;
}
 
Example #12
Source File: StandardDeployCommandHandler.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
private boolean checkAppEngineRuntimeCompatibility(Shell shell, IProject project) {
  try {
    IFacetedProject facetedProject = ProjectFacetsManager.create(project);
    if (facetedProject == null) {
      return false;
    }

    if (AppEngineStandardFacet.usesObsoleteRuntime(facetedProject)) {
      String message = Messages.getString("obsolete.runtime.message", project.getName());
      MessageDialog.openError(shell, Messages.getString("obsolete.runtime.title"), message);
      return false;
    }
  } catch(CoreException ex) {
    logger.log(Level.WARNING, "Unable to check project use of obsolete App Engine runtime", ex);
  }
  return true;
}
 
Example #13
Source File: FlexDeployCommandHandler.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
@Override
protected StagingDelegate getStagingDelegate(IProject project) throws CoreException {
  IFacetedProject facetedProject = ProjectFacetsManager.create(project);
  Preconditions.checkNotNull(facetedProject);

  String appYamlPath = new FlexDeployPreferences(project).getAppYamlPath();
  IPath appYaml = resolveFile(appYamlPath, project.getLocation());
  IPath appEngineDirectory = appYaml.removeLastSegments(1);

  if (AppEngineFlexWarFacet.hasFacet(facetedProject)) {
    return new FlexWarStagingDelegate(project, appEngineDirectory);
  } else if (AppEngineFlexJarFacet.hasFacet(facetedProject)) {
    if (MavenUtils.hasMavenNature(project)) {
      return new FlexMavenPackagedProjectStagingDelegate(project, appEngineDirectory);
    } else {
      throw new IllegalStateException("BUG: command enabled for non-Maven flex projects");
    }
  } else {
    throw new IllegalStateException("BUG: command enabled for non-flex projects");
  }
}
 
Example #14
Source File: FacetFinder.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Obtains a list of facet IDs for all non-Java facets enabled for a specified Eclipse project.
 * 
 * @param project the specified Eclipse project
 * @return the list of facet IDs
 */
public static List<String> getEnabledNonJavaFacetIds(IProject project) {
  IFacetedProject facetedProject;
  try {
    facetedProject = ProjectFacetsManager.create(project);
  } catch (CoreException e) {
    CorePluginLog.logError(e);
    return NO_STRINGS;
  }
  if (facetedProject == null) {
    return NO_STRINGS;
  }
  Collection<IProjectFacetVersion> projectFacetVersions = facetedProject.getProjectFacets();
  List<String> facetsEnabled = Lists.newArrayListWithCapacity(projectFacetVersions.size());
  for (IProjectFacetVersion facet : facetedProject.getProjectFacets()) {
    // Skip Java facet, since that is always on by default.
    String facetId = facet.getProjectFacet().getId();
    if (!facetId.equals(FACET_JST_JAVA) && !facetId.equals(FACET_JAVA)) {
      facetsEnabled.add(facetId);
    }
  }
  return facetsEnabled;
}
 
Example #15
Source File: WtpMavenProjectConfigurator.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void configure(ProjectConfigurationRequest request, IProgressMonitor monitor) throws CoreException {
  GwtWtpPlugin.logMessage("WtpMavenProjectConfigurator.doConfigure() invoked");

  // Given a pom.xml configuration
  Model pom = request.getMavenProject().getModel();

  // When the GWT plugin exists in POM
  if (isGwtProject(pom)) {
    IProject eclipseProject = request.getProject();
    IFacetedProject facetedProject = ProjectFacetsManager.create(eclipseProject);

    // Then add GWT facet
    new GwtMavenFacetManager().addGwtFacet(pom, facetedProject, monitor);
  }
}
 
Example #16
Source File: WebAppProjectCreator.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
private void jobSetupFacets(final IProject project) {
  // Facet setup is done in a workspace job since this can be long running,
  // hence shouldn't be from the UI thread.
  WorkspaceJob setupFacetsJob = new WorkspaceJob("Setting up facets") {
    @Override
    public IStatus runInWorkspace(IProgressMonitor monitor) {
      try {
        // Create faceted project
        IFacetedProject facetedProject = ProjectFacetsManager.create(project, true, monitor);
        // Add Java facet by default
        IProjectFacet javaFacet = ProjectFacetsManager.getProjectFacet(FACET_JST_JAVA);
        facetedProject.installProjectFacet(javaFacet.getDefaultVersion(), null, monitor);
        return Status.OK_STATUS;
      } catch (CoreException e) {
        // Log and continue
        GdtPlugin.getLogger().logError(e);
        return new Status(IStatus.ERROR, GdtPlugin.PLUGIN_ID, e.toString(), e);
      }
    }
  };
  setupFacetsJob.schedule();
}
 
Example #17
Source File: AppEngineStandardProjectConvertCommandHandler.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
  try {
    IProject project = ProjectFromSelectionHelper.getFirstProject(event);
    if (project == null) {
      throw new NullPointerException(
          "Convert menu should not be enabled for non-project resources");
    }

    IFacetedProject facetedProject = ProjectFacetsManager.create(project,
        true /* convert to faceted project if necessary */, null /* no monitor here */);
    if (AppEngineStandardFacet.hasFacet(facetedProject)) {
      throw new IllegalStateException(
          "Convert menu should not be enabled for App Engine standard projects");
    }

    AppEngineStandardProjectConvertJob job =
        new AppEngineStandardProjectConvertJob(facetedProject);
    job.setUser(true);
    job.schedule();
  } catch (CoreException ex) {
    StatusUtil.setErrorStatus(this, "Failed to convert to a faceted project", ex);
  }
  return null; // Must return null per method Javadoc.
}
 
Example #18
Source File: AppEngineFlexJarFacetTest.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
@Test
public void testFlexFacetExists() {
  Assert.assertEquals("com.google.cloud.tools.eclipse.appengine.facets.flex.jar",
      AppEngineFlexJarFacet.ID);
  Assert.assertEquals("1", AppEngineFlexJarFacet.VERSION);
  Assert.assertTrue(ProjectFacetsManager.isProjectFacetDefined(AppEngineFlexJarFacet.ID));
  Assert.assertEquals(AppEngineFlexJarFacet.ID, AppEngineFlexJarFacet.FACET.getId());
  Assert.assertEquals(AppEngineFlexJarFacet.VERSION,
      AppEngineFlexJarFacet.FACET_VERSION.getVersionString());
}
 
Example #19
Source File: AppEngineStandardProjectConvertJobTest.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
@Test
public void testAppEngineFacetAdded() throws CoreException, InterruptedException {
  IProject project = projectCreator.getProject();
  IFacetedProject facetedProject = ProjectFacetsManager.create(project);
  Job convertJob = new AppEngineStandardProjectConvertJob(facetedProject);
  convertJob.schedule();
  convertJob.join();
  assertTrue(AppEngineStandardFacet.hasFacet(facetedProject));

  // verify App Engine standard files are present
  IFile webXml = WebProjectUtil.findInWebInf(project, new Path("web.xml"));
  assertTrue(webXml.exists());
  IFile appEngineWebXml =
      AppEngineConfigurationUtil.findConfigurationFile(project, new Path("appengine-web.xml"));
  assertTrue(appEngineWebXml.exists());

  // verify no overlap in WEB-INF and source paths
  // Java 1.7 facet sets the source path to src/ which will overlap with the
  // default src/main/webapp used in the AppEngineStandardFacet installer
  IFolder webInfFolder = (IFolder) webXml.getParent();
  assertEquals("WEB-INF", webInfFolder.getName());
  IPath webInfPath = webInfFolder.getProjectRelativePath();
  List<IPath> sourcePaths = WebProjectUtil.getJavaSourcePaths(project);
  for (IPath sourcePath : sourcePaths) {
    assertFalse(sourcePath.isPrefixOf(webInfPath));
  }
}
 
Example #20
Source File: AppEngineFlexJarFacetTest.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
@Test
public void testHasAppEngineFacet_withoutFacet() {
  IProjectFacet projectFacet = ProjectFacetsManager.getProjectFacet(AppEngineFlexJarFacet.ID);
  when(mockFacetedProject.hasProjectFacet(projectFacet)).thenReturn(false);

  Assert.assertFalse(AppEngineFlexJarFacet.hasFacet(mockFacetedProject));
}
 
Example #21
Source File: PluginXmlTest.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
private static void checkFacetDefined(Document doc, String elementName) {
  NodeList elements = doc.getElementsByTagName(elementName);
  for (int i = 0; i < elements.getLength(); i++) {
    Element element = (Element) elements.item(i);
    String facet = element.getAttribute("facet");
    Assert.assertTrue(facet.isEmpty() || ProjectFacetsManager.isProjectFacetDefined(facet));
    String group = element.getAttribute("group");
    Assert.assertTrue(group.isEmpty() || ProjectFacetsManager.isGroupDefined(group));
  }
}
 
Example #22
Source File: AppEngineFlexJarFacetTest.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
@Test
public void testHasAppEngineFacet_withFacet() {
  IProjectFacet projectFacet = ProjectFacetsManager.getProjectFacet(AppEngineFlexJarFacet.ID);
  when(mockFacetedProject.hasProjectFacet(projectFacet)).thenReturn(true);

  Assert.assertTrue(AppEngineFlexJarFacet.hasFacet(mockFacetedProject));
}
 
Example #23
Source File: FlexFacetInstallDelegateTest.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
@Test
public void testWarFacetInstall() throws CoreException {
  IProject project = wtpProjectCreator.getProject();

  IFacetedProject facetedProject = ProjectFacetsManager.create(project);
  facetedProject.installProjectFacet(AppEngineFlexWarFacet.FACET_VERSION,
      null /* config */, new NullProgressMonitor());

  Assert.assertTrue(AppEngineFlexWarFacet.hasFacet(facetedProject));
  Assert.assertTrue(project.getFile("src/main/appengine/app.yaml").exists());
}
 
Example #24
Source File: AppEngineStandardFacet.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
/**
 * Return the App Engine standard facet for the given project, or {@code null} if none.
 */
public static IProjectFacetVersion getProjectFacetVersion(IProject project) {
  try {
    IFacetedProject facetedProject = ProjectFacetsManager.create(project);
    if (facetedProject == null) {
      return null;
    }
    return facetedProject.getProjectFacetVersion(FACET);
  } catch (CoreException ex) {
    return null;
  }
}
 
Example #25
Source File: FlexFacetInstallDelegateTest.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
@Test
public void testJarFacetInstall() throws CoreException {
  IProject project = javaProjectCreator.getProject();

  IFacetedProject facetedProject = ProjectFacetsManager.create(project);
  facetedProject.installProjectFacet(AppEngineFlexJarFacet.FACET_VERSION,
      null /* config */, new NullProgressMonitor());

  Assert.assertTrue(AppEngineFlexJarFacet.hasFacet(facetedProject));
  Assert.assertTrue(project.getFile("src/main/appengine/app.yaml").exists());
}
 
Example #26
Source File: AppEngineFacetPresetsTest.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
@Test
public void appEngineStandardJava7presetExists() {
  IPreset preset = ProjectFacetsManager
      .getPreset("com.google.cloud.tools.eclipse.appengine.standard.jre7.preset");
  assertNotNull(preset);
  assertEquals(
      "App Engine standard environment with Java 7, Servlet 2.5 (deprecated)", preset.getLabel());
  assertThat(preset.getProjectFacets(), hasItem(JavaFacet.VERSION_1_7));
  assertThat(preset.getProjectFacets(), hasItem(WebFacetUtils.WEB_25));
  assertThat(preset.getProjectFacets(), hasItem(AppEngineStandardFacet.JRE7));
}
 
Example #27
Source File: AppEngineFacetPresetsTest.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
@Test
public void appEngineFlexibleWarPresetExists() {
  IPreset preset = ProjectFacetsManager
      .getPreset("com.google.cloud.tools.eclipse.appengine.flexible.war.preset");
  assertNotNull(preset);
  assertEquals("App Engine flexible environment with Java 8, Servlet 3.1", preset.getLabel());
  assertThat(preset.getProjectFacets(), hasItem(JavaFacet.VERSION_1_8));
  assertThat(preset.getProjectFacets(), hasItem(WebFacetUtils.WEB_31));
  assertThat(preset.getProjectFacets(), hasItem(AppEngineFlexWarFacet.FACET_VERSION));
}
 
Example #28
Source File: AppEngineFacetPresetsTest.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
@Test
public void appEngineFlexibleJarPresetExists() {
  IPreset preset = ProjectFacetsManager
      .getPreset("com.google.cloud.tools.eclipse.appengine.flexible.jar.preset");
  assertNotNull(preset);
  assertEquals("App Engine flexible environment with Java 8, runnable JAR", preset.getLabel());
  assertThat(preset.getProjectFacets(), hasItem(JavaFacet.VERSION_1_8));
  assertThat(preset.getProjectFacets(), hasItem(AppEngineFlexJarFacet.FACET_VERSION));
}
 
Example #29
Source File: AppEngineStandardJava8PresetTest.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
@Test
public void presetExists() {
  IPreset preset = ProjectFacetsManager
      .getPreset("com.google.cloud.tools.eclipse.appengine.standard.jre8.preset");
  assertNotNull(preset);
  assertEquals("App Engine standard environment with Java 8, Servlet 3.1",
      preset.getLabel());
  assertThat(preset.getProjectFacets(), hasItem(JavaFacet.VERSION_1_8));
  assertThat(preset.getProjectFacets(), hasItem(WebFacetUtils.WEB_31));
  assertThat(preset.getProjectFacets(),
      hasItem(AppEngineStandardFacetChangeListener.APP_ENGINE_STANDARD_JRE8));
}
 
Example #30
Source File: AppEngineWebBuilder.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
@Override
protected IProject[] build(int kind, Map<String, String> args, IProgressMonitor monitor)
    throws CoreException {
  IFacetedProject project = ProjectFacetsManager.create(getProject());
  if (project == null || !AppEngineStandardFacet.hasFacet(project)) {
    logger.fine(getProject() + ": no build required: no App Engine Standard facet");
    return null;
  }
  IFile appEngineWebDescriptor =
      AppEngineConfigurationUtil.findConfigurationFile(
          project.getProject(), new Path("appengine-web.xml"));
  if (appEngineWebDescriptor == null || !appEngineWebDescriptor.exists()) {
    logger.warning(getProject() + ": no build required: missing appengine-web.xml");
    return null;
  }
  if (kind == FULL_BUILD) {
    checkRuntimeElement(project, appEngineWebDescriptor, monitor);
  } else {
    IResourceDelta delta = getDelta(getProject());
    if (delta == null
        || delta.findMember(appEngineWebDescriptor.getProjectRelativePath()) != null) {
      checkRuntimeElement(project, appEngineWebDescriptor, monitor);
    } else {
      logger.finer(getProject() + ": no build required: appengine-web.xml not changed");
    }
  }
  return null;
}