-
Notifications
You must be signed in to change notification settings - Fork 0
Build Monitor: per-builder events and example view #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,6 +49,7 @@ | |
| import org.eclipse.core.resources.IProject; | ||
| import org.eclipse.core.resources.IProjectDescription; | ||
| import org.eclipse.core.resources.IResource; | ||
| import org.eclipse.core.resources.IResourceChangeEvent; | ||
| import org.eclipse.core.resources.IResourceDelta; | ||
| import org.eclipse.core.resources.IResourceStatus; | ||
| import org.eclipse.core.resources.IncrementalProjectBuilder; | ||
|
|
@@ -262,6 +263,11 @@ private void basicBuild(int trigger, IncrementalProjectBuilder builder, Map<Stri | |
| currentTree = ((trigger == IncrementalProjectBuilder.FULL_BUILD) || clean) ? null : workspace.getElementTree(); | ||
| int depth = -1; | ||
| ISchedulingRule rule = null; | ||
| IProject builderProject = builder.getProject(); | ||
| ICommand builderCommand = builder.getCommand(); | ||
| String builderName = builderCommand != null ? builderCommand.getBuilderName() : null; | ||
| workspace.broadcastProjectBuildEvent(builderProject, builderName, | ||
| IResourceChangeEvent.PRE_PROJECT_BUILD, trigger); | ||
| try { | ||
| //short-circuit if none of the projects this builder cares about have changed. | ||
| if (!needsBuild(currentBuilder, trigger)) { | ||
|
|
@@ -274,9 +280,9 @@ private void basicBuild(int trigger, IncrementalProjectBuilder builder, Map<Stri | |
| String name = currentBuilder.getLabel(); | ||
| String message; | ||
| if (name != null) { | ||
| message = NLS.bind(Messages.events_invoking_2, name, builder.getProject().getFullPath()); | ||
| message = NLS.bind(Messages.events_invoking_2, name, builderProject.getFullPath()); | ||
| } else { | ||
| message = NLS.bind(Messages.events_invoking_1, builder.getProject().getFullPath()); | ||
| message = NLS.bind(Messages.events_invoking_1, builderProject.getFullPath()); | ||
| } | ||
| monitor.subTask(message); | ||
| hookStartBuild(builder, trigger); | ||
|
|
@@ -302,7 +308,9 @@ private void basicBuild(int trigger, IncrementalProjectBuilder builder, Map<Stri | |
| //do the build | ||
| SafeRunner.run(getSafeRunnable(currentBuilder, trigger, args, status, monitor)); | ||
| } finally { | ||
| // Re-acquire the WS lock, then release the scheduling rule | ||
| // Re-acquire the WS lock, then release the scheduling rule, so | ||
| // POST_PROJECT_BUILD listeners see the same locking state as | ||
| // PRE_PROJECT_BUILD listeners did: WS lock held, no rule held. | ||
| if (depth >= 0) { | ||
| getWorkManager().endUnprotected(depth); | ||
| } | ||
|
|
@@ -313,23 +321,28 @@ private void basicBuild(int trigger, IncrementalProjectBuilder builder, Map<Stri | |
| throw handleRuleConflict(false, currentBuilder, e); | ||
| } | ||
| } | ||
| // Be sure to clean up after ourselves. | ||
| if (clean || currentBuilder.wasForgetStateRequested()) { | ||
| currentBuilder.setLastBuiltTree(null); | ||
| } else if (currentBuilder.wasRememberStateRequested()) { | ||
| // If remember last build state, and FULL_BUILD | ||
| // last tree must be set to => null for next build | ||
| if (trigger == IncrementalProjectBuilder.FULL_BUILD) { | ||
| try { | ||
| workspace.broadcastProjectBuildEvent(builderProject, builderName, | ||
| IResourceChangeEvent.POST_PROJECT_BUILD, trigger); | ||
| } finally { | ||
|
Comment on lines
+324
to
+327
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
| // Be sure to clean up after ourselves. | ||
| if (clean || currentBuilder.wasForgetStateRequested()) { | ||
| currentBuilder.setLastBuiltTree(null); | ||
| } else if (currentBuilder.wasRememberStateRequested()) { | ||
| // If remember last build state, and FULL_BUILD | ||
| // last tree must be set to => null for next build | ||
| if (trigger == IncrementalProjectBuilder.FULL_BUILD) { | ||
| currentBuilder.setLastBuiltTree(null); | ||
| } | ||
| // else don't modify the last built tree | ||
| } else { | ||
| // remember the current state as the last built state. | ||
| ElementTree lastTree = workspace.getElementTree(); | ||
| lastTree.immutable(); | ||
| currentBuilder.setLastBuiltTree(lastTree); | ||
| } | ||
| // else don't modify the last built tree | ||
| } else { | ||
| // remember the current state as the last built state. | ||
| ElementTree lastTree = workspace.getElementTree(); | ||
| lastTree.immutable(); | ||
| currentBuilder.setLastBuiltTree(lastTree); | ||
| hookEndBuild(builder); | ||
| } | ||
| hookEndBuild(builder); | ||
| } | ||
| } finally { | ||
| currentBuilders.remove(currentBuilder); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potential
NullPointerExceptionifbuilder.getCommand()returnsnull. According to theIncrementalProjectBuilder#getCommand()documentation, the returned value may be null if the builder was not created from a build command. A defensive check should be added before accessing the builder name to ensure the build process is not interrupted by an unexpected NPE.