Module Checking Gradle Plugin
Table of Contents
Intro #
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.
Get the repo #
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.
Run it #
Finally run it:
./gradlew -Pmodules-check.outputFile=/tmp/results.md modules-check
which produces a markdown table, for example:
jar | OSGI | JPMS | multi-release | module-info.class | Automatic-Module-Name |
---|---|---|---|---|---|
antlr:antlr:2.7.7 | |||||
co.paralleluniverse:quasar-core:0.8.2_r3 | YES | YES | co.paralleluniverse.quasar.core | ||
com.esotericsoftware:kryo:4.0.2 | YES | ||||
com.esotericsoftware:minlog:1.3.0 | YES | ||||
com.esotericsoftware:reflectasm:1.11.3 | YES | ||||
com.fasterxml:classmate:1.3.4 | YES | YES | com.fasterxml.classmate | ||
com.github.ben-manes.caffeine:caffeine:2.7.0 | YES | YES | com.github.benmanes.caffeine |
More information can be found in the README.