Take the 2-minute tour ×

I am new to Maven and I am trying to get strong hold of it. I have gone through the beginner's tutorials and I am able to understand the basic stuff, but I have a complex pom.xml file in my project and my next goal is to understand that.

With the limited knowledge acquired from beginner's guide it is not possible for me to understand that complex pom.xml, so i was thinking of adding some sort of log statements in pom.xml or looking for an alternative via which i could track the flow of execution in pom.xml, since that would help me in knowing how things are moving.

share|improve this question

4 Answers 4

I believe that output generated by debug option in maven can be quite huge and time consuming for reading. I use it only for some specific problem analysis.

For me it allways worked to go through complicated pom.xml files by reading and try to understand intent of the author of the particular section (I think good reference for the pom.xml elements can be found on: http://maven.apache.org/pom.html).

Once you run build afterwards, you can see what and when is it executed and you can find mapping between what you've learned before and how it really works :)

share|improve this answer
+1, -X is usefull only for debugging. –  gontard Aug 22 '12 at 8:01

You could printout some log messages to maven console using the maven-antrun-plugin, you can also specify the phase you want to print the message in, see the code below (it goes to the plugins section)

                    <echo message="Your log message for project ${project.artifactId}" />
share|improve this answer
Can i add this log statement any where in my pom or only with in ant-run plugin scope. –  Bagira Aug 23 '12 at 7:35
No, you cannot add this anywhere - this is not exactly how Maven works. Maven uses plugins that enrich its core features with additional functionality. It happens that antrun plugin is capable of printing log statements if you tell it to. Every plugin has its purpose (goals) and printing logs is rarely one of them. Maven, however, logs all its activity - you can follow the sequence of actions reading the standard log, and if you need some extra debugging info, as mentioned here, use the -X or--debug flag. May I know what kind of information you want to log? –  Marek Dec Aug 23 '12 at 9:34

You can start by issuing

mvn -X install

That will give you the flow of execution.

According to mvn --help:

-X,--debug     Produce execution debug output

An alternative if you want to see all your dependencies, properties, plugins, directories etc. the try this:

mvn help:effective-pom
share|improve this answer

I would recommend to read more about Maven build lifecycle. Maven is not a script-like build automation tool (like ant or make). It's a different approach. Logs should be less important than output artifacts produced in ./target directory.

share|improve this answer

Your Answer


