kordamp/enforcer-gradle-plugin

[question] how to see the details of error

Opened this issue · 11 comments

hi @aalmiray

thanks for the gradle plugin, i come from maven enforcer plugin which is used in most of our projects.

i have the project enforcer setup with BanDuplicateClasses rule

    enforce {
        rule(enforcer.rules.BanDuplicateClasses)
    }

the build failed but without any detail, i don't know which classes are duplicate.

$ ./gradlew build
Type-safe dependency accessors is an incubating feature.

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':demo-service'.
> [AFTER_PROJECT :demo-service] An Enforcer rule has failed

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.4/userguide/command_line_interface.html#sec:command_line_warnings

When a rule fails there should be a print out explaining the failure. All rules behave like that.
Do you have a reproducible project where this behavior can be observed?

unfortunately i can't share the project, could you share the tips of diagnosing? thx

Can you reproduce with a smaller self-contained project?

HI @aalmiray! Thanks for the plugin.

I faced the same issue, though. Here is a project to reproduce: https://github.com/estroykov/enforcer-gradle-plugin-rule-is-not-specified-in-output

@estroykov thank you for the link to the repository. However, its configuration does not match the reported issue and thus can't reproduce what @rr-nick-tan encountered.

@aalmiray Do you mean I use other rule in my example? Ok, anyway, is there any way to have a name (or custom message) of a failed rule in my case?

I believe every rule exposes a message property you may use to set a custom message. https://kordamp.org/enforcer-gradle-plugin/#_rules

@aalmiray I did use message property (see link above) but it didn't affect output.

@aalmiray I have the same issue, could you please take a look?

I also noticed something suspicious with integration tests. Do all zeros look ok to you?
изображение

I can see the custom message if the plugin is applied to the settings.gradle file but not to build.gradle. There may be a timing issue or a missing collector for error messages.

I can see the custom message if the plugin is applied to the settings.gradle file but not to build.gradle. There may be a timing issue or a missing collector for error messages.

Ok and do you think it is an issue or not? I would like to apply it to build.gradle and missing message confuses devs about what actually is wrong - so it seems like an issue to me.