Skip to content

Commit

Permalink
Using AfterBuildActionHook rather than TaskListener
Browse files Browse the repository at this point in the history
  • Loading branch information
dukescript committed Jun 2, 2019
1 parent 95dc440 commit cee89d4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@
import org.netbeans.api.project.ui.OpenProjects;
import org.netbeans.junit.NbModuleSuite;
import org.netbeans.junit.NbTestCase;
import org.netbeans.modules.gradle.spi.actions.AfterBuildActionHook;
import org.netbeans.spi.project.ActionProvider;
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileUtil;
import org.openide.filesystems.LocalFileSystem;
import org.openide.util.TaskListener;
import org.openide.util.lookup.Lookups;

public class CreateArchetypeTest extends NbTestCase {
Expand Down Expand Up @@ -136,7 +136,7 @@ public void testCreateFromArchetype() throws Exception {

protected void invokeCommand(ActionProvider actions, String cmd, Project prj) throws IllegalArgumentException, InterruptedException {
CountDownLatch waiter = new CountDownLatch(1);
TaskListener notifier = (t) -> {
AfterBuildActionHook notifier = (action, context, res, out) -> {
waiter.countDown();
};
actions.invokeAction(cmd, Lookups.fixed(prj, notifier));
Expand Down
2 changes: 1 addition & 1 deletion groovy/gradle/arch.xml
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,7 @@ publishPlugins</args>
When calling
<a href="@org-netbeans-modules-projectapi@/org/netbeans/spi/project/ActionProvider.html">
ActionProvider</a><code>.invokeAction(name, lookup)</code>
an instance of <a href="@org-openide-util@/org/openide/util/TaskListener.html">TaskListener</a>
an instance of <a href="@TOP@/org/netbeans/modules/gradle/spi/actions/AfterBuildActionHook.html">AfterBuildActionHook</a>
can be placed into <code>lookup</code>. It is then notified when the
execution of the action is finished. Useful when writing tests.
</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@
import org.openide.util.BaseUtilities;
import org.openide.util.ContextAwareAction;
import org.openide.util.NbBundle.Messages;
import org.openide.util.TaskListener;
import org.openide.util.actions.Presenter;
import org.openide.util.lookup.Lookups;
import org.openide.util.lookup.ProxyLookup;
Expand Down Expand Up @@ -251,8 +250,8 @@ private static void invokeProjectAction(final Project project, final ActionMappi
prj.reloadProject(true, maxQualily, reloadArgs);
}
project.getLookup().lookup(AfterBuildActionHook.class).afterAction(action, outerCtx, task.result(), out1);
for (TaskListener l : context.lookupAll(TaskListener.class)) {
l.taskFinished(t);
for (AfterBuildActionHook l : context.lookupAll(AfterBuildActionHook.class)) {
l.afterAction(action, outerCtx, task.result(), out1);
}
});
}
Expand Down

0 comments on commit cee89d4

Please sign in to comment.