Skip to content

provide functionality to automatically "export" / "open" all packages #38

@hendrikebbers

Description

@hendrikebbers

We have several dependencies in our project that does not provide any module support. By using your great plugin we can simply convert all that dependencies to be an automatic module:

automaticModule("com.goterl:lazysodium-java", "lazysodium.java")

We (sadly) still have several of that modules and all will be as automatic modules on the module path at compile time. Based on the definition of automatic modules (see overview at https://stackoverflow.com/questions/46741907/what-is-an-automatic-module) we have a limitation:

Automatic modules imply readability on all other automatic modules, which means a module reading one of them, reads all of them.

Based on that we do not get any error at gradle build time when we do not add all the requires foo.bar definitions in the module-info.java files of our modules. Only one requires statement is needed for all automatic modules.

Example

At compile time we depend on the foo and bar libs (import statements in our code). Since the foo and bar libs have no module support we use your plugin to define them as automatic modules:

plugins {
    id("org.gradlex.extra-java-module-info")
}
extraJavaModuleInfo {
    failOnMissingModuleInfo.set(true)
    automaticModule("foo:foo", "foo")
    automaticModule("bar: bar", "bar")
}

Since we have import statements for both libs in our code you would assume that we need to add requires statements for both of them. But only anyone of the is needed and based on the definition of automatic modules both can be accessed.

What we could to do solve the problem

We could use your api to define the dependency as a "real" module and add exports for all internal packages by hand:

module("foo:foo", "foo") {
        exports("com.foo")
        exports("com.foo.impl")
        exports("com.foo.api")
        exports("com.foo.common")
}

Since this is a lot of work for all Jars it would be great to have a functionally that automatically add exports to all packages of a jar:

module("foo:foo", "foo") {
        exportAllPackages(true)
}

Would that be a possible / interesting new feature for the plugin?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions