Skip to content

Commit

Permalink
Issue #88: Make Traute work with gradle apt plugin
Browse files Browse the repository at this point in the history
Avoid throwing/catching exceptions for a project with
many files generated by annotation processors
  • Loading branch information
denis-zhdanov committed Jan 2, 2018
1 parent 53493bb commit 6e6ace5
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import java.lang.reflect.Field;
import java.util.*;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;

import static java.lang.reflect.Modifier.*;
Expand Down Expand Up @@ -125,6 +126,7 @@ public void init(JavacTask task, String... args) {
)));
}
Context context = ((BasicJavacTask) task).getContext();
AtomicBoolean contextClosed = new AtomicBoolean();
TrautePluginSettings settings = getPluginSettings(context);
pluginSettingsRef.set(settings);
task.addTaskListener(new TaskListener() {
Expand Down Expand Up @@ -218,10 +220,14 @@ public void finished(TaskEvent event) {
* @return {@code true} if current context is closed; {@code false} otherwise
*/
private boolean isContextClosed() {
if (contextClosed.get()) {
return true;
}
try {
Log.instance(context);
return false;
} catch (Exception e) {
contextClosed.set(true);
return true;
}
}
Expand Down

0 comments on commit 6e6ace5

Please sign in to comment.