将检索到的工件拆分到两个单独的lib目录中 [英] Split retrieved artifacts in two separate lib directories

查看:62
本文介绍了将检索到的工件拆分到两个单独的lib目录中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

In my web application, there are two separate lib directories:

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

其背后的想法是,后者中的库仅由前端代码使用,而第一个库由两者用作前端和业务逻辑代码.这里有一个类加载器,它使业务逻辑代码 not 不能查看/web/webroot/WEB-INF/lib中的jar.

The idea behind it is that libraries in the latter one are used by front-end code only, and the first one by both the front-end and the business logic code. There is a class loader in place which lets the business logic code not see the jars in /web/webroot/WEB-INF/lib.

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

这不是一件容易的事,因为Web类加载器可以在两个目录中看到jar,而我不希望jar在两个目录中.

It's not trival since the the web class loader can see jars in both directories and I don't want jars to be in both directories.

推荐答案

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

Configurations are used to create logical groupings of dependencies:

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>

常春藤检索 ant任务可以使用以下配置来填充目录:

The ivy retrieve ant task can use these configurations to populate your directories:

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

这篇关于将检索到的工件拆分到两个单独的lib目录中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆