【问题标题】:Split retrieved artifacts in two separate lib directories在两个单独的 lib 目录中拆分检索到的工件
【发布时间】:2011-05-03 12:42:34
【问题描述】:

在我的 Web 应用程序中,有两个单独的 lib 目录:

  • /lib,和
  • /web/webroot/WEB-INF/lib

其背后的想法是,后者中的库仅由前端代码使用,而第一个库同时前端和业务逻辑代码使用。有一个类加载器可以让业务逻辑代码看到 /web/webroot/WEB-INF/lib 中的 jars。

我如何告诉 ivy 某些依赖项应该转到第二个目录,而所有其他依赖项应该转到第一个目录?

这不是微不足道的,因为 web 类加载器可以在两个目录中看到 jars,我不希望 jars 在两个目录中。

【问题讨论】:

    标签: ivy


    【解决方案1】:

    配置用于创建依赖的逻辑分组:

    ivy.xml

    <ivy-module version="2.0">
        <info organisation="com.myspotontheweb" module="demo"/>
        <configurations>
            <conf name="frontEnd" description="Jars used by front end"/>
            <conf name="businessLogic" description="Jars used for business logic"/>
        </configurations>
        <dependencies>
            <dependency org="commons-lang"    name="commons-lang"    rev="2.5"   conf="businessLogic->default"/>
            <dependency org="commons-codec"   name="commons-codec"   rev="1.4"   conf="businessLogic->default"/>
            <dependency org="commons-cli"     name="commons-cli"     rev="1.2"   conf="frontEnd->default"/>
            <dependency org="commons-logging" name="commons-logging" rev="1.1.1" conf="frontEnd->default"/>
        </dependencies>
    </ivy-module>
    

    ivy retrieve ant 任务可以使用这些配置来填充您的目录:

    build.xml

    <target name="init" description="--> retrieve dependencies with ivy">
        <ivy:retrieve conf="businessLogic" pattern="lib/[artifact].[ext]"/>
        <ivy:retrieve conf="frontEnd" pattern="web/webroot/WEB-INF/lib/[artifact].[ext]"/>
    </target>
    

    示例

    $ find . -type f
    ./build.xml
    ./ivy.xml
    ./lib/commons-lang.jar
    ./lib/commons-codec.jar
    ./web/webroot/WEB-INF/lib/commons-cli.jar
    ./web/webroot/WEB-INF/lib/commons-logging.jar
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-03
    • 2021-10-26
    • 1970-01-01
    • 1970-01-01
    • 2015-03-01
    • 1970-01-01
    相关资源
    最近更新 更多