enforcer-gradle-plugin icon indicating copy to clipboard operation
enforcer-gradle-plugin copied to clipboard

[question] how to see the details of error

Open rr-nick-tan opened this issue 2 years ago • 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

rr-nick-tan avatar May 13 '22 05:05 rr-nick-tan

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?

aalmiray avatar May 13 '22 12:05 aalmiray

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

rr-nick-tan avatar May 13 '22 16:05 rr-nick-tan

Can you reproduce with a smaller self-contained project?

aalmiray avatar May 16 '22 07:05 aalmiray

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 avatar Jul 07 '24 18:07 estroykov

@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 avatar Jul 08 '24 09:07 aalmiray

@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?

estroykov avatar Jul 08 '24 16:07 estroykov

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

aalmiray avatar Jul 08 '24 18:07 aalmiray

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

estroykov avatar Jul 08 '24 20:07 estroykov