Java Code Examples for org.eclipse.core.resources.IProject#build()
The following examples show how to use
org.eclipse.core.resources.IProject#build() .
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: ASTReader.java From JDeodorant with MIT License | 6 votes |
private List<IMarker> buildProject(IJavaProject iJavaProject, IProgressMonitor pm) { ArrayList<IMarker> result = new ArrayList<IMarker>(); try { IProject project = iJavaProject.getProject(); project.refreshLocal(IResource.DEPTH_INFINITE, pm); project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, pm); IMarker[] markers = null; markers = project.findMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE); for (IMarker marker: markers) { Integer severityType = (Integer) marker.getAttribute(IMarker.SEVERITY); if (severityType.intValue() == IMarker.SEVERITY_ERROR) { result.add(marker); } } } catch (CoreException e) { e.printStackTrace(); } return result; }
Example 2
Source File: JCasGenM2ETest.java From uima-uimaj with Apache License 2.0 | 6 votes |
public void testEmptyOutputDirectory() throws Exception { ResolverConfiguration configuration = new ResolverConfiguration(); IProject project = importProject("target/projects/jcasgen/simple/pom.xml", configuration); waitForJobsToComplete(); assertNoErrors(project); project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor); waitForJobsToComplete(); assertNoErrors(project); // make sure the Java sources were generated assertTrue(project.getFolder("target/generated-sources/jcasgen").exists()); // remove the generated directory project.getFolder("target/generated-sources/jcasgen").delete(IProject.FORCE, monitor); assertFalse(project.getFolder("target/generated-sources/jcasgen").exists()); // re-build project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor); waitForJobsToComplete(); assertNoErrors(project); // make sure the Java sources were generated assertTrue(project.getFolder("target/generated-sources/jcasgen").exists()); }
Example 3
Source File: JavaUtils.java From developer-studio with Apache License 2.0 | 6 votes |
public static File buildProject(IProject project) throws CoreException{ project.build(IncrementalProjectBuilder.CLEAN_BUILD, new NullProgressMonitor()); project.build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor()); IMarker[] markers; markers = project.findMarkers(IMarker.PROBLEM, true,IResource.DEPTH_INFINITE); boolean errorsExists=false; StringBuffer sb=new StringBuffer(); for (IMarker marker : markers) { if(marker.getAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR) == IMarker.SEVERITY_ERROR) { sb.append(marker.getAttribute(IMarker.MESSAGE)).append("\n"); errorsExists=true; } } if (errorsExists){ throw new CoreException(new Status(IStatus.ERROR,Activator.PLUGIN_ID,"Compilation error exists in the project "+project.getName()+". Please resolve these error before continuing:\n"+sb.toString())); } return new File(project.getWorkspace().getRoot().getFolder(getJavaOutputDirectory(project)).getLocation().toOSString()); }
Example 4
Source File: JarFileExportOperation.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private void buildProjects(IProgressMonitor progressMonitor) { Set<IProject> builtProjects= new HashSet<IProject>(10); Object[] elements= fJarPackage.getElements(); for (int i= 0; i < elements.length; i++) { IProject project= null; Object element= elements[i]; if (element instanceof IResource) project= ((IResource)element).getProject(); else if (element instanceof IJavaElement) project= ((IJavaElement)element).getJavaProject().getProject(); if (project != null && !builtProjects.contains(project)) { try { project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, progressMonitor); } catch (CoreException ex) { String message= Messages.format(JarPackagerMessages.JarFileExportOperation_errorDuringProjectBuild, BasicElementLabels.getResourceName(project)); addError(message, ex); } finally { // don't try to build same project a second time even if it failed builtProjects.add(project); } } } }
Example 5
Source File: DependencyFileStore.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override protected void doDelete() { try { final IResource r = getResource(); if (r != null && r.exists()) { r.delete(true, Repository.NULL_PROGRESS_MONITOR); final Repository repository = getRepository(); final IProject project = repository.getProject(); project.refreshLocal(IResource.DEPTH_ONE, Repository.NULL_PROGRESS_MONITOR); if (repository.isBuildEnable()) { project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, Repository.NULL_PROGRESS_MONITOR); } } } catch (final CoreException e) { BonitaStudioLog.error(e); } }
Example 6
Source File: BuilderUtilities.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 6 votes |
/** * Schedules a full rebuild on a project. * * @param project the project to rebuild */ public static void scheduleRebuild(final IProject project) { WorkspaceJob buildJob = new WorkspaceJob("Building " + project.getName()) { @Override public boolean belongsTo(Object family) { return ResourcesPlugin.FAMILY_MANUAL_BUILD.equals(family); } @Override public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException { project.build(IncrementalProjectBuilder.FULL_BUILD, monitor); return Status.OK_STATUS; } }; buildJob.setRule(ResourcesPlugin.getWorkspace().getRuleFactory().buildRule()); buildJob.setUser(true); buildJob.schedule(); }
Example 7
Source File: BuilderUtilities.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
/** * Schedules a full rebuild on all projects in the workspace that have any of * the specified natures. */ public static void scheduleRebuildAll(final String... natureIds) { final IWorkspace workspace = ResourcesPlugin.getWorkspace(); WorkspaceJob buildJob = new WorkspaceJob("Building workspace projects") { @Override public boolean belongsTo(Object family) { return ResourcesPlugin.FAMILY_MANUAL_BUILD.equals(family); } @Override public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException { for (IProject project : workspace.getRoot().getProjects()) { for (String natureId : natureIds) { if (NatureUtils.hasNature(project, natureId)) { project.build(IncrementalProjectBuilder.FULL_BUILD, monitor); break; } } } return Status.OK_STATUS; } }; buildJob.setRule(workspace.getRuleFactory().buildRule()); buildJob.setUser(true); buildJob.schedule(); }
Example 8
Source File: ProjectArtifactHandler.java From developer-studio with Apache License 2.0 | 5 votes |
/** * * @param project * @return * @throws Exception */ protected IPath buildJavaProject(IProject project) throws Exception { project.build(IncrementalProjectBuilder.CLEAN_BUILD, getProgressMonitor()); project.build(IncrementalProjectBuilder.FULL_BUILD, getProgressMonitor()); IJavaProject javaProject = JavaCore.create(project); return getOutputPath(javaProject); }
Example 9
Source File: ProjectArtifactHandler.java From developer-studio with Apache License 2.0 | 5 votes |
protected void clearTarget(IProject project) { try { project.build(IncrementalProjectBuilder.CLEAN_BUILD, getProgressMonitor()); File target = project.getFolder("target").getLocation().toFile(); FileUtils.cleanDirectory(target); } catch (Exception e) { log.error("Error while cleaning the target directory", e); } }
Example 10
Source File: MavenBuildSupportTest.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
@Test public void testBuildHelperSupport() throws Exception { IProject project = importMavenProject("buildhelped"); project.build(IncrementalProjectBuilder.FULL_BUILD, monitor); assertIsJavaProject(project); assertNoErrors(project); }
Example 11
Source File: JavaCompilationParticipantTest.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
public void testClean() throws CoreException { IProject project = getTestProject().getProject(); IEclipsePreferences prefs = new InstanceScope().getNode("org.eclipse.core.resources"); // Disable auto-building so we don't race with the build process. prefs.putBoolean("description.autobuilding", false); // Verify that we have existing problem markers IMarker[] markers = project.findMarkers(GWTJavaProblem.MARKER_ID, true, IResource.DEPTH_INFINITE); assertTrue(markers.length > 0); // Verify that we have existing JavaRefIndex entries assertEquals(3, JavaRefIndex.getInstance().size()); // Clean the test project project.build(IncrementalProjectBuilder.CLEAN_BUILD, null); // Wait for the validation job to complete. JobsUtilities.waitForIdle(); // Verify that the problems went away markers = project.findMarkers(GWTJavaProblem.MARKER_ID, true, IResource.DEPTH_INFINITE); assertEquals(0, markers.length); // Verify that the JavaRefIndex entries went away assertEquals(0, JavaRefIndex.getInstance().size()); // Re-enable auto-building prefs.putBoolean("description.autobuilding", true); }
Example 12
Source File: AbstractJavaGeneratorTest.java From statecharts with Eclipse Public License 1.0 | 5 votes |
public IMarker[] generateAndCompile(Statechart statechart) throws Exception { GeneratorEntry entry = createGeneratorEntry(statechart.getName(), SRC_GEN); entry.setElementRef(statechart); IProject targetProject = getProject(entry); targetProject.delete(true, new NullProgressMonitor()); targetProject = getProject(entry); if (!targetProject.exists()) { targetProject.create(new NullProgressMonitor()); targetProject.open(new NullProgressMonitor()); } IGeneratorEntryExecutor executor = new EclipseContextGeneratorExecutorLookup() { protected Module getContextModule() { return Modules.override(super.getContextModule()).with(new Module() { @Override public void configure(Binder binder) { binder.bind(IConsoleLogger.class).to(TestLogger.class); } }); }; }.createExecutor(entry, "yakindu::java"); executor.execute(entry); targetProject.refreshLocal(IResource.DEPTH_INFINITE, null); targetProject.getWorkspace().build(IncrementalProjectBuilder.INCREMENTAL_BUILD, null); targetProject.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, new NullProgressMonitor()); IMarker[] markers = targetProject.findMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE); return markers; }
Example 13
Source File: PerformanceTest.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Test public void testCleanFullBuild() throws Exception { final IProject project = PerformanceTestProjectSetup.testProject.getProject(); project.build(IncrementalProjectBuilder.CLEAN_BUILD, null); project.build(IncrementalProjectBuilder.FULL_BUILD, null); project.build(IncrementalProjectBuilder.CLEAN_BUILD, null); project.build(IncrementalProjectBuilder.FULL_BUILD, null); Stopwatches.resetAll(); project.build(IncrementalProjectBuilder.CLEAN_BUILD, null); project.build(IncrementalProjectBuilder.FULL_BUILD, null); }
Example 14
Source File: PerformanceTest.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Test public void testCleanBuild() throws Exception { final IProject project = PerformanceTestProjectSetup.testProject.getProject(); project.build(IncrementalProjectBuilder.CLEAN_BUILD, null); project.build(IncrementalProjectBuilder.CLEAN_BUILD, null); Stopwatches.resetAll(); project.build(IncrementalProjectBuilder.CLEAN_BUILD, null); }
Example 15
Source File: JCasGenM2ETest.java From uima-uimaj with Apache License 2.0 | 5 votes |
public void testSimple() throws Exception { System.out.println("Using this repository: " + MavenPlugin.getMaven().getLocalRepository()); ResolverConfiguration configuration = new ResolverConfiguration(); IProject project = importProject("target/projects/jcasgen/simple/pom.xml", configuration); waitForJobsToComplete(); assertNoErrors(project); project.build(IncrementalProjectBuilder.FULL_BUILD, monitor); project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor); waitForJobsToComplete(); assertNoErrors(project); // make sure the Java sources were generated String prefix = "target/generated-sources/jcasgen/type/"; assertTrue(project.getFile(prefix + "span/Sentence.java").isAccessible()); assertTrue(project.getFile(prefix + "span/Sentence_Type.java").isAccessible()); assertTrue(project.getFile(prefix + "span/Token.java").isAccessible()); assertTrue(project.getFile(prefix + "span/Token_Type.java").isAccessible()); assertTrue(project.getFile(prefix + "relation/Dependency.java").isAccessible()); assertTrue(project.getFile(prefix + "relation/Dependency_Type.java").isAccessible()); // make sure the files are all synchronized in the workspace int zero = IResource.DEPTH_ZERO; assertTrue(project.getFile(prefix + "span/Sentence.java").isSynchronized(zero)); assertTrue(project.getFile(prefix + "span/Sentence_Type.java").isSynchronized(zero)); assertTrue(project.getFile(prefix + "span/Token.java").isSynchronized(zero)); assertTrue(project.getFile(prefix + "span/Token_Type.java").isSynchronized(zero)); assertTrue(project.getFile(prefix + "relation/Dependency.java").isSynchronized(zero)); assertTrue(project.getFile(prefix + "relation/Dependency_Type.java").isSynchronized(zero)); // make sure the generated sources are on the classpath Set<String> classpathEntries = new HashSet<String>(); for (IClasspathEntry cpEntry : JavaCore.create(project).getRawClasspath()) { classpathEntries.add(cpEntry.getPath().toPortableString()); } assertTrue(classpathEntries.contains("/simple/src/main/java")); assertTrue(classpathEntries.contains("/simple/target/generated-sources/jcasgen")); }
Example 16
Source File: BOSWebServerManager.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
public synchronized void startServer(Repository repository, IProgressMonitor monitor) { if (!serverIsStarted()) { BonitaHomeUtil.configureBonitaClient(); copyTomcatBundleInWorkspace(monitor); monitor.subTask(Messages.startingWebServer); if (BonitaStudioLog.isLoggable(IStatus.OK)) { BonitaStudioLog.debug("Starting tomcat...", EnginePlugin.PLUGIN_ID); } WatchdogManager.getInstance().startWatchdog(); updateRuntimeLocationIfNeeded(); final IRuntimeType type = ServerCore.findRuntimeType(TOMCAT_RUNTIME_TYPE); try { final IProject confProject = createServerConfigurationProject(Repository.NULL_PROGRESS_MONITOR); final IRuntime runtime = createServerRuntime(type, Repository.NULL_PROGRESS_MONITOR); tomcat = createServer(monitor, confProject, runtime); UIDesignerServerManager uidManager = UIDesignerServerManager.getInstance(); if (uidManager.getPortalPort() != portConfigurator.getHttpPort()) { uidManager.setPortalPort(portConfigurator.getHttpPort()); uidManager.stop(); uidManager.start(repository, monitor); } createLaunchConfiguration(tomcat, Repository.NULL_PROGRESS_MONITOR); confProject.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, Repository.NULL_PROGRESS_MONITOR); startResult = null; tomcat.start(ILaunchManager.RUN_MODE, result -> startResult = result); waitServerRunning(); } catch (final CoreException e) { if (tomcat != null) { try { tomcat.delete(); tomcat = null; } catch (CoreException e1) { BonitaStudioLog.error(e1); } } handleCoreExceptionWhileStartingTomcat(e); } } }
Example 17
Source File: SourceRepositoryStore.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
private void incrementaBuild() throws CoreException { if (RepositoryManager.getInstance().getCurrentRepository().isBuildEnable()) { final IProject project = RepositoryManager.getInstance().getCurrentRepository().getProject(); project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, Repository.NULL_PROGRESS_MONITOR); } }
Example 18
Source File: ProjectUtils.java From developer-studio with Apache License 2.0 | 4 votes |
public static void buildProject(IProject project) throws CoreException{ project.build(IncrementalProjectBuilder.CLEAN_BUILD, new NullProgressMonitor()); project.build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor()); }
Example 19
Source File: PerformanceTest.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
@Test public void testBuildOfDownstreamProject() throws Exception { final IJavaProject project = PerformanceTestProjectSetup.testProject; final IJavaProject downStreamProject = PerformanceTestProjectSetup.createJavaProject("performance.test.project.downstream", new String[] { JavaCore.NATURE_ID, "org.eclipse.pde.PluginNature" }); JavaProjectSetupUtil.addProjectReference(downStreamProject, project); new ToggleXtextNatureCommand().toggleNature(downStreamProject.getProject()); final IFolder sourceFolder = JavaProjectSetupUtil.addSourceFolder(downStreamProject, "src"); JavaProjectSetupUtil.addSourceFolder(downStreamProject, "xtend-gen"); sourceFolder.getFolder("foo").create(true, true, null); final IFile sourceFile = sourceFolder.getFile("foo/MyFile.xtend"); StringConcatenation _builder = new StringConcatenation(); _builder.append("package foo"); _builder.newLine(); _builder.newLine(); _builder.append("import org.eclipse.xtext.xbase.formatting.BasicFormatterPreferenceKeys"); _builder.newLine(); _builder.append("import org.eclipse.xtext.xbase.formatting.FormattableDocument"); _builder.newLine(); _builder.append("import org.eclipse.xtext.xbase.formatting.HiddenLeafAccess"); _builder.newLine(); _builder.append("import org.eclipse.xtext.xbase.formatting.NodeModelAccess"); _builder.newLine(); _builder.append("import org.eclipse.xtext.xbase.formatting.XbaseFormatter2"); _builder.newLine(); _builder.newLine(); _builder.append("class MyFile extends XbaseFormatter2 {"); _builder.newLine(); _builder.append("\t"); _builder.newLine(); _builder.append("\t"); _builder.append("def a(BasicFormatterPreferenceKeys keys) {"); _builder.newLine(); _builder.append("\t\t"); _builder.append("BasicFormatterPreferenceKeys::indentation"); _builder.newLine(); _builder.append("\t"); _builder.append("}"); _builder.newLine(); _builder.append("\t"); _builder.newLine(); _builder.append("\t"); _builder.append("def b(FormattableDocument doc) {"); _builder.newLine(); _builder.append("\t\t"); _builder.append("doc.cfg.get(BasicFormatterPreferenceKeys::indentation)"); _builder.newLine(); _builder.append("\t"); _builder.append("}"); _builder.newLine(); _builder.append("\t"); _builder.newLine(); _builder.append("\t"); _builder.append("def c(HiddenLeafAccess x) {"); _builder.newLine(); _builder.append("\t\t"); _builder.append("x.getHiddenLeafsAfter(null).newLines"); _builder.newLine(); _builder.append("\t"); _builder.append("}"); _builder.newLine(); _builder.append("\t"); _builder.newLine(); _builder.append("\t"); _builder.append("def d(NodeModelAccess x) {"); _builder.newLine(); _builder.append("\t\t"); _builder.append("x.nodeForEObject(null).asTreeIterable"); _builder.newLine(); _builder.append("\t"); _builder.append("}"); _builder.newLine(); _builder.append("}"); _builder.newLine(); StringInputStream _stringInputStream = new StringInputStream(_builder.toString()); sourceFile.create(_stringInputStream, true, null); final IProject p = downStreamProject.getProject(); p.build(IncrementalProjectBuilder.FULL_BUILD, null); p.build(IncrementalProjectBuilder.FULL_BUILD, null); Stopwatches.resetAll(); p.build(IncrementalProjectBuilder.FULL_BUILD, null); }
Example 20
Source File: BuildUtil.java From APICloud-Studio with GNU General Public License v3.0 | 2 votes |
/** * Asynchronous run of a builder with the given name on the given project. * * @param project * @param kind * See {@link IncrementalProjectBuilder} for the available types. * @param builderName * @param args * @param monitor * @throws CoreException */ public static void asyncBuild(IProject project, int kind, String builderName, Map args, IProgressMonitor monitor) throws CoreException { project.build(kind, builderName, args, monitor); }