【问题标题】:How to exclude jasperreports artifact from jasperreports maven plugin如何从 jasperreports maven 插件中排除 jasperreports 工件
【发布时间】:2016-03-15 14:22:58
【问题描述】:

我的 pom 中有以下插件:

<plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>jasperreports-maven-plugin</artifactId>
                    <version>1.0-beta-2</version>
                    <dependencies>                       
                        <dependency>
                            <!-- The dependency specified by the plugin doesn't work so we must provide our own -->
                            <groupId>net.sf.jasperreports</groupId>
                            <artifactId>jasperreports</artifactId>
                            <version>${jasperreports.version}</version>
                            <exclusions>
                                <exclusion>
                                    <groupId>jfree</groupId>
                                    <artifactId>jcommon</artifactId>
                                </exclusion>
                                <exclusion>
                                    <groupId>com.lowagie</groupId>
                                    <artifactId>itext</artifactId>
                                </exclusion>
                            </exclusions>
                        </dependency>
                        <!-- Groovy compiler seems to be required but not part of JasperReports' specified dependencies-->
                        <dependency>
                            <groupId>org.codehaus.groovy</groupId>
                            <artifactId>groovy-all</artifactId>
                            <version>${groovy.version}</version>
                        </dependency>
                        <dependency>
                            <groupId>com.lowagie</groupId>
                            <artifactId>itext</artifactId>
                            <version>${itext.version}</version>
                        </dependency>
                    </dependencies>
                </plugin>

上述插件的 1.0-beta-2 版本指向 1.2.0 版本的 jasperreports 工件,该工件又指向 [2.1, ) 的开放式 commons-collections 在 1.0-beta-2 pom 中:

<dependency>
      <groupId>jasperreports</groupId>
      <artifactId>jasperreports</artifactId>
      <version>1.2.0</version>
    </dependency>

在 jasperreports 1.2.0 pom 中:

<dependency>
            <groupId>commons-collections</groupId>
            <artifactId>commons-collections</artifactId>
            <version>[2.1,)</version>
            <scope>compile</scope>
        </dependency>

在我的例子中,其他人推动了一个 nexus 存储库,一个名为 3.2.1-redhat-7 commons-collections 的工件。 jasperreports-maven-plugin 指向上面的集合版本,它恰好是一个损坏的版本。有一个有效的 3.2.1 版本的 commons 集合。我需要排除 jasperreports 工件并强制 jasperreports-maven-plugin 使用 net.sf.jasperreports。 我已经尝试添加

<dependency>
                            <groupId>org.codehaus.mojo</groupId>
                            <artifactId>jasperreports-maven-plugin</artifactId>
                            <version>1.0-beta-2</version>
                            <exclusions>
                                <exclusion>
                                    <groupId>jasperreports</groupId>
                                    <artifactId>jasperreports</artifactId>
                                </exclusion>
                            </exclusions>
                        </dependency>

到上面的插件,但它仍然指向相同的 1.2.0 jasperreports,它指向一个开放式的 commons-collections,并且构建失败。 但是,如果我在 jasperreports-maven-plugin.pom 中注释掉依赖项“jasperreports”,它会使用来自 net.sf.jasperreports 的 jasperreports 并构建良好。 请告诉我。

【问题讨论】:

    标签: maven jasper-reports maven-plugin


    【解决方案1】:

    很抱歉没有真正回答(由于缺乏声誉,目前无法发表评论),但是:
    1.
    如果你像我一样着急, 这是一种解决方法,来自 http://community.jaspersoft.com/questions/967926/issue-maven-plugin-codehaus-dec-9-2015:

    你需要添加

    https://maven.repository.redhat.com/nexus/content/groups/product-ga

    作为您的远程仓库之一。

    非常感谢joel.witham

    2.
    我认为this 回答 Maven dependency management for plugin dependencies

    是最有希望的..即不要排除 jasper-1.2,但要确保它使用正确的依赖版本。

    【讨论】:

    • 在我的 settings.xml 中添加 porduct-ga 作为另一个镜像解决了这个问题。谢谢。
    • 当我尝试明确使用 1.2 的 jasperreports 工件,排除开放式 commons-collections 并强制它使用特定的 commons-collections 版本时,还有其他问题。所以,我不得不依靠远程仓库作为临时修复。
    • 我明确将 commons-collections-3.2.1 作为另一个 depdendecy 添加到 jasperreports-maven-plugin..worked..我删除了 product-ga repo..仍然有效..然后我删除了再次显式依赖..仍然有效?!?。也许同时有人在公共回购中解决了这个问题..当我注释掉明确的 commons-collection dep 时,我可以研究什么版本的 commons-collections jasperreports-maven 现在使用,但我觉得我在这方面花了足够的时间;- )。我可以解决运行 mvn -X install 并看到它使用 3.2.1 然后我明确设置它..
    【解决方案2】:

    试试这个配置:

    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>jasperreports-maven-plugin</artifactId>
        <version>1.0-beta-2</version>
        ...
        <dependencies>
            ...
            <dependency>
                <groupId>commons-collections</groupId>
                <artifactId>commons-collections</artifactId>
                <version>3.2.1</version>
            </dependency>
             <dependency>
                <groupId>jasperreports</groupId>
                <artifactId>jasperreports</artifactId>
                <version>1.2.0</version>
                <exclusions>
                    <exclusion>
                        <groupId>commons-collections</groupId>
                        <artifactId>commons-collections</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
        </dependencies>
    </plugin>
    

    【讨论】:

      猜你喜欢
      • 2015-08-29
      • 1970-01-01
      • 2013-03-04
      • 1970-01-01
      • 1970-01-01
      • 2011-02-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多