This worked for me too. Later, I ended-up switching to the maven-antrun-plugin
to avoid warnings in Eclipse. And I prefer using default plugins when possible. Example:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>get-the-hostname</id>
<phase>package</phase>
<configuration>
<target>
<exec executable="bash">
<arg value="-c"/>
<arg value="hostname"/>
</exec>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>