To make projects compatible with both Java 8 and modular JDKs, a popular strategy
is to compile the project so it produces Java 8 bytecode, and separately compile
the module-info.java
file targeting a modular JDK version.
The Apache Maven documentation includes an example of how to achieve that, but
the Gradle user guide lacks it. This document presents an approach that could
be included in a convention plugin, and requires Gradle 7 or higher (you
could try to adapt it to Gradle 6.x by explicitly enabling inferModulePath
in