Felk opened a new issue, #12199:
URL: https://github.com/apache/maven/issues/12199

   ### Affected version
   
   4.0.0-rc-5
   
   ### Bug description
   
   With maven 4 (4.0.0-rc-5), comparing it to 3.9.12, an executions' stdout is 
cached until the end of the build. Inattentive me got confused by this and 
thought that the maven build just exited mid-build. With maven 3, the stdout 
gets printed at the right place, namely during the execution of the respective 
goal.  
   For my case, namely using the `exec-maven-plugin`, I can fix this by setting 
my executions' `useMavenLogger` to true. I suspect, but haven't verified it, 
that this potentially affects all plugins writing to stdout.
   
   To illustrate, here's a minimal POM with two executions. The latter one uses 
`useMavenLogger`.
   ```xml
   <?xml version="1.0"?>
   <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
https://maven.apache.org/xsd/maven-4.0.0.xsd"; 
xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
     <modelVersion>4.0.0</modelVersion>
     <groupId>com.example</groupId>
     <artifactId>acme</artifactId>
     <version>0.1.0-SNAPSHOT</version>
   
     <properties>
       <java.version>25</java.version>
       <maven.compiler.release>${java.version}</maven.compiler.release>
       <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
       
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
     </properties>
   
     <build>
       <plugins>
         <plugin>
           <groupId>org.apache.maven.plugins</groupId>
           <artifactId>maven-resources-plugin</artifactId>
           <version>3.5.0</version>
         </plugin>
   
         <plugin>
           <groupId>org.codehaus.mojo</groupId>
           <artifactId>exec-maven-plugin</artifactId>
           <version>3.6.3</version>
           <executions>
             <execution>
               <id>exec-step-1</id>
               <phase>validate</phase>
               <goals><goal>exec</goal></goals>
               <configuration>
                 <executable>echo</executable>
                 <arguments><argument>step1</argument></arguments>
   <!--              <useMavenLogger>true</useMavenLogger>-->
               </configuration>
             </execution>
             <execution>
               <id>exec-step-2</id>
               <phase>validate</phase>
               <goals><goal>exec</goal></goals>
               <configuration>
                 <executable>echo</executable>
                 <arguments><argument>step2</argument></arguments>
                 <useMavenLogger>true</useMavenLogger>
               </configuration>
             </execution>
           </executions>
         </plugin>
       </plugins>
     </build>
   </project>
   ```
   
   Here's the output of maven 3:
   ```
   $ /c/Program\ Files/Maven/apache-maven-3.9.12/bin/mvn process-resources
   [INFO] Scanning for projects...
   [INFO]
   [INFO] --------------------------< com.example:acme 
>--------------------------
   [INFO] Building acme 0.1.0-SNAPSHOT
   [INFO]   from pom.xml
   [INFO] --------------------------------[ jar 
]---------------------------------
   [INFO]
   [INFO] --- exec:3.6.3:exec (exec-step-1) @ acme ---
   step1
   [INFO]
   [INFO] --- exec:3.6.3:exec (exec-step-2) @ acme ---
   [INFO] step2
   [INFO]
   [INFO] --- resources:3.5.0:resources (default-resources) @ acme ---
   [INFO] skip non existing resourceDirectory D:\repos\test\src\main\resources
   [INFO] 
------------------------------------------------------------------------
   [INFO] BUILD SUCCESS
   [INFO] 
------------------------------------------------------------------------
   [INFO] Total time:  0.628 s
   [INFO] Finished at: 2026-06-01T11:35:35+02:00
   [INFO] 
------------------------------------------------------------------------
   ```
   
   And here's the output of maven 4:
   ```
   $ /c/Program\ Files/Maven/apache-maven-4.0.0-rc-5/bin/mvn process-resources
   [WARNING] Unable to find the root directory. Create a .mvn directory in the 
root directory or add the root="true" attribute on the root project's model to 
identify it.
   [INFO] Scanning for projects...
   [INFO]
   [INFO] ---------------------------------------------------< com.example:acme 
>---------------------------------------------------
   [INFO] Building acme 0.1.0-SNAPSHOT
   [INFO]   from pom.xml
   [INFO] ---------------------------------------------------------[ jar 
]----------------------------------------------------------
   [INFO] Loaded 22901 auto-discovered prefixes for remote repository central 
(prefixes-central.txt)
   [INFO]
   [INFO] --- exec:3.6.3:exec (exec-step-1) @ acme ---
   [INFO] Loaded 50 auto-discovered prefixes for remote repository ow2-snapshot 
(prefixes-ow2-snapshot-40669f8efefaadb4c1705a2585cefc8851f735ac.txt)
   [INFO]
   [INFO] --- exec:3.6.3:exec (exec-step-2) @ acme ---
   [INFO] step2
   [INFO]
   [INFO] --- resources:3.5.0:resources (default-resources) @ acme ---
   [INFO] skip non existing resourceDirectory D:\repos\test\src\main\resources
   [INFO] 
--------------------------------------------------------------------------------------------------------------------------
   [INFO] BUILD SUCCESS
   [INFO] 
--------------------------------------------------------------------------------------------------------------------------
   [INFO] Total time:  0.938 s
   [INFO] Finished at: 2026-06-01T11:35:58+02:00
   [INFO] 
--------------------------------------------------------------------------------------------------------------------------
   [INFO] [stdout] step1
   ```
   
   This might be an emergent behaviour of how some internals regarding parallel 
build were re-constructed, but from a user perspective I'd consider this a 
usability bug (in that it's an annoyance or confusion, not really a defect).
   
   Suggestion: Output each plugin's stdout at the end of the current goal at 
the latest.
   Alternatively, the `exec-maven-plugin` could probably change the default of 
`useMavenLogger` to true. In this case I could open an issue for discussion 
over at https://github.com/mojohaus/exec-maven-plugin. Other plugins printing 
to stdout could similarly be encouraged to use the maven logger.


-- 
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]

Reply via email to