gradlex-org/extra-java-module-info

Provide functionality to automatically derive 'requires' directives from metadata

Closed this issue · 2 comments

Similar to exportAllPackages() (#38) we can introduce a requireAllDefinedDependencies() to automatically create requires directives based on what is defined in a component metadata (pom.xml / module.json). For this, the GA coordinates in the metadata need to be mapped to the corresponding module names. This knowledge is available for other patched Jars where the module name is introduced through this plugin. An additional knownModule(name, ga) statement should be added to the extension for adding the knowledge for existing modules when needed.

This feature is now on main and can be used as follows:

module("org.apache.httpcomponents:httpclient", "org.apache.httpcomponents.httpclient") {
  requireAllDefinedDependencies()
}

The current solution wouldn't work for any Jar that is not on the main compile/runtime classpath. Instead we should probably use the combined classpaths of all registered source sets, as for all of these the transform is triggered by default.