Search code examples
mavenmaven-antrun-plugin

What does "echo" mean when it comes to using Maven?


I'm currently learning how to use Maven and have encountered a term called "echo". I was just wondering what it actually means?

There are few important concepts related to Maven Lifecycles, which are worth to mention:

1) When a phase is called via Maven command, for example mvn compile, only phases up to and including that phase will execute.

2) Different maven goals will be bound to different phases of Maven lifecycle depending upon the type of packaging (JAR / WAR / EAR).

In the following example, we will attach maven-antrun-plugin:run goal to few of the phases of Build lifecycle. This will allow us to echo text messages displaying the phases of the lifecycle.


Solution

  • echo is an ant task which allow to print messages to console (system.out)

    This makes sense when using maven-antrun-plugin which allow to execute ant tasks in a maven build.

    It can be used to print some maven properties during the build as there is no built-in way to output value to console in maven.

             <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>${maven.antrun.plugin.version}</version>
                <executions>
                    <execution>
                        <phase>validate</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <tasks>
                                <echo>Configuration properties :</echo>
                                <echo>service.endpoint=${service.endpoint}</echo>
                            </tasks>
                        </configuration>
                    </execution>
                </executions>
            </plugin>