How to instantly display exec-maven-plugin output

I am using Maven 3.1.1 and exec-maven-plugin(1.3) to execute a bash script during a build job.

The bash script prints the output to stdoutc echoand printf. I noticed that the script output is not written to the maven console output instantly. Instead, the maven console output freezes until it is updated with several bash script output lines at once. I don’t know which trigger to update maven output (timeout? Full output buffer?), But it is very slow.

Take a very simple bash script, for example. counter.sh:

#!/usr/bin/env bash
for i in `seq 1 1000`; do
  echo $i
  sleep 0.5
done 

And here is my plugin configuration in pom.xml:

<plugin>
    <artifactId>exec-maven-plugin</artifactId>
    <groupId>org.codehaus.mojo</groupId>
    <version>1.3</version>
    <executions>
        <execution>
            <id>execute-script</id>
            <phase>package</phase>
            <goals>
                <goal>exec</goal>
            </goals>
            <configuration>
                <executable>${project.build.directory}/executable/counter.sh</executable>
            </configuration>
        </execution>
    </executions>
</plugin>

mvn clean package, maven exec-maven-plugin / , script ~ 8 .

script, , ~ 15 .

, , - bash script maven.

: maven-antrun-plugin ( )

<plugin>
    <artifactId>maven-antrun-plugin</artifactId>
    <version>1.7</version>
    <executions>
        <execution>
            <id>execute-script</id>
            <phase>package</phase>
            <goals>
                <goal>run</goal>
            </goals>
            <configuration>
                <target>
                    <exec dir="${project.basedir}" executable="${project.build.directory}/executable/counter.sh" />
                </target>
            </configuration>
        </execution>
    </executions>
</plugin>
+4
3

exec-maven-plugin , .

, :

, , maven ant ant, script, .

+1
+2

exec-maven-plugin: 1.3 . .

, 1.3.

exec-maven-plugin: 1.2.1 really has the desired behavior and clears the output stream. So instead of using ant, you can switch to an older version of exec-maven-plugin.

+1
source

Source: https://habr.com/ru/post/1540476/


All Articles