Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven skip site/reporting for module

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...

like image 723
babernathy Avatar asked May 25 '12 15:05

babernathy


3 Answers

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>
like image 78
Andrzej Jozwik Avatar answered Oct 18 '22 16:10

Andrzej Jozwik


You can also ignore report generation on the command line:

mvn -DgenerateReports=false package
like image 43
neu242 Avatar answered Oct 18 '22 18:10

neu242


You can also ignore report generation with:

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

like image 5
Bruno Lee Avatar answered Oct 18 '22 17:10

Bruno Lee