The Java module system has no intention to solve the version selection or verification problem.
However, it does support adding version information to a module jar that is available through the Module API.
Similarly, a ‘requires’ clause on another module will contain the version of the dependency it was compiled against. A prerequisite is that the other module needs to contain the version number.
Having both these versions available through an API makes it possible for other frameworks to verify if an application composed from different modules has compatible versions (e.g. based on semantic versioning).
In a maven build the following usage of the java ‘jar’ tool allows to add the project.version to the modular jar:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<id>add-version-to-jar</id>
<phase>package</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>jar</executable>
<workingDirectory>${project.build.directory}</workingDirectory>
<arguments>
<argument>--update</argument>
<argument>--verbose</argument>
<argument>--module-version</argument>
<argument>${project.version}</argument>
<argument>--file</argument>
<argument>${project.build.finalName}.jar</argument>
<argument>-C</argument>
<argument>${project.build.outputDirectory}</argument>
<argument>.</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
A more detailed description and code showing this can be found on