Would A Plugin Work As A Multi-Release Jar?

Does Gradle provide any direct support for creating multi-release jars for plugins?

I found this Gradle blog post. But being new to Gradle, it wasn’t obvious to me whether the approach outlined there would work with the plugin development plugin. Will it?


Fifteen days of crickets forced me to eventually make the effort to figure my question out for myself. And the answer is a resounding: Yes! A Plugin Would Work As A Multi-Release JAR.

The project in this download contains a simple example.

The following commands build the plugin implemented in that downloaded project:

gradle publish

gradle --build-file=use.plugin.gradle hello

That puts into $buildDir/repo a Multi-Release JAR with a very simple plugin in it. The plugin was successfully tested with JDK 8, 9, 10 and 11.

For anybody interested, the plugin code itself and the plugin build logic I lifted from two of Gradle’s sample projects: here and here. The Multi-Release JAR build logic I lifted from here.

This simple example has convinced me that Multi-Release JARs are a lot cooler and way more useful than this one guy’s rant against them would have folks believe.