Skip to content

Commit 3813dd4

Browse files
committed
Update README
1 parent e9f737e commit 3813dd4

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

README.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ If you really don't know how to configure javac to compile `module-info.java` co
1010
## Usage
1111

1212
Currently this tool supports being used as a command line tool, and also supports being added as a Maven dependency.
13-
A Gradle plugin will be provided in the future.
13+
It also includes a prebuilt Gradle task. In the future I may provide a Gradle plugin to use it.
1414

1515
### Use as a CLI tool
1616

@@ -40,4 +40,35 @@ Gradle:
4040

4141
```kotlin
4242
implementation("org.glavo:module-info-compiler:1.2")
43+
```
44+
45+
### Gradle Task (`CompileModuleInfo`)
46+
47+
First, you can add it to the classpath of your Gradle build script like this:
48+
49+
```kotlin
50+
buildscript {
51+
repositories {
52+
mavenCentral()
53+
}
54+
55+
dependencies {
56+
classpath("org.glavo:module-info-compiler:1.2")
57+
}
58+
}
59+
```
60+
61+
Then you can create a task that compiles `module-info.java` like this:
62+
63+
```kotlin
64+
tasks.create<org.glavo.mic.tasks.CompileModuleInfo>("compileModuleInfo") {
65+
sourceFile.set(file("src/main/module-info.java"))
66+
targetFile.set(buildDir.resolve("classes/java/module-info/module-info.class"))
67+
68+
targetCompatibility = 9 // Optional, defaults to 9
69+
encoding = "UTF-8" // Optional, defaults to UTF-8
70+
moduleVersion = "1.0.0" // Optional
71+
moduleMainClass = "simple.Main" // Optional
72+
73+
}
4374
```

0 commit comments

Comments
 (0)