Maven报表配置与构建配置

Vit*_*aly 5 maven

有趣的是,两者之间有什么区别

POM中的report-> configuration元素和build-> configuration元素。

它是用POM参考编写的:

细微的区别是,报告元素下的插件配置可以用作构建插件配置,尽管事实并非相反(构建插件配置不会影响报告插件)。

参见http://maven.apache.org/pom.html#Reporting

您能否举一个例子说明行为差异?

Vit*_*aly 5

该声明的含义如下:

如果我们有报告生成插件配置,例如

  <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>
Run Code Online (Sandbox Code Playgroud)

那么调用站点生成命令时将不会使用 linkOnly 配置属性

mvn site
Run Code Online (Sandbox Code Playgroud)

相反,我们应该在报告元素下使用相同的配置:

  <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>
Run Code Online (Sandbox Code Playgroud)

这里我们仅生成配置参数 linkOnly=true 的许可证报告。

即不使用构建配置。

注意:如果我们明确调用报告生成目标“许可证”

mvn project-info-report:license
Run Code Online (Sandbox Code Playgroud)

然后它将使用构建元素下的配置。即我们这里有相反的行为。