使用通配符模式排除常春藤中的罐子

Excluding jars in ivy using wild card pattern

使用 apache ivy 我想下载 jcs 1.3 jar 文件,但我不想要它附带的其余临时依赖项。无论如何我可以指定常春藤来排除这个特定依赖元素的所有瞬态依赖?或者至少在排除模式中使用通配符?

我查找了 Ivy 文档,但找不到任何关于如何使用匹配器排除文件的 glob/regex 模式的示例。

以下是我的 ivy.xml 的片段,我想避免排除的长列表 name/modules。

    <dependency org="jcs" name="jcs" rev="1.3" conf="*->*,!sources,!javadoc">
        <exclude name='ant-optional' />
        <exclude name='avalon-framework' />
        <exclude name='berkeleydb' />
        <exclude name='commons-beanutils' />
        <exclude name='commons-beanutils-core' />
        <exclude name='commons-codec' />
        <exclude name='commons-collections' />
        <exclude name='commons-configuration' />
        <exclude name='commons-dbcp' />
        <exclude name='commons-digester' />
        <exclude name='commons-jxpath' />
        <exclude name='commons-lang' />
        <exclude name='commons-logging' />
        <exclude name='commons-logging-api' />
        <exclude name='commons-pool' />
        <exclude name='concurrent' />
        <exclude name='hsqldb' />
        <exclude name='jdom' />
        <exclude name='junit' />
        <exclude name='jdbc-stdext' />
        <exclude name='jta' />          
        <exclude name='log4j' />
        <exclude name='logkit' />
        <exclude name='mysql-connector-java' />
        <exclude name='oro' />
        <exclude name='servlet-api' />
        <exclude name='tomcat-util' />
        <exclude name='velocity' />
        <exclude name='xerces' />
        <exclude name='xercesImpl' />
        <exclude name='xmlrpc' />
    </dependency>

其实要简单很多,使用配置映射。这是示例:

<ivy-module version="2.0">
    <info organisation="com.myspotontheweb" module="demo"/>

    <configurations>
        <conf name="compile" description="Required to compile application"/>
        <conf name="runtime" description="Additional run-time dependencies" extends="compile"/>
        <conf name="test"    description="Required for test only" extends="runtime"/>
    </configurations>

    <dependencies>
        <!-- compile dependencies -->
        <dependency org="jcs" name="jcs" rev="1.3" conf="compile->master"/>

    </dependencies>

</ivy-module>

魔术位是以下映射:

compile->master

下面的回答更详细地解释了 ivy 如何解释 Maven 模块:

How are maven scopes mapped to ivy configurations by ivy

master contains only the artifact published by this module itself, with no transitive dependencies

额外

使用配置是一项强大的功能。 cachepath 任务可用于填充 ANT 路径:

   <ivy:cachepath pathid="compile.path" conf="compile"/>
   <ivy:cachepath pathid="test.path"    conf="test"/>