hankolerd opened a new pull request, #392:
URL: https://github.com/apache/maven-antrun-plugin/pull/392
## Problem Statement
Forked Ant process output is forwarded through Maven logging, but in
parallel Maven builds the output may be emitted by an Ant stream worker thread
instead of the Maven build thread that owns the module. This makes output from
parallel modules difficult to associate with the correct project.
## Summary of Change
This change adds an opt-in option that prefixes forked-process output with
the owning Maven build thread name.
With Maven thread names enabled, normal Maven messages identify the module,
but forked Ant output only identifies the Ant stream worker thread. With the
new option enabled, the forked output retains the owning Maven module thread
name as well.
**Before**:
```text
19:00:48.722 [mvn-builder-sample-module-a] [INFO] Executing tasks
19:00:48.723 [Thread-4] [INFO] [exec] antrun.test.artifact =
sample-module-a
```
**After**:
```text
19:00:48.722 [mvn-builder-sample-module-a] [INFO] Executing tasks
19:00:48.723 [Thread-4] [INFO] [exec] [mvn-builder-sample-module-a]
antrun.test.artifact = sample-module-a
```
NOTE: The outer `Thread-4` is the thread delivering the Ant process output.
The additional `mvn-builder-sample-module-a` prefix is what identifies the
Maven project that owns the Ant execution.
## Configuration
Enable the plugin option explicitly:
```xml
<configuration>
<includeMavenThreadName>true</includeMavenThreadName>
</configuration>
```
The equivalent system property is:
`-Dmaven.antrun.includeMavenThreadName=true`
To display Maven thread names in the surrounding Maven log, configure the
Maven installation `conf/logging/simplelogger.properties` file with:
```text
org.slf4j.simpleLogger.showThreadName=true
```
## Compatibility
- The option defaults to `false`, preserving existing output by default.
- The prefix is applied only when Maven is running in parallel.
- Output emitted on the owning Maven thread, such as inline Ant tasks, is
not
prefixed a second time.
- The existing `MavenLogger(Log)` constructor remains compatible.
- Sequential builds and existing configurations are unchanged.
## Implementation
`MavenLogger` captures the owning Maven thread when constructed. For
messages delivered by another thread, it temporarily adds the owner thread name
to the Ant `BuildEvent`, delegates to the existing Maven logging path, and
restores the original message afterward.
## Tests
- mvn -nsu test — 6 unit tests passed.
- mvn -nsu -Prun-its verify — 30 integration tests passed.
- Added a multi-module Invoker integration test that runs two neutral
sample modules in parallel and validates their actual
`mvn-builder-<artifactId>` output prefixes.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]