desruisseaux commented on PR #959:
URL: 
https://github.com/apache/maven-compiler-plugin/pull/959#issuecomment-3371826357

   Yes, compiling a project which uses the module source hierarchy would result 
in many JAR files, one per module. For each JAR, the dependencies in the 
`pom.xml` would be the intersection of the dependencies declared in the 
`pom.xml` of the Maven project and the dependencies declared directly or 
indirectly (including transitive dependencies and service providers) in the 
`module-info.java` of each Java module. In other words, Maven `<dependencies>` 
section would effectively become a `<dependenciesManagement>`.
   
   **Note 1:** this is already the case in Maven 3: any dependency declared in 
Maven `<dependencies>` will be ignored (except for some particular things such 
as annotation processor) by the compiler if it is not implied by some 
statements in `module-info`, even in single-module projects using the package 
hierarchy.
   
   **Note 2:** this idea is not only mine. I saw it independently expressed 
somewhere on GitHub, but couldn't find it back. For information, some of the 
ideas related to module-info support are also found in slightly different forms 
in the [Christian Stein's 
blog](https://github.com/sormuras/java-module-patching?tab=readme-ov-file#introduce-new-module-modifier-patch),
 themselves based on Robert Scholte's emails on OpenJDK mailing list 
(references in the blog). I think that the same idea appears independently 
because in a modular world, the fact that `<dependencies>` would effectively 
behave as `<dependenciesManagement>` is not in our control (unless we choose to 
generate `--add-modules` options).
   
   **Note 3:** about 10 years ago, the `maven-jar-plugin` was just zipping 
whatever exist in `target/classes/` with the addition of a `MANIFEST.MF` file. 
But now, there are [some options such as 
`--hash-modules`](https://docs.oracle.com/en/java/javase/25/docs/specs/man/jar.html#operation-modifiers-valid-only-in-create-and-update-modes)
 which require a module-path. So creating a JAR file is already becoming more 
`<dependencies>`-dependent than before.
   
   **Note 4:** while Maven is still quite JAR-oriented, JAR files are not 
necessarily the main artifacts anymore. The main artifact could be the `jlink` 
output, in which case a multi-module project can still produce a single 
artifact (the executable application), and `*.jar` files are only intermediate 
outputs like the `*.class` files.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to