【问题标题】:Upgrading to maven 3 from maven 2从 maven 2 升级到 maven 3
【发布时间】:2012-05-11 21:40:37
【问题描述】:

我已从 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>  

已经对此进行了注释,并将插件标签及其内容移至&lt;build&gt;&lt;plugins&gt; 标签。

当我现在运行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]

我错过了什么吗?我可以让东西保持原样,但我试着移动它,但它没有用。

【问题讨论】:

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


    【解决方案1】:

    试试:

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

    (未经测试;我不确定报告集部分)

    【讨论】:

    • 谢谢!这有效(从 2.4 更改为 2.1 )。至少 mvn validate 没有抱怨 :)
    • 同时您可以使用 maven-site-plugin 3.1 版。此外关于升级的文档maven.apache.org/plugins/maven-site-plugin/maven-3.html
    • 为什么我得到这个异常:java.lang.NoClassDefFoundError: org/sonatype/aether/graph/Dependency ... java.lang.ClassNotFoundException: org.sonatype.aether.graph.Dependency。 .. ?
    【解决方案2】:

    这不仅仅是将标签复制到不同位置的问题。架构也在其他方面发生了变化。

    我建议您阅读“仅限 Maven 3”配置的文档,因为您似乎正在尝试这样做。这是link

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-04-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-01
      相关资源
      最近更新 更多