tags:

views:

143

answers:

1

I can easily see if there are conflicts between (transitive) dependency versions using:

mvn dependency:tree -Dverbose=true

... this will show the full resolution tree, including which elements were omitted (for duplicate or conflict or whatever). What I would like to do is to add the full tree to the 'mvn site' report.

Currently, the site report includes the dependency tree but only as resolved, i.e., without any conflicts. I see in the project-info-reports plugin that there is not currently any way to do what I want using the standard report.

I tried adding a section to the pom to include the maven-dependency-plugin 'tree' goal with the outputFile specified, but it wasn't included when I ran 'mvn site'. It was something like this:

<reporting>
  ....
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-dependency-plugin</artifactId>
      <reportSets>
        <reportSet>
          <id>deptree</id>
          <reports>
            <report>tree</report>
          </reports>
          <configuration>
            <verbose>true</verbose>
            <outputFile>${project.reporting.outputDirectory}/deptree.txt</outputFile>
          </configuration>

Of course, the 'tree' goal is explicitly identified as not a report, but I was hoping to at least be able to produce a file that I could link to from the generated site. No dice.

Is there any way to force an arbitrary plugin's goal to execute during site generation? Am I totally out of luck here? Obviously I could write my own reporting plugin to do this, and/or submit a patch for the project-info-reports plugin, but I want to make sure I've exhausted all the built-in maven options.

(I'm using maven 2.1.0, but I didn't see anything about a change to this functionality in the release notes for later versions.)

+1  A: 

Is there any way to force an arbitrary plugin's goal to execute during site generation? Am I totally out of luck here?

Just to answer your question, you can bind a mojo to the pre-site phase of the Site Lifecycle:

<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-dependency-plugin</artifactId>
      <executions>
        <execution>
          <id>tree</id>
          <phase>pre-site</phase>
          <goals>
            <goal>tree</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>
<reporting>
  ...
</reporting>

If you then run mvn site, dependency:tree will run.

Pascal Thivent
I can't believe I didn't try this myself. Obvious in retrospect: use the site lifecycle phases in the build section as usual. I was so focused on the reporting section that I didn't even consider it. Thanks!
Zac Thompson