从maven 2升级到maven 3

时间:2012-05-02 12:02:53

标签: java java-ee maven maven-2 maven-3

我已经从Maven 2升级到Maven 3,它似乎对clean install工作正常。

但是,在Maven 3.x Compatibility Notes中,提到不再支持<reporting>标记,应移动直至<build>标记。


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

对此进行了评论,并将插件标记及其内容移至<build><plugins>标记。

当我现在运行mvn validate时,我收到以下错误:

[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]

我错过了什么吗?我可以把事情保留原样,但是我试着去试一下,但它没有用。

2 个答案:

答案 0 :(得分:3)

这不仅仅是将标签复制到其他地方的问题。模式也在其他方面发生了变化。

我建议您阅读“Maven 3 only”配置的文档,因为这是您似乎要尝试的内容。这是一个link

答案 1 :(得分:3)

尝试:

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

(未经测试;我对reportSets-part不确定)