diff --git a/src/main/java/org/codehaus/mojo/exec/ExecMojo.java b/src/main/java/org/codehaus/mojo/exec/ExecMojo.java index a2092474..d24d8dfd 100644 --- a/src/main/java/org/codehaus/mojo/exec/ExecMojo.java +++ b/src/main/java/org/codehaus/mojo/exec/ExecMojo.java @@ -452,8 +452,11 @@ else if ( !StringUtils.isEmpty( argsProp ) ) else if (useMavenLogger) { getLog().debug("Will redirect program output to Maven logger"); - final String parentThreadName = Thread.currentThread().getName(); - final String logSuffix = "[" + parentThreadName + "] "; + // If running parallel, append the projects original (i.e. current) thread name to the program + // output as a log prefix, to enable easy tracing of program output when intermixed with other + // Maven log output. NOTE: The accept(..) methods are running in PumpStreamHandler thread, + // which is why we capture the thread name prefix here. + final String logPrefix = session.isParallel() ? "[" + Thread.currentThread().getName() + "] " : ""; Consumer mavenOutRedirect = new Consumer() { @@ -462,11 +465,11 @@ public void accept(String logMessage) { if (quietLogs) { - getLog().debug(logSuffix + logMessage); + getLog().debug(logPrefix + logMessage); } else { - getLog().info(logSuffix + logMessage); + getLog().info(logPrefix + logMessage); } } }; @@ -476,7 +479,7 @@ public void accept(String logMessage) @Override public void accept(String logMessage) { - getLog().error(logSuffix + logMessage); + getLog().error(logPrefix + logMessage); } };