Skip to content

Program output can be difficult to trace and may be jumbled with Maven logs when running Maven with multiple threads #152

@hankolerd

Description

@hankolerd

A common problem I have faced when working on large projects that run with large thread counts is that the executed program output can be hard to identify with the Maven console output.

As an example, a simple Maven multi-module project where each project is executing:

<execution>
  <id>test</id>
  <phase>compile</phase>
  <goals>
    <goal>exec</goal>
  </goals>
  <configuration>
    <executable>bash</executable>
    <arguments>
      <argument>-c</argument>
      <argument><![CDATA[
        for i in {1..10000}
        do
          echo "${project.artifactId} - $i"
        done
      ]]></argument>
    </arguments>
  </configuration>
</execution>

The Maven console output may come as:

[BuilderThread 1] [INFO] --- exec-maven-plugin:1.6.0:exec (test) @ module1 ---
[BuilderThread 2] [INFO] --- exec-maven-plugin:1.6.0:exec (test) @ module2 ---
...
module2 - 98
modu
module1 - 97
module1 -
le2 - 9899
...

It would be great to have an option (or maybe even make it the default behavior) to redirect program output into the Maven logger, so that we can trace the program output within a specific build thread, and so that log output is synchronized to avoid jumbled output. For the example above, the preferred output would be something more similar to:

[BuilderThread 1] [INFO] --- exec-maven-plugin:1.6.0:exec (test) @ module1 ---
[BuilderThread 2] [INFO] --- exec-maven-plugin:1.6.0:exec (test) @ module2 ---
...
[BuilderThread 2] [INFO] module2 - 98
[BuilderThread 1] [INFO] module1 - 97
[BuilderThread 1] [INFO] module1 - 98
[BuilderThread 2] [INFO] module2 - 99
...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions