You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
*[#112](https://github.com/gradlex-org/java-module-dependencies/issues/114) Settings plugin to configure module locations and identity
5
+
3
6
## Version 1.6.6
4
7
*[#113](https://github.com/gradlex-org/java-module-dependencies/issues/113) Fix: Do not fail for duplicated project names (Thanks [TheGoesen](https://github.com/TheGoesen))
5
8
*[#111](https://github.com/gradlex-org/java-module-dependencies/issues/111) Fix: Do not use 'MapProperty.unset' (Thanks [TheGoesen](https://github.com/TheGoesen))
A Gradle 7.4+ plugin to make Gradle use dependencies from _module-info.java_ files automatically.
6
+
A Gradle plugin to make Gradle use dependencies from _module-info.java_ files automatically.
7
7
If you have a project that fully uses Java Modules, you do **not** need to declare dependencies in the `dependencies { }` block anymore.
8
8
Gradle will use the information from your `module-info.java` directly.
9
9
10
-
To manage the versions of Java Modules, the plugin conveniently integrates with
10
+
Minimal required Gradle version:
11
+
-**Gradle 7.4** if you **not** use the plugin in `settings.gradle.kts`
12
+
-**Gradle 8.8** to use the plugin in `settings.gradle.kts` and the [additional functionality](#project-structure-definition-when-using-this-plugin-as-settings-plugin) that comes with it.
13
+
14
+
To manage the versions of Java Modules, the plugin integrates with
11
15
[Platform Projects](https://docs.gradle.org/current/userguide/java_platform_plugin.html#sec:java_platform_usage) and
12
16
[Dependency Versions Constraints](https://docs.gradle.org/current/userguide/dependency_constraints.html#sec:adding-constraints-transitive-deps) in general
13
17
as well as [Version Catalogs](https://docs.gradle.org/current/userguide/platforms.html#sub:version-catalog).
@@ -22,36 +26,28 @@ There is a [CHANGELOG.md](CHANGELOG.md).
22
26
23
27
# Java Modules with Gradle
24
28
25
-
If you plan to build Java Modules with Gradle, you should consider using these plugins on top of Gradle core:
29
+
If you build Java Modules with Gradle, you should consider using these plugins on top of Gradle core:
Only if your (existing) project cannot avoid using non-module legacy Jars
33
-
34
-
[Here is a sample](https://github.com/gradlex-org/java-module-testing/tree/main/samples/use-all-java-module-plugins)
35
-
that shows all plugins in combination.
36
+
Only if you cannot avoid using non-module legacy Jars
36
37
37
38
[In episodes 31, 32, 33 of Understanding Gradle](https://github.com/jjohannes/understanding-gradle) I explain what these plugins do and why they are needed.
[Full Java Module System Project Setup](https://github.com/jjohannes/gradle-project-setup-howto/tree/java_module_system) is a full-fledged Java Module System project setup using these plugins.
-[java-module-system](https://github.com/jjohannes/java-module-system) contains a compact sample and further documentation
47
+
-[gradle-project-setup-howto](https://github.com/jjohannes/gradle-project-setup-howto/tree/java_module_system) is a full-fledged Java Module System project setup
48
+
-[hedera-services](https://github.com/hashgraph/hedera-services) is an open-source Java project using this plugin large scale
53
49
54
-
For general information about how to structure Gradle builds and apply community plugins like this one to all subprojects
50
+
For general information about how to structure Gradle builds and apply community plugins like this one
55
51
you can check out my [Understanding Gradle video series](https://www.youtube.com/playlist?list=PLWQK2ZdV4Yl2k2OmC_gsjDpdIBTN0qqkE).
56
52
57
53
## Plugin dependency
@@ -61,7 +57,7 @@ Add this to the build file of your convention plugin's build
module("module-a") // Module in directory, discovers 'src/*/java/module-info.java' files
111
+
112
+
module("module-b") {
113
+
group = "org.example" // define group early so that all subprojects know all groups
114
+
artifact = "lib-x" // Gradle subproject name (if differnt than directory)
115
+
plugin("java-library") // apply plugin to the Module's subproject to omit 'build.gradle'
116
+
}
117
+
118
+
directory("modules") { // Auto-include all Modules in subfolders of 'modules'
119
+
group = "org.example" // group for all Modules
120
+
plugin("java-library") // apply plugin to all Modules' subprojects
121
+
module("app") { ... } // individualise Module (only if needed)
122
+
}
123
+
124
+
versions("gradle/versions") // subproject configured as Platform Project
125
+
}
126
+
```
127
+
128
+
## Project structure definition when using this plugin as Project Plugin
129
+
130
+
In this setup, subprojects with Java Modules are configured as in any traditional Gradle build: by using the
131
+
`include(...)` statement in `settings.gradle(.kts)`. The plugin is then applied in all subprojects with Java Modules,
132
+
ideally through a convention plugin. If you use the plugin like this, it needs to [make some assumption](#naming-patterns-for-modules-in-the-build-if-used-as-project-plugin)
133
+
due to missing information and thus, for example, requires you to have the Gradle _project names_, _groups_ and _Java Module Names_ align.
134
+
The preferred way to use the plugin is to use it as [Settings Plugin](#project-structure-definition-when-using-this-plugin-as-settings-plugin).
135
+
99
136
## Define additional module dependencies in build files
100
137
101
138
With this plugin you move dependency definitions into `module-info.java` files and no longer use the `dependencies {}` block in build files.
@@ -104,8 +141,8 @@ For this, the plugin offers an extension of Gradle's DSL to be used in `build.gr
104
141
105
142
```
106
143
mainModuleInfo {
107
-
runtimeOnly("org.slf4j.simple") // runtime only dependency for the 'main' module
108
-
annotationProcessor("dagger.compiler") // annotation processor dependency for the 'main' module
144
+
runtimeOnly("org.slf4j.simple") // runtime only dependency for the 'main' module
145
+
annotationProcessor("dagger.compiler") // annotation processor dependency for the 'main' module
109
146
}
110
147
```
111
148
@@ -116,9 +153,9 @@ The only case where this should be used is for whitebox testing activated via th
0 commit comments