为什么 maven 不生成项目报告?

2022-09-04 02:18:36

这是Maven 3.0。我正在创建一个新项目:

mvn archetype:create

然后我正在创建一个文件:site/site.xml

<project name="foo">
  <body>
    <menu name="Overview">
      <item name="Introduction" href="index.html" />
    </menu>
    <menu ref="reports" />
  </body>
</project>

然后,我将报告插件添加到:pom.xml

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

然后我跑了,它说.但我在项目网站中看不到任何报告(报告菜单项不存在)。我做错了什么?mvn site"BUILD SUCCESS"


答案 1

Maven 3 报告则不同

[...]
<build>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-site-plugin</artifactId>
    <version>3.0-beta-2</version>
    <configuration>
      <reportPlugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-project-info-reports-plugin</artifactId>
          <version>2.2</version>
          <reports>
            <report>cim</report>
            <report>issue-tracking</report>
          </reports>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-javadoc-plugin</artifactId>
          <version>2.2</version>
        </plugin>
      </reportPlugins>
    </configuration>
  </plugin>
</build>
[...]

答案 2

这个pom工作(即使你没有定义站点.xml文件)

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>it.cucchiara</groupId>
    <artifactId>test</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>test</name>
    <url>http://maven.apache.org</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <reporting>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-project-info-reports-plugin</artifactId>
                <version>2.1.1</version>
            </plugin>
        </plugins>
    </reporting>
</project>

推荐