Skip to content

Commit 7c59a22

Browse files
committed
Update README to recommend applying plugin through convention plugin
1 parent 04ea7d0 commit 7c59a22

File tree

2 files changed

+27
-11
lines changed

2 files changed

+27
-11
lines changed

README.md

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,27 @@ A Gradle 6.4+ plugin to use legacy Java libraries as _Java Modules_ in a modular
1010
This plugin allows you to add module information to a Java library that does not have any.
1111
If you do that, you can give it a proper _module name_ and Gradle can pick it up to put it on the _module path_ during compilation, testing and execution.
1212

13+
The plugin should be applied to **all subprojects** of your multi-project build.
14+
It is recommended to use a [convention plugin](https://docs.gradle.org/current/samples/sample_convention_plugins.html#organizing_build_logic) for that.
15+
16+
## Plugin dependency
17+
18+
Add this to the build file of your convention plugin's build
19+
(e.g. `build-logic/build.gradle(.kts)` or `buildSrc/build.gradle(.kts)`).
20+
21+
```
22+
dependencies {
23+
implementation("de.jjohannes.gradle:extra-java-module-info:0.9")
24+
}
25+
```
26+
27+
## Defining extra module information
28+
In your convention plugin, apply the plugin and define the additional module info:
29+
1330
```
1431
plugins {
15-
id("java-library")
16-
id("de.jjohannes.extra-java-module-info") version "0.9"
32+
...
33+
id("de.jjohannes.extra-java-module-info")
1734
}
1835
1936
// add module information for all direct and transitive dependencies that are not modules
@@ -35,15 +52,14 @@ extraJavaModuleInfo {
3552
module("commons-collections-3.2.2.jar", "org.apache.commons.collections", "3.2.2")
3653
automaticModule("commons-logging-1.2.jar", "org.apache.commons.logging")
3754
}
55+
```
3856

39-
repositories {
40-
mavenCentral()
41-
}
57+
## Dependencies in build files
4258

43-
java {
44-
modularity.inferModulePath.set(true)
45-
}
59+
Now dependencies defined in your build files are all treated as modules if enough extra information was provided.
60+
For example:
4661

62+
```
4763
dependencies {
4864
implementation("com.google.code.gson:gson:2.8.6") // real module
4965
implementation("net.bytebuddy:byte-buddy:1.10.9") // real module with multi-release jar

build.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
*/
1616

1717
plugins {
18-
`java-gradle-plugin`
19-
`maven-publish`
20-
groovy
18+
id("java-gradle-plugin")
19+
id("maven-publish")
20+
id("groovy")
2121
id("com.gradle.plugin-publish") version "0.15.0"
2222
id("com.github.hierynomus.license") version "0.15.0"
2323
}

0 commit comments

Comments
 (0)