HubSpot / dependency-management-maven-plugin

5 stars 6 forks source link

Added custom error messages for dependency and plugin issues #6

Closed Nimisha94 closed 6 years ago

Nimisha94 commented 6 years ago

This PR provides support to pass custom error messages for the following errors -

stevie400 commented 6 years ago

Can you please share some example output here?

Nimisha94 commented 6 years ago

image

Nimisha94 commented 6 years ago

Now the output looks something like this -

image

stevie400 commented 6 years ago

LGTM, with one small comment. I wonder if @jhaber has more thoughts on formatting the output.

It could be worth taking a look at how the custom banned dependencies message is displayed and checking that this is consistent. I also wonder about putting more newlines in between the log messages.

jhaber commented 6 years ago

Awesome! How does it look if the custom message is multiline?

Nimisha94 commented 6 years ago

Multiline message -

image

jhaber commented 6 years ago

And if a user doesn't set any custom messages?

Nimisha94 commented 6 years ago

If a user doesn't give in the pom file, a blank line is shown as of now.

image

jhaber commented 6 years ago

I think we should probably check if the custom message is null before calling log.warn

Nimisha94 commented 6 years ago

I tweaked the code to display the custom message only if given. So, the blank line above doesn't show up even if the user doesn't set any custom messages. For example, looks like this if the user doesn't set <unmanagedDependencyMessage> in the pom file

image

stevie400 commented 6 years ago

I think we should also omit the log.warn(""); if there are no messages to print. One approach could be to add the messages we want to print to a list instead of log.warning them immediately. Then we could log the empty line only when we have messages to print.

Nimisha94 commented 6 years ago

Yes. I was thinking of logging it only when the success flag is false (which happens when there is some dependency or plugin issue).

Nimisha94 commented 6 years ago

I changed the code to display the custom messages only if present by adding them to a list before logging them as warnings. The output is looks like this (if custom messages are given)-

image

The output looks like this if the custom messages are not given -

image

stevie400 commented 6 years ago

Nice, I think this looks great! Have you experimented with adding more newlines / indentation? What do you think about

[WARNING] Found version mismatches in managed dependencies:
[WARNING]   Custom version mismatch message
Nimisha94 commented 6 years ago

Yes. It's behaving in the similar way as the bannedDependencies custom messages has been implemented by the Apache plugin.

Multi-line message without any spaces at the beginning of the second line would be shown this way [WARNING] Found version mismatches in managed dependencies : Custom message line 1. Custom message line 2

Nimisha94 commented 6 years ago

Output look like this now

Given any custom message - image

No custom messages given - image

stevie400 commented 6 years ago

LGTM w/ tweak