我正在使用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
最佳答案
如果你使用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>
关于java - 如何在使用 Maven 构建期间读取来自 system.out.println 的警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22177599/