22

I have a multi-module project and in the parent pom, I have several reporting plug-ins defined. Some of the modules contain code that does not need to have the reporting plugins run against them and I do not need them included in the generated site. Is there a way I can tell Maven to ignore them at the parent pom level?

Update:

Based on ajozwik's answer I added the skip configuration. My POMs now look like the following...

parent/pom.xml
<modules>
  <module>service</module>
  <module>client</module>
</modules>
<reporting>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-checkstyle-plugin</artifactId>
      <version>2.9.1</version>
    </plugin>
    <plugin>
      <groupId>org.codehaus.mojo</groupId>
      <artifactId>findbugs-maven-plugin</artifactId>
      <version>2.4.0</version>
    </plugin>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-javadoc-plugin</artifactId>
      <version>2.8.1</version>
    </plugin>
    <plugin>
      <groupId>org.codehaus.mojo</groupId>
      <artifactId>cobertura-maven-plugin</artifactId>
      <version>2.5.1</version>
      <configuration>
        <formats>
          <format>html</format>
        </formats>
      </configuration>
    </plugin>
  </plugins>   
</reporting>

client/pom.xml

<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-site-plugin</artifactId>
      <version>3.1</version>
      <configuration>
        <skip>true</skip>
        <skipDeploy>true</skipDeploy>
      </configuration>
    </plugin>
  </plugins>
</build>

When I execute:

mvn clean package site

The build succeeds and the client's target directory does not contain the generated site. When I run:

mvn clean package site site-stage

In order to stage the site, it stages the site correctly. Without the skipDeploy tag, the staging would fail...

Joshua Taylor
  • 84,998
  • 9
  • 154
  • 353
babernathy
  • 803
  • 2
  • 8
  • 23

3 Answers3

15

Have you tried (in child pom)?:

       <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-site-plugin</artifactId>
          <version>3.1</version>
          <configuration>
                <skip>true</skip>
          </configuration>
        </plugin>


Update. You can use property to redefine default behavior. Keep your children poms simple.
In parent pom set (pluginManagement or plugins section)
 <properties>
    <maven-site-plugin.skip>false</maven-site-plugin.skip>
 </properties>

   <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-site-plugin</artifactId>
      <version>3.1</version>
      <configuration>
            <skip>${maven-site-plugin.skip}</skip>
      </configuration>
    </plugin>

In parent pom just redefine maven-site-plugin.skip:

<properties>
    <maven-site-plugin.skip>true</maven-site-plugin.skip>
 </properties>
Andrzej Jozwik
  • 14,331
  • 3
  • 59
  • 68
  • Thank you for the input. I updated my question based on what you provided. – babernathy Jun 01 '12 at 23:35
  • 2
    It seems that (more recently?) most plugins natively support a property to control skipping. `maven.site.skip` and `maven.site.deploy.skip` in this case - see https://maven.apache.org/plugins/maven-site-plugin/deploy-mojo.html – Ed Randall Jul 05 '17 at 10:24
7

You can also ignore report generation on the command line:

mvn -DgenerateReports=false package
neu242
  • 15,796
  • 20
  • 79
  • 114
5

You can also ignore report generation with:

mvn -Dmaven.site.skip=true clean install for example

Bruno Lee
  • 1,867
  • 16
  • 17