如何在使用maven构建期间阅读来自system.out.println的警告

时间:2014-03-04 16:33:24

标签: java maven maven-antrun-plugin

我正在使用maven-ant-run插件通过maven运行jar批处理,它很酷,我需要的是能够在maven构建报告中读取system.out.println字符串。

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.6</version>
                <executions>
                    <execution>
                        <phase>clean</phase>
                        <configuration>
                            <target>
                                <echo>
                                    Language synchronization is being started
                                </echo>
                                <exec executable="cmd.exe"
                                      spawn="true">
                                    <arg value="/c"/>
                                    <arg value="${languagesynch.path}"/>
                                    <arg value="C:\ContinuousIntegration\res" /> <!--copy from-->
                                    <arg value="${project.basedir}\res" /> <!--to this directory-->


                                </exec>
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

它只显示正在执行的任务和执行的任务。

[INFO] --- maven-antrun-plugin:1.6:run (default) ---
[INFO] Executing tasks

main:
     [echo] Language synchronization is being started through D:\Projects\MavenI
nHerd\LanguageSynch\out\artifacts\LanguageSynch_jar\LanguageSynch.jar
[INFO] Executed tasks

1 个答案:

答案 0 :(得分:1)

如果使用spawn =“true”,则无法实现。将spawn设置为false(默认值),它可以工作。

更新

尝试使用:

<java fork="true" 
      jar="${languagesynch.path}/dist/test.jar">
    <arg value="C:\ContinuousIntegration\res" /> <!--copy from-->
    <arg value="${project.basedir}\res" /> <!--to this directory-->
</java>

或者,如果由于任何原因你必须使用exec:

<exec executable="cmd.exe" spawn="false">
    <arg value="/c"/>
    <arg value="java"/>
    <arg value="-jar"/>
    <arg value="${languagesynch.path}"/>
    <arg value="C:\ContinuousIntegration\res" /> <!--copy from-->
    <arg value="${project.basedir}\res" /> <!--to this directory-->
</exec>