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

Resolves #152 - Adds option to redirect program output of exec:exec to the maven logger. #153

Merged
merged 1 commit into from
May 31, 2020

Conversation

hankolerd
Copy link
Contributor

These changes would add two new options to exec:exec goal:

  • exec.useMavenLogger - Program standard and error output will be redirected to the Maven logger as Info and Error level logs, respectively. If not enabled the program output is redirected to standard System.out and System.err of the parent Maven process (i.e. the old plugin behavior). NOTE: This option is ignored when exec.outputFile is specified.
  • exec.quiet - When combined with exec.useMavenLogger=true, prints all executed program output at debug level instead of the default info level to the Maven logger.

Please see the javadocs in the code for more information.

@hankolerd hankolerd changed the title 152 - Adds option to redirect program output of exec:exec to the maven logger. Resolves #152 - Adds option to redirect program output of exec:exec to the maven logger. May 21, 2020
@olamy olamy merged commit 13d1369 into mojohaus:master May 31, 2020
@khmarbaise khmarbaise added this to the 3.0.0 milestone Jun 9, 2020
{
getLog().debug("Will redirect program output to Maven logger");
final String parentThreadName = Thread.currentThread().getName();
final String logSuffix = "[" + parentThreadName + "] ";

Choose a reason for hiding this comment

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

more of a prefix instead of a suffix… but it always says [main] for me and as such is redundant and unnecessary in the output (makes it unnecessarily wider)…

Choose a reason for hiding this comment

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

In Jenkins, they are [pool-1-thread-1 for channel], making the output definitely too wide to read.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mirabilos Good point about prefix instead of suffix, my bad.
As for always getting [main], were you running Maven multi-threaded on a reactor that is bound to have 2 projects running in parallel with this plugin? This option adds no value for single threaded builds, but can become an aid in tracing program output in large reactors with lots of threads. For example 1000+ projects running with 50+ threads.

@mirabilos
Copy link

mirabilos commented Jun 16, 2020 via email

@hankolerd
Copy link
Contributor Author

Yes, I understand. But for single-threaded execution it’s rather redundant and annoying. Is there a way to detect whether it runs multi-threaded, so it could disable the prefix if not?

This new useMavenLogger option itself should be disabled by default. If your environment is using single threaded builds then simply don't enable this new option to stick with the old behavior. My expectation for this property is that it would be enabled on command line at the same time multi-threaded builds are enabled, for example: mvn clean install -T 32 -Dexec.useMavenLogger=true. It doesn't add value for local builds of single projects, and is more useful for CI/CD builds.

@mirabilos
Copy link

mirabilos commented Jun 16, 2020 via email

@hankolerd
Copy link
Contributor Author

Hi @mirabilos - I created Pull Request #157 to at least address your concern to not print the thread name prefix when Maven itself is not running with multiple threads.

Your points above about how scripts tend to use stderr/stdout I am sure are completely valid, but I am not a shell power user, so it is well beyond my limited understanding. If you find this solution is not honoring the original intention behind stderr/stdout (or how these are most commonly used by scripts) I am not at all offended if you propose a patch to these changes that more closely aligns with them.

Cheers!

@mirabilos
Copy link

mirabilos commented Jun 18, 2020 via email

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

Successfully merging this pull request may close these issues.

4 participants