Linux 如何即时显示execmaven插件的输出
我正在使用Maven 3.1.1和Linux 如何即时显示execmaven插件的输出,linux,bash,shell,maven,exec-maven-plugin,Linux,Bash,Shell,Maven,Exec Maven Plugin,我正在使用Maven 3.1.1和exec Maven插件(1.3),以便在构建作业期间执行bash脚本 bash脚本使用echo和printf在stdout上生成输出。我注意到脚本的输出并不是即时写入maven控制台输出的。相反,maven控制台输出会“冻结”,直到同时使用bash脚本的多个输出行进行更新。我不知道更新maven输出(超时?完整输出缓冲区?)的触发因素是什么,但速度非常慢 让我们看一个非常简单的bash脚本,例如counter.sh: #!/usr/bin/env bash f
exec Maven插件
(1.3),以便在构建作业期间执行bash脚本
bash脚本使用echo
和printf
在stdout
上生成输出。我注意到脚本的输出并不是即时写入maven控制台输出的。相反,maven控制台输出会“冻结”,直到同时使用bash脚本的多个输出行进行更新。我不知道更新maven输出(超时?完整输出缓冲区?)的触发因素是什么,但速度非常慢
让我们看一个非常简单的bash脚本,例如counter.sh
:
#!/usr/bin/env bash
for i in `seq 1 1000`; do
echo $i
sleep 0.5
done
下面是我在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>
execmaven插件使用的输出流不会自动刷新 我认为你有两个选择:
第二个选项可能会慢一些,因为maven调用ant,ant然后调用您的脚本,但这很简单。正如Ivan已经指出的那样,exec maven插件:1.3不会自动刷新输出流。这可能导致输出延迟 我注意到这种行为只出现在1.3版以后的插件中
execmaven插件:1.2.1实际上具有所需的行为并刷新输出流。因此,您不必使用ant,而可以切换到旧版本的exec maven插件。JFYI,exec maven插件v1.3.2-
<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>