Java Code Examples for org.eclipse.wst.common.project.facet.core.ProjectFacetsManager#create()
The following examples show how to use
org.eclipse.wst.common.project.facet.core.ProjectFacetsManager#create() .
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: FacetFinder.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 6 votes |
/** * 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 2
Source File: ImportNativeAppEngineStandardProjectTest.java From google-cloud-eclipse with Apache License 2.0 | 6 votes |
@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 3
Source File: ImportNativeAppEngineStandardProjectTest.java From google-cloud-eclipse with Apache License 2.0 | 6 votes |
@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 4
Source File: XmlSourceValidator.java From google-cloud-eclipse with Apache License 2.0 | 6 votes |
/** * 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 5
Source File: GpeConvertCommandHandler.java From google-cloud-eclipse with Apache License 2.0 | 6 votes |
@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 6
Source File: FlexDeployCommandHandler.java From google-cloud-eclipse with Apache License 2.0 | 6 votes |
@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 7
Source File: AppEngineStandardProjectDetector.java From google-cloud-eclipse with Apache License 2.0 | 6 votes |
@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 8
Source File: DeployPropertyPage.java From google-cloud-eclipse with Apache License 2.0 | 6 votes |
@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 9
Source File: TestProjectCreator.java From google-cloud-eclipse with Apache License 2.0 | 6 votes |
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: FlexFacetInstallDelegateTest.java From google-cloud-eclipse with Apache License 2.0 | 5 votes |
@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 11
Source File: GpeFacetedMigratorTest.java From google-cloud-eclipse with Apache License 2.0 | 5 votes |
@Test public void testRemoveGpeRuntimeAndFacets_facetsRemoved() throws CoreException { IFacetedProject facetedProject = ProjectFacetsManager.create(gpeProject); assertTrue(containsFacet(facetedProject, "com.google.appengine.facet")); assertTrue(containsFacet(facetedProject, "com.google.appengine.facet.ear")); assertTrue(GpeMigrator.removeGpeRuntimeAndFacets(facetedProject)); assertFalse(containsFacet(facetedProject, "com.google.appengine.facet")); assertFalse(containsFacet(facetedProject, "com.google.appengine.facet.ear")); assertFalse(GpeMigrator.removeGpeRuntimeAndFacets(facetedProject)); }
Example 12
Source File: AppEngineWebBuilder.java From google-cloud-eclipse with Apache License 2.0 | 5 votes |
@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; }
Example 13
Source File: StandardFacetInstallDelegate.java From google-cloud-eclipse with Apache License 2.0 | 5 votes |
private void installAppEngineRuntimes(IProject project) throws CoreException { IFacetedProject facetedProject = ProjectFacetsManager.create(project); // Modifying targeted runtimes while installing/uninstalling facets is not allowed, // so schedule a job as a workaround. Job installJob = new AppEngineRuntimeInstallJob(facetedProject); // Schedule immediately so that it doesn't go into the SLEEPING state. Ensuring the job is // active is necessary for unit testing. installJob.schedule(); }
Example 14
Source File: ImportMavenAppEngineStandardProjectTest.java From google-cloud-eclipse with Apache License 2.0 | 5 votes |
@Test public void runImport() throws IOException, CoreException { assertFalse(projectExists("springboot-appengine-standard")); ZipUtil.extractZip(new URL( "platform:/plugin/com.google.cloud.tools.eclipse.integration.appengine/test-projects/springboot-appengine-standard.zip"), tempFolder.getRoot()); project = SwtBotAppEngineActions.importMavenProject(bot, "springboot-appengine-standard", tempFolder.getRoot()); assertTrue(project.exists()); ProjectUtils.failIfBuildErrors("Imported Maven project has errors", project); IFacetedProject facetedProject = ProjectFacetsManager.create(project); assertNotNull("m2e-wtp should create 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)); ArrayAssertions.assertIsEmpty("runtime classpath should be empty for Maven projects", NewMavenBasedAppEngineProjectWizardTest.getAppEngineServerRuntimeClasspathEntries(project)); }
Example 15
Source File: CreateAppEngineStandardWtpProjectTest.java From google-cloud-eclipse with Apache License 2.0 | 5 votes |
@Test public void testAppEngineRuntimeAdded() throws InvocationTargetException, CoreException { CreateAppEngineWtpProject creator = newCreateAppEngineWtpProject(); creator.execute(monitor); ProjectUtils.waitForProjects(project); // App Engine runtime is added via a Job, so wait. IFacetedProject facetedProject = ProjectFacetsManager.create(project); IRuntime primaryRuntime = facetedProject.getPrimaryRuntime(); assertTrue(AppEngineStandardFacet.isAppEngineStandardRuntime(primaryRuntime)); }
Example 16
Source File: StandardFacetUninstallDelegate.java From google-cloud-eclipse with Apache License 2.0 | 5 votes |
@Override public void execute(IProject project, IProjectFacetVersion version, Object config, IProgressMonitor monitor) throws CoreException { // Modifying targeted runtimes while installing/uninstalling facets is not allowed, // so schedule a job as a workaround. IFacetedProject facetedProject = ProjectFacetsManager.create(project); Job uninstallJob = new UninstallAppEngineRuntimesJob(facetedProject); uninstallJob.schedule(); }
Example 17
Source File: AppEngineContentProvider.java From google-cloud-eclipse with Apache License 2.0 | 5 votes |
/** Return {@code true} if the project is an App Engine project. */ static boolean isAppEngine(IProject project) { Preconditions.checkNotNull(project); try { IFacetedProject facetedProject = ProjectFacetsManager.create(project); return facetedProject != null && (AppEngineStandardFacet.hasFacet(facetedProject) || AppEngineFlexWarFacet.hasFacet(facetedProject) || AppEngineFlexJarFacet.hasFacet(facetedProject)); } catch (CoreException ex) { // Project is not faceted return false; } }
Example 18
Source File: AppEngineFlexWarFacetTest.java From google-cloud-eclipse with Apache License 2.0 | 5 votes |
@Test public void testInstallAppEngineFacet_onWtpProject() throws CoreException { IProject project = wtpProjectCreator.getProject(); IFacetedProject facetedProject = ProjectFacetsManager.create(project); AppEngineFlexWarFacet.installAppEngineFacet(facetedProject, false /* installDependentFacets */, new NullProgressMonitor()); Assert.assertTrue(AppEngineFlexWarFacet.hasFacet(facetedProject)); Assert.assertTrue(facetedProject.hasProjectFacet(JavaFacet.VERSION_1_7)); Assert.assertTrue(facetedProject.hasProjectFacet(WebFacetUtils.WEB_25)); Assert.assertTrue(project.getFile("src/main/appengine/app.yaml").exists()); }
Example 19
Source File: AppEngineStandardFacet.java From google-cloud-eclipse with Apache License 2.0 | 5 votes |
/** * 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 20
Source File: NewMavenBasedAppEngineProjectWizardTest.java From google-cloud-eclipse with Apache License 2.0 | 4 votes |
/** Create a project with the given parameters. */ private void createAndCheck(String artifactId, String location, String packageName, AppEngineRuntime runtime, String[] projectFiles) throws CoreException, IOException { assertFalse(projectExists(artifactId)); project = SwtBotAppEngineActions.createMavenWebAppProject(bot, artifactId, location, packageName, runtime, "com.google.groupId", artifactId); assertTrue(project.exists()); if (location != null) { assertEquals(new File(location).getCanonicalPath(), project.getLocation().toFile().getCanonicalPath()); } IFacetedProject facetedProject = ProjectFacetsManager.create(project); assertNotNull("m2e-wtp should create a faceted project", facetedProject); assertEquals("1.8", getPomProperty(project, "maven.compiler.source")); assertEquals("1.8", getPomProperty(project, "maven.compiler.target")); // we don't currently export a JRE8 facet version assertNotNull("Project does not have standard facet", facetedProject.getProjectFacetVersion(AppEngineStandardFacet.FACET)); assertEquals("Project does not have standard facet", "JRE8", facetedProject.getProjectFacetVersion(AppEngineStandardFacet.FACET).getVersionString()); assertEquals(JavaFacet.VERSION_1_8, facetedProject.getProjectFacetVersion(JavaFacet.FACET)); if (runtime == null || runtime == AppEngineRuntime.STANDARD_JAVA_8) { assertEquals(WebFacetUtils.WEB_31, facetedProject.getProjectFacetVersion(WebFacetUtils.WEB_FACET)); } else if (runtime == AppEngineRuntime.STANDARD_JAVA_8_SERVLET_25) { assertEquals(WebFacetUtils.WEB_25, facetedProject.getProjectFacetVersion(WebFacetUtils.WEB_FACET)); } else { fail("Runtime not handled: " + runtime); } for (String projectFile : projectFiles) { Path projectFilePath = new Path(projectFile); assertTrue(project.exists(projectFilePath)); } ProjectUtils.waitForProjects(project); // App Engine runtime is added via a Job, so wait. ProjectUtils.failIfBuildErrors("New Maven project has errors", project); ArrayAssertions.assertIsEmpty("runtime classpath should be empty for Maven projects", getAppEngineServerRuntimeClasspathEntries(project)); }