fed*_*der 11 logging maven maven-antrun-plugin
如何在执行mvn命令时(在阶段/目标中)打印到控制台,但不使用Maven Antrun插件?
为什么我拒绝Antrun解决方案:
目前Ant-echo看起来像这样(参见"hello world"行):
[INFO] --- maven-antrun-plugin:1.7:run (default) @ ejpd-alertmanager-ear ---
[WARNING] Parameter tasks is deprecated, use target instead
[INFO] Executing tasks
main:
[echo] hello world
[INFO] Executed tasks
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
Run Code Online (Sandbox Code Playgroud)
但是,我希望它看起来像这样(见"hello world"行).
[INFO] --- maven-antrun-plugin:1.7:run (default) @ ejpd-alertmanager-ear ---
[WARNING] Parameter tasks is deprecated, use target instead
[INFO] Executing tasks
[INFO] hello world
[INFO] Executed tasks
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
Run Code Online (Sandbox Code Playgroud)
我很肯定,我在这里遗漏了一些东西,因为我不能成为第一个提出这种需求的人.谢谢你的任何聪明提示.
你应该尝试Maven Echo插件:
<plugin>
<groupId>com.soebes.maven.plugins</groupId>
<artifactId>maven-echo-plugin</artifactId>
<version>0.1</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>echo</goal>
</goals>
</execution>
</executions>
<configuration>
<echos>
<echo>This is the Text which will be printed out.</echo>
</echos>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
可通过Maven Central获得.顺便说一句:如果您有进一步的请求/改进,只需提交问题.
您可以使用Björn Ekryd的Echo Maven Plugin,它在Maven Central 中发布。
它具有 Maven 插件所需的正常数量的 XML,输出的格式与其他 Maven 日志行一样,您可以为消息分配严重级别(默认为 INFO)。
<plugin>
<groupId>com.github.ekryd.echo-maven-plugin</groupId>
<artifactId>echo-maven-plugin</artifactId>
<version>1.2.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>echo</goal>
</goals>
<configuration>
<message>war has changed</message>
<level>INFO</level>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
[INFO] --- maven-war-plugin:2.4:war (default-war) @ mymodule ---
[INFO] Packaging webapp
[INFO] Processing war project
[INFO]
[INFO] --- echo-maven-plugin:1.2.0:echo (default) @ mymodule ---
[INFO] war has changed
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
Run Code Online (Sandbox Code Playgroud)
此外,这个插件有95% 的代码覆盖率,这很酷。
我自己没有尝试过,但这里有一个插件可能会有所帮助:
http://code.google.com/p/maven-echo-plugin/
| 归档时间: |
|
| 查看次数: |
9900 次 |
| 最近记录: |