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

Disable ANSI decorations for default (embedded) maven logger. #6843

Merged
merged 1 commit into from
Dec 17, 2023

Conversation

mbien
Copy link
Member

@mbien mbien commented Dec 14, 2023

maven-slf4j-provider injects MavenSimpleLogger which decorates the output for terminal use. This causes problems in log files, tests etc which don't expect or cant display them properly.

a quick way to test this:
run NexusRepositoryIndexerImplTest#testFilterPluginGroupIdsRepositoryQueries directly from NB and check that there is no color in the stack trace. The TEST-org.netbeans.modules.maven.indexer.NexusRepositoryIndexerImplTest.xml should also have no escaped ANSI symbols in it.

long way to test would be to run NB and check that the log file is clean.
this is how it should not look:
image

@mbien mbien added the Maven [ci] enable "build tools" tests label Dec 14, 2023
@mbien mbien added this to the NB21 milestone Dec 14, 2023
@mbien mbien requested a review from sdedic December 14, 2023 10:07
@sdedic
Copy link
Member

sdedic commented Dec 15, 2023

A question: I understand it is desirable to disable ansi output for testing, but wouldn't it affect some IDE operations that use Embedder ? Would it be possible to disable the coloring conditionally (i.e. some system property set up by the test infrastructure) ?

@mbien
Copy link
Member Author

mbien commented Dec 15, 2023

@sdedic I convert this back to draft since this trick isn't working anymore today for some reason. (can't explain it, i swear it worked yesterday)

But regarding what is affected: the messags.log is ansi decorated too, the screenshot above is the log opened with my default text editor on linux (xed) - it doesn't look much better when opened in NB. This creates a mess when pasted into issue forms etc.

edit:
the build output in the output window is not affected since 1) maven builds run outside of the IDE and 2) the output window itself does the parsing/coloring/linking etc.

@mbien mbien marked this pull request as draft December 15, 2023 08:10
maven-slf4j-provider injects MavenSimpleLogger which decorates the
output for terminal use. This causes problems in log files, tests etc
which don't expect or cant display them properly.
@mbien mbien force-pushed the mvn-embedder-no-ansi branch from 7a452a0 to 036d646 Compare December 15, 2023 08:34
Comment on lines +322 to +329
<!--
disable Maven's ANSI CLI decorations
maven-slf4j-provider injects MavenSimpleLogger which decorates the output for terminal use
this causes problems in log files, tests etc which don't expect or cant display them properly
<class-path-extension>
<runtime-relative-path>../maven/lib/jansi-2.4.0.jar</runtime-relative-path>
</class-path-extension>
-->
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great !!

@mbien mbien marked this pull request as ready for review December 15, 2023 08:41
@mbien mbien merged commit ce9ca1f into apache:master Dec 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Maven [ci] enable "build tools" tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants