Module Checking Gradle Plugin

At work, we started a new project at work recently to modularise a Java and Kotlin code base to use either OSGi or JPMS.

The initial step in that work was to scan all Gradle dependencies to see which supported JPMS, or OSGi, or both.

For OSGi, we simply scan the manifest of the jar files listed as dependencies, and see whether they contain any Bundle-* entries.

For JPMS, we check the jar for a module-info.class file.

To run, clone this repository then build and publish it:

git clone https://github.com/barrylapthorn/gradle-plugins
cd gradle-plugins
# optionally specify the JDK with -Dorg.gradle.java.home=/usr/lib/jvm/java-11-amazon-corretto/
./gradlew check publishToMavenLocal

Then add the plugin to your build.gradle file:

plugins {
    id "net.lapthorn.plugins.modules-check" version "1.0.0"
}

which provides the modules-check task. Finally run it:

./gradlew -Pmodules-check.outputFile=/tmp/results.md modules-check

which produces a markdown table, for example:

jarOSGIJPMSmulti-releasemodule-info.classAutomatic-Module-Name
antlr:antlr:2.7.7
co.paralleluniverse:quasar-core:0.8.2_r3YESYESco.paralleluniverse.quasar.core
com.esotericsoftware:kryo:4.0.2YES
com.esotericsoftware:minlog:1.3.0YES
com.esotericsoftware:reflectasm:1.11.3YES
com.fasterxml:classmate:1.3.4YESYEScom.fasterxml.classmate
com.github.ben-manes.caffeine:caffeine:2.7.0YESYEScom.github.benmanes.caffeine

More information can be found in the README.