A tool for compiling module-info.java for Java alone.
It can easily compile module-info.java for your Java 8 project to fit JPMS without complicated module path configuration.
It can be used as a dependency library, as a command line tool, or as a Gradle plugin.
It only parses the syntax of module-info.java without checking the actual module, so it compiles without configuring the module path.
This tool does not depend on javac, it can run on Java 8 or higher, and you can configure the major version of the target class file.
Using the plugins:
Groovy DSL:
plugins { id "org.glavo.compile-module-info-plugin" version "2.0" }Kotlin DSL:
plugins { id("org.glavo.compile-module-info-plugin") version "2.0" }It takes over compiling module-info.java, so you can easily mix module-info.java in your Java 8 project.
You can also do some configuration like this:
tasks.named<org.glavo.mic.tasks.CompileModuleInfo>("compileModuleInfo") { targetCompatibility = 9 // Optional, defaults to 9 encoding = "UTF-8" // Optional, defaults to UTF-8 moduleVersion = "1.0.0" // Optional moduleMainClass = "simple.Main" // Optional }Here is a sample project: Glavo/compile-module-info-sample
Download the jar from the release page, run it with java -jar module-info-compiler.jar.
The parameters it accepts are as follows:
Usage: gmic [-target <target compatibility>] [-main-class <module main class>] [-module-version <module version>] <source file> <target file> This tool has been published on Maven Central, you can add dependencies to it like this:
Maven:
<dependency> <groupId>org.glavo</groupId> <artifactId>module-info-compiler</artifactId> <version>2.0</version> </dependency>Gradle:
implementation("org.glavo:module-info-compiler:2.0")