Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven Report Configuration vs Build Configuration

Tags:

maven

It is interesting what is the differences between

report->configuration element and build->configuration element in POM.

It is written in POM references:

Subtle difference is that a plugin configuration under the reporting element works as build plugin configuration, although the opposite is not true (a build plugin configuration does not affect a reporting plugin).

See http://maven.apache.org/pom.html#Reporting

Could you give particular example of the differences in behaviour?

like image 620
Vitaly Avatar asked Oct 09 '15 08:10

Vitaly


People also ask

What is reporting in Maven?

ReportNG is open-source software, a simple plug-in for the TestNG which is a simple framework to generate HTML reports as a replacement for the default TestNG HTML reports.

What is Maven configuration?

Maven configuration occurs at 3 levels: Project - most static configuration occurs in pom. xml. Installation - this is configuration added once for a Maven installation. User - this is configuration specific to a particular user.

What are the three builds in the Maven life cycle?

There are three built-in build lifecycles: default, clean and site. The default lifecycle handles your project deployment, the clean lifecycle handles project cleaning, while the site lifecycle handles the creation of your project's web site.

What is the difference between plugin and pluginManagement tags?

pluginManagement: is an element that is seen along side plugins. Plugin Management contains plugin elements in much the same way, except that rather than configuring plugin information for this particular project build, it is intended to configure project builds that inherit from this one.


1 Answers

This statement means the following:

If we have report generation plugin configuration like

  <build>
      <plugins>
          <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-project-info-reports-plugin</artifactId>
              <version>2.8</version>

              <configuration>
                  <linkOnly>true</linkOnly>
              </configuration>
          </plugin>
      </plugins>
  </build>

then linkOnly configuration property won't be used when invoking site generation command

mvn site

Instead, we should use the same configuration under reporting element:

  <reporting>
      <plugins>
          <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-project-info-reports-plugin</artifactId>
              <version>2.8</version>

              <configuration>
                  <linkOnly>true</linkOnly>
              </configuration>

              <reportSets>
                  <reportSet>
                      <reports>
                          <report>license</report>
                      </reports>
                  </reportSet>
              </reportSets>
          </plugin>
      </plugins>
  </reporting>

Here we generate only license report with configuration parameter linkOnly=true.

I.e. build configuration is not used.

Note: If we explicitly invoke report generation goal "license"

mvn project-info-report:license

then it will use configuration under build element. I.e. we have opposite behaviour here.

like image 80
Vitaly Avatar answered Sep 30 '22 13:09

Vitaly