The existing "guesswork" code should be replaced with proper support, this "experiment" (w/ some PoC code) will aim to achieve that.
To achieve the goal, several aspects of Maven (core and plugins) will need changes. The goal of this experiment is to produce a "demo", but not to produce code that may be used as-is, the goal of this experiment is NOT to produce production ready code. Most probably will have more hacks than anticipated (at least this is what I envision).
New types with existing "jar" present just for reference.
| name | extension | classifier | [flags] | explanation |
|---|---|---|---|---|
| jar | jar | - | [CP] | same as today, added to classpath |
| module | jar | - | [MP] | a JPMS module, added to modulepath |
| java-agent | jar | - | [AG] | ? |
| annotation-processor | jar | - | [AP] | not on classpath/modulepath, m-compiler-p handles it |
| doclet | jar | - | [DOC] | not on classpath/modulepath, m-javadoc-p handles it |
| fatjar | jar | - | [ID,CP] | new type to express "self contained" jar added to classpath |
| fatmodule | jar | - | [ID,MP] | new type to express "self contained" module added to modulepath |
Flags:
Note: from Resolver perspective only the ID flag makes sense (so should be defined in resolver, presence of this flag effectivel stops collection), while all the other flags are "Maven customizations", have no meaning for Resolver.
packaging=module
Pretty much same as today "jar" packaging, but
In "validate" phase:
In "package" phase:
The output of this packaging would be artifactId-version.jar (yes, same as for packaging "jar"), that still can be consumed downstream either as type=jar or type=module, as use case requires.
Maven master changes:
The modified Maven is here: https://github.com/cstamas/maven/tree/module-experiment
The experimental project (uses slf4j-api and slf4j-simple sources, thanks!) consist of 3 parts:
The experimental build project (buildable with modified maven ONLY) is here: https://github.com/cstamas/maven4-jpms-experiment/tree/main
Note: the experimental build project contains a "hack" for IDEA IDE: when you load it up, enable "idea" profile, and IDE will work for you. Still, on CLI you will get what you expect to get.