Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

delombok does not find all modules on module path #824

Open
A-Willems opened this issue Jun 30, 2023 · 2 comments
Open

delombok does not find all modules on module path #824

A-Willems opened this issue Jun 30, 2023 · 2 comments

Comments

@A-Willems
Copy link

A-Willems commented Jun 30, 2023

After we migrated our project to the Java Module System we encountered that not all modules on the modulePath are recognized.

The attached example is a simple gradle project that can be used to reproduce the problem: module-sample.zip

First, gradlew :application:run shows that the module-info.java is implemented correctly and the program executes as it should.

My module-info.java looks like this:

module delombok.sample.app {
    exports delombok.sample;

    requires lombok;
    requires org.slf4j;
    requires com.google.gson;
    requires org.apache.commons.lang3;

    opens delombok.sample to com.google.gson;
}

My delombok task allows to run with or without modulePath, so it's easier to reproduce the problem from command line:

delombok {
    dependsOn tasks.findByName('cleanDelombok')

    verbose = true

    if (project.hasProperty('withModulePath')) {

        modulePath = configurations.runtimeClasspath
    }
}

Calling gradlew :application:delombok does not set the delombok modulePath and produces the following output:

/home/user/tmp/module-sample/application/src/main/java/module-info.java:5: error: module not found: org.slf4j
    requires org.slf4j;
                ^
/home/user/tmp/module-sample/application/src/main/java/module-info.java:6: error: module not found: com.google.gson
    requires com.google.gson;
                       ^
/home/user/tmp/module-sample/application/src/main/java/module-info.java:7: error: module not found: org.apache.commons.lang3
    requires org.apache.commons.lang3;
                               ^

This shows, that there are three modules (org.slf4j, com.google.gson and org.apache.commons.lang3) that cannot be found. In this case it is not surprising as the modulePath was not set.

Finally calling gradlew -PwithModulePath :application:delombok produces:

/home/user/tmp/module-sample/application/src/main/java/module-info.java:5: error: module not found: org.slf4j
    requires org.slf4j;
                ^
/home/user/tmp/module-sample/application/src/main/java/module-info.java:6: error: module not found: com.google.gson
    requires com.google.gson;
                       ^

In this case, the module path of the delombok task is set (which I confirmed in the temporarily generated delombok.options). Now, the Apache Commons module was found, but SLF4J and GSON were still missing.

The question is: Am I doing something wrong or is this a problem within the delombok task?

Regards,
Achim

@larsgrefer
Copy link
Member

Could be this bug from lombok itself: projectlombok/lombok#2829

@moaxcp
Copy link

moaxcp commented Apr 25, 2024

It looks like the solution was a plugin that skips module-info.java when delombok is run. Maybe this is an option you can add to the Delombok task?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants