Skip to content

Commit a18d579

Browse files
committed
Update README
1 parent 6033a8b commit a18d579

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,16 @@ extraJavaModuleInfo {
6565
// failOnMissingModuleInfo.set(false)
6666
module("commons-beanutils:commons-beanutils", "org.apache.commons.beanutils") {
6767
exports("org.apache.commons.beanutils")
68+
// exportAllPackages()
6869
6970
requires("org.apache.commons.logging")
7071
requires("java.sql")
7172
requires("java.desktop")
7273
7374
// requiresTransitive(...)
7475
// requiresStatic(...)
76+
77+
// requireAllDefinedDependencies()
7578
}
7679
module("commons-cli:commons-cli", "org.apache.commons.cli") {
7780
exports("org.apache.commons.cli")
@@ -143,6 +146,22 @@ extraJavaModuleInfo {
143146
}
144147
```
145148

149+
## Should I use real modules or automatic modules?
150+
151+
Only if you use _real_ modules (Jars with `module-info.class`) everywhere you can use all features of the Java Module System
152+
(see e.g. [#38](https://github.com/gradlex-org/extra-java-module-info/issues/38) for why it may be problematic to depend on an automatic module).
153+
Still, using automatic modules is more convenient if you need to work with a lot of legacy libraries, because you do not need to define `exports` and `requires` directives.
154+
Alternatively though, this plugin offers a way to define a _real_ module, without defining all of those directives explicitly:
155+
156+
```
157+
extraJavaModuleInfo {
158+
module("org.apache.httpcomponents:httpclient", "org.apache.httpcomponents.httpclient") {
159+
exportAllPackages() // Adds an `exports` for each package found in the Jar
160+
requireAllDefinedDependencies() // Adds `requires (transitive|static)` directives based on dependencies defined in the component's metadata
161+
}
162+
}
163+
```
164+
146165
## What do I do in a 'split package' situation?
147166

148167
The Java Module System does not allow the same package to be used in more than one _module_.

0 commit comments

Comments
 (0)