|
4 | 4 | [](https://plugins.gradle.org/plugin/org.gradlex.java-module-dependencies) |
5 | 5 |
|
6 | 6 | A Gradle 7.4+ plugin to make Gradle use dependencies from _module-info.java_ files automatically. |
7 | | -If you have a project that fully uses Java Modules, you do **not** need to declare dependencies in the `dependencies { }` block anymore |
8 | | -(except for _runtimeOnly_ dependencies). |
| 7 | +If you have a project that fully uses Java Modules, you do **not** need to declare dependencies in the `dependencies { }` block anymore. |
9 | 8 | Gradle will use the information from your `module-info.java` directly. |
10 | 9 |
|
11 | 10 | To manage the versions of Java Modules, the plugin conveniently integrates with |
@@ -73,6 +72,21 @@ plugins { |
73 | 72 | } |
74 | 73 | ``` |
75 | 74 |
|
| 75 | +## Effect of the plugin |
| 76 | + |
| 77 | +Once the plugin is applied, dependencies are automatically determined based on the `requires` directives in your `module-info.java` files. For example: |
| 78 | + |
| 79 | +``` |
| 80 | +module org.example.mymodule { |
| 81 | + requires com.fasterxml.jackson.core; // -> implementation("com.fasterxml.jackson.core:jackson-core") |
| 82 | + requires transitive org.slf4j; // -> api("org.slf4j:slf4j-api") |
| 83 | + requires static jakarta.servlet; // -> compileOnly("jakarta.servlet:jakarta.servlet-api") |
| 84 | + requires /*runtime*/ org.slf4j.simple; // -> runtimeOnly("org.slf4j:slf4j-simple") |
| 85 | +} |
| 86 | +``` |
| 87 | + |
| 88 | +Note that `requires /*runtime*/` is a directive specifically supported by this plugin to allow the specification of _runtime only_ dependencies. |
| 89 | + |
76 | 90 | ## Add Module Name mapping information (if needed) |
77 | 91 |
|
78 | 92 | You may define additional mappings from _Module Name_ to _group:name (GA) coordinates_. |
@@ -139,7 +153,7 @@ dependencies { |
139 | 153 | } |
140 | 154 | ``` |
141 | 155 |
|
142 | | -Note: If you need to declare additional dependencies, e.g. as `runtimeOnly` without version, or want to use Gradle's rich versions, you can also use the `ga()` shortcut to map a Module Name to the corresponding GA coordinates. |
| 156 | +Note: If you need to declare additional dependencies without version, or want to use Gradle's rich versions, you can also use the `ga()` shortcut to map a Module Name to the corresponding GA coordinates. |
143 | 157 | For example: |
144 | 158 |
|
145 | 159 | ``` |
|
0 commit comments