How do I display the effective pom of a project?
Author: Deron Eriksson
Description: This tutorial describes how to display the effective pom for a project.
Tutorial created using: Windows Vista || JDK 1.6.0_04 || Eclipse Web Tools Platform 2.0.1 (Eclipse 3.3.1)


The mavenSW "help:effective-pom" goal can be used to display the effective pomW of a project. The effective pom represents the current pom state for a project. This isn't just the project's pom, but it also factors in things like the maven super pom and active profiles.

I created an EclipseSW external tool configuration to make it easy to call the "help:effective-pom" goal for a project.

Name:mvn help~effective-pom
Location:C:\dev\apache-maven-2.0.8\bin\mvn.bat
Working Directory:${project_loc}
Arguments:help:effective-pom

The external tool configuration window is shown here.

External Tool Configuration

I selected the "mytest" project and then selected the "mvn help~effective-pom" external tool configuration.

Executing 'mvn help:effective-pom' on 'mytest' project

Here, we can see the console output from executing the "help:effective-pom" goal on "mytest".

Console output from 'mvn help:effective-pom' for 'mytest' project

[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'help'.
[INFO] ------------------------------------------------------------------------
[INFO] Building mytest
[INFO]    task-segment: [help:effective-pom] (aggregator-style)
[INFO] ------------------------------------------------------------------------
[INFO] [help:effective-pom]
[INFO] 
************************************************************************************
Effective POM for project 'com.maventest:mytest:jar:1.0-SNAPSHOT'
************************************************************************************
<?xml version="1.0"?><project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.maventest</groupId>
  <artifactId>mytest</artifactId>
  <name>mytest</name>
  <version>1.0-SNAPSHOT</version>
  <url>http://maven.apache.org</url>
  <build>
    <sourceDirectory>C:\dev\workspace\mytest\src\main\java</sourceDirectory>
    <scriptSourceDirectory>src/main/scripts</scriptSourceDirectory>
    <testSourceDirectory>C:\dev\workspace\mytest\src\test\java</testSourceDirectory>
    <outputDirectory>C:\dev\workspace\mytest\target\classes</outputDirectory>
    <testOutputDirectory>C:\dev\workspace\mytest\target\test-classes</testOutputDirectory>
    <resources>
      <resource>
        <directory>C:\dev\workspace\mytest\src\main\resources</directory>
      </resource>
    </resources>
    <testResources>
      <testResource>
        <directory>C:\dev\workspace\mytest\src\test\resources</directory>
      </testResource>
    </testResources>
    <directory>C:\dev\workspace\mytest\target</directory>
    <finalName>mytest-1.0-SNAPSHOT</finalName>
    <plugins>
      <plugin>
        <artifactId>maven-help-plugin</artifactId>
        <version>2.0.2</version>
      </plugin>
    </plugins>
  </build>
  <repositories>
    <repository>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <id>central</id>
      <name>Maven Repository Switchboard</name>
      <url>http://repo1.maven.org/maven2</url>
    </repository>
  </repositories>
  <pluginRepositories>
    <pluginRepository>
      <releases>
        <updatePolicy>never</updatePolicy>
      </releases>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <id>central</id>
      <name>Maven Plugin Repository</name>
      <url>http://repo1.maven.org/maven2</url>
    </pluginRepository>
  </pluginRepositories>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>commons-lang</groupId>
      <artifactId>commons-lang</artifactId>
      <version>2.3</version>
      <scope>compile</scope>
    </dependency>
  </dependencies>
  <reporting>
    <outputDirectory>target/site</outputDirectory>
  </reporting>
</project>
************************************************************************************


[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Sat Feb 09 22:28:20 PST 2008
[INFO] Final Memory: 2M/5M
[INFO] ------------------------------------------------------------------------

For comparison, here is the actual pom.xml file for the mytest project. Notice that the effective pom includes many elements not present in the mytest pom.xml.

Actual pom.xml file of 'mytest' project

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>com.maventest</groupId>
	<artifactId>mytest</artifactId>
	<packaging>jar</packaging>
	<version>1.0-SNAPSHOT</version>
	<name>mytest</name>
	<url>http://maven.apache.org</url>
	<dependencies>
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>3.8.1</version>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>commons-lang</groupId>
			<artifactId>commons-lang</artifactId>
			<version>2.3</version>
			<scope>compile</scope>
		</dependency>
	</dependencies>
</project>