在两个单独的lib目录中拆分检索到的工件

Wol*_*ang 6 ivy

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

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

其背后的想法是,在后者的一个库由仅前端代码,和由第一个使用两个前端和业务逻辑代码.有一个地方一个类加载器,它可以让业务逻辑代码没有看到罐子在/ web /根目录/ WEB-INF/lib目录下.

我怎么能告诉ivy某些依赖项应该转到第二个目录而其他所有依赖项都转到第一个目录?

由于Web类加载器可以在两个目录中看到jar,而且我不希望jar存在于两个目录中,因此这并不是一件好事.

Mar*_*nor 15

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

的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>
Run Code Online (Sandbox Code Playgroud)

常春藤检索 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>
Run Code Online (Sandbox Code Playgroud)

$ 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
Run Code Online (Sandbox Code Playgroud)