Thursday, January 9, 2020

EA Async Gradle plugin

A couple weeks ago I came across EA Async, which transforms Java methods containing "await" calls into a series of asynchronous, non-blocking tasks. This makes it easier to write nice asynchronous code for the JVM. EA Async can perform the transformation at runtime via a Java agent, at build time via a command-line utility, or at build time via a Maven plugin. Using a build system plugin integrates the transformation into the normal development workflow, which is very convenient. Of course, since there's only a Maven plugin, only users of the Maven build system got this benefit.

I like Gradle, another very widely used build system. So yesterday and today I went ahead with writing a Gradle plugin for EA Async. It was a little tricky to build a Gradle plugin with their Maven project, but once I got it compiling it was fairly straightforward thanks to my work on other Gradle plugins. There was a subtlety in taking advantage of the transformer's support for custom CompletionStage implementations. Their class files needed to be accessible through the classloader passed to the transformer, so I had to involve the compilation task's classpath and its output directory to make sure the CompletionStage implementations in the target project were recognized.

I made a pull request today which was merged. The plugin will probably be published in the next EA Async release.

No comments:

Post a Comment