Upgrading to maven 3 from maven 2

2019-07-10 05:52发布

I have upgraded from Maven 2 to Maven 3 and it seems to be working fine to clean install.

However, in the Maven 3.x Compatibility Notes, it is mentioned that the <reporting> tag is no longer supported and should be moved up to the <build> tag.


<reporting>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-project-info-reports-plugin</artifactId>
        <version>2.1</version>
        <reportSets>
          <reportSet>
            <reports>
              <report>dependencies</report>
              <report>dependency-convergence</report>
              <report>dependency-management</report>
              <report>index</report>
              <report>plugin-management</report>
              <report>project-team</report>
              <report>license</report>
              <report>summary</report>
            </reports>
          </reportSet>
        </reportSets>
      </plugin>
    </plugins>
  </reporting>  

I have commented this out and moved the plugin tag and its content, to the <build><plugins> tag.

When I run mvn validate now, I get the following error:

[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR]   The project com.company.projectName:ProjectName:1.2 (C:\Svn\projectName\branches\projectName-1.2\System\4_ImplementationSet\WAS\src\pom.xml) has 1 error
[ERROR]     Malformed POM C:\Svn\projectName\branches\projectName-1.2\System\4_ImplementationSet\WAS\src\pom.xml: Unrecognised tag: 'reportSets' (position: START_TAG seen ...</version>\r\n        <reportSets>... @123:21)  @ C:\Svn\projectName\branches\projectName-1.2\System\4_ImplementationSet\WAS\src\pom.xml, line 123, column 21 -> [Help 2]

Am I missing something? I could just leave things as they are, but I gave it a try to move it, but it did not work.

2条回答
Summer. ? 凉城
2楼-- · 2019-07-10 06:27

Try:

    <plugins>
       ...
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-site-plugin</artifactId>
            <version>3.0</version>
            <configuration>
                <reportPlugins> 
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-project-info-reports-plugin</artifactId>
                        <version>2.4</version>
                        <configuration>
                            <reportSets>
                                <reportSet>
                                    <reports>
                                        <report>dependencies</report>
                                        <report>dependency-convergence</report>
                                        <report>dependency-management</report>
                                        <report>index</report>
                                        <report>plugin-management</report>
                                        <report>project-team</report>
                                        <report>license</report>
                                        <report>summary</report>
                                    </reports>
                                </reportSet>
                            </reportSets>
                        </configuration>
                    </plugin>
                    ...
                </reportPlugins>
            </configuration>
        </plugin>
        ...
    </plugins>

(untested; I'm not sure about the reportSets-part)

查看更多
做自己的国王
3楼-- · 2019-07-10 06:36

It is not simply a matter of copying the tag to a different place. The schema has changed in other ways too.

I suggest that you read the documentation for "Maven 3 only" configuration, since that's what you seem to be trying to do. Here's a link.

查看更多
登录 后发表回答