如何减去ivy依赖集 [英] How to subtract ivy dependency sets

查看:239
本文介绍了如何减去ivy依赖集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目标是将项目传递依赖关系划分为若干不穿越集:




  • 系统(jars已存在于j2ee容器中;手动列出提供(jars可以复制到j2ee容器,手动列出)

  • ear(要包装在ear / lib中的jar ,其余)



我下面列出的当前解决方案有一些缺点:




  • 必须逐个排除系统和提供的图书馆。/ b>
  • 尚未明确排除的新的第三方传递机构可能会不小心接触到

  • 有时必须添加显式的覆盖复制库名称和版本



是否有一些方法可以消除这些缺点?



由于依赖集的结果,能够以某种方式定义一个conf是很好的扣除其他(优雅冲突解决):
ear =运行时 - 系统 - 提供



也许< conf name =当 982rel =nofollow> IVY-982 得到修正。



寻找一个实际的解决方案。



即使有解决方案,即使愿意考虑切换到毕业。

  <?xml version = 1.0encoding =UTF-8?> 
< ivy-module version =2.0xmlns:xsi =http://www.w3.org/2001/XMLSchema-instance
xsi:noNamespaceSchemaLocation =http:// ant。 apache.org/ivy/schemas/ivy.xsd\">

< info organization =example.commodule =parent/>

<配置defaultconfmapping =compile-> @; runtime-> @; system-> master;提供 - >运行时; ear->运行时; test->默认)>
< conf name =compile/>
< conf name =runtimeextends =compile/>
< conf name =earextends =runtimedescription =要包装的内容/>
< conf name =provideddescription =要复制到j2ee容器的Libs/>
< conf name =systemdescription =j2ee容器中已存在的Lib/>
< conf name =testextends =ear,provided,systemdescription =模拟容器环境,由单元测试用于捕获依赖关系兼容性问题/>
< / configurations>

<依赖关系>
< dependency org =log4jname =log4jrev =1.2.15force =trueconf =system/>
<依赖关系org =commons-collectionsname =commons-collectionsrev =3.1force =trueconf =system/>
< dependency org =commons-langname =commons-langrev =2.2force =trueconf =system/>

< dependency org =org.apache.velocityname =velocityrev =1.7force =trueconf =provided/>
< dependency org =org.slf4jname =slf4j-apirev =1.5.6force =trueconf =provided/>
< dependency org =org.slf4jname =slf4j-log4j12rev =1.5.6force =trueconf =provided/>
<! - ... - >

< dependency name =module1rev =latest.integrationconf =runtime,ear,provided,test/>
< dependency name =module2rev =latest.integrationconf =runtime,ear,provided,test/>
<! - ... - >

< exclude org =commons-collectionsconf =ear,provided/>
< exclude org =commons-langconf =ear,provided/>
< exclude org =org.apache.velocityconf =ear/>
<! - TODO:否定无效:https://issues.apache.org/jira/browse/IVY-982 - >
<! - < exclude org =org.slf4jconf =*,!provided/> - >
< exclude org =org.slf4jconf =ear,test/>
<! - ... - >

< override org =org.slf4jrev =1.5.6/>
< override org =commons-collectionsmodule =commons-collectionsrev =3.1/>
< override org =commons-langmodule =commons-langrev =2.2/>
<! - ... - >
< / dependencies>

< / ivy-module>

可以在 IVY-1443 附件。

解决方案

p>虽然提供的依赖关系可以通过 Maven Gradle ,似乎目前没有办法用ivy轻松实现它。



更新



在某些情况下,任务可以使用中间感应模块和阴性正则表达式面具:

 < dependency org =com.companyname =root.moduleconf =earrev =latest.integration> 
< exclude org =^(?! com.company)。* $matcher =regexp/>
< / dependency>

但是,Ivy似乎正在失去动力,我们已经转到了Gradle。 b $ b

My goal is to demarcate project transitive dependencies into several not crossing sets:

  • system (jars already present in j2ee container; listed manually with explicit fixed versions)
  • provided (jars to be copied to j2ee container; listed manually)
  • ear (jars to be packed inside ear/lib, the rest)

My current solution listed below has some shortcomings:

  • have to exclude system and provided libraries from ear conf one by one
  • new third-party transitive deps that weren't already explicitly excluded could accidentally get to ear
  • sometimes have to add explicit override duplicating library name and version

Is there some approach possible to eliminate these shortcomings?

It would be nice to be able somehow define one conf as a result of dependency sets subtraction of the others (with graceful conflict resolution): ear = runtime - system - provided.

Maybe <conf name="ear" extends="runtime,!system,!provided"/> notation could be supported when IVY-982 gets fixed.

Looking for an actual solution to apply.

Even willing to consider switching to gradle if it has a solution.

<?xml version="1.0" encoding="UTF-8"?>
<ivy-module version="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd">

    <info organisation="example.com" module="parent"/>

    <configurations defaultconfmapping="compile->@;runtime->@;system->master;provided->runtime;ear->runtime;test->test(default)">
        <conf name="compile"/>
        <conf name="runtime" extends="compile"/>
        <conf name="ear" extends="runtime" description="Libs to be packed inside ear"/>
        <conf name="provided" description="Libs to copy to j2ee container"/>
        <conf name="system" description="Libs already present in j2ee container"/>
        <conf name="test" extends="ear,provided,system" description="Simulate container environment. Used by unit tests to catch dependency compatibility problems."/>
    </configurations>

    <dependencies>
        <dependency org="log4j" name="log4j" rev="1.2.15" force="true" conf="system"/>
        <dependency org="commons-collections" name="commons-collections" rev="3.1" force="true" conf="system"/>
        <dependency org="commons-lang" name="commons-lang" rev="2.2" force="true" conf="system"/>

        <dependency org="org.apache.velocity" name="velocity" rev="1.7" force="true" conf="provided"/>
        <dependency org="org.slf4j" name="slf4j-api" rev="1.5.6" force="true" conf="provided"/>
        <dependency org="org.slf4j" name="slf4j-log4j12" rev="1.5.6" force="true" conf="provided"/>
        <!-- ... -->

        <dependency name="module1" rev="latest.integration" conf="runtime,ear,provided,test"/>
        <dependency name="module2" rev="latest.integration" conf="runtime,ear,provided,test"/>
        <!-- ... -->

        <exclude org="commons-collections" conf="ear,provided"/>
        <exclude org="commons-lang" conf="ear,provided"/>
        <exclude org="org.apache.velocity" conf="ear"/>
        <!-- TODO: negation not working: https://issues.apache.org/jira/browse/IVY-982 -->
        <!--<exclude org="org.slf4j" conf="*, !provided"/>-->
        <exclude org="org.slf4j" conf="ear,test"/>
        <!-- ... -->

        <override org="org.slf4j" rev="1.5.6"/>
        <override org="commons-collections" module="commons-collections" rev="3.1"/>
        <override org="commons-lang" module="commons-lang" rev="2.2"/>
        <!-- ... -->
    </dependencies>

</ivy-module>

Sample project sources to experiment with can be found in IVY-1443 attachment.

解决方案

While provided dependencies exclusion is possible with Maven and Gradle, it seems that currently there is no way to easily achieve it with ivy.

Update

In some cases the task can be worked around with intermediate induced module and negative regexp mask:

    <dependency org="com.company" name="root.module" conf="ear" rev="latest.integration">
        <exclude org="^(?!com.company).*$" matcher="regexp"/>
    </dependency>

But we've already moved to Gradle as Ivy seems to be losing momentum.

这篇关于如何减去ivy依赖集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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