ant - 无法让 Apache Ivy 不从 Spring 存储库下载源代码

标签 ant repository ivy

在我的项目中,我使用 Ivy 来解决依赖关系。我使用 Spring 的存储库。问题是我不想下载源代码和许可证/通知文件。产生问题的设置如下:

ivyconf.xml

<ivysettings>
<settings defaultResolver="default" />
<resolvers namespace="apache">
    <chain name="default" returnFirst="true">

    <url name="com.springsource.repository.bundles.release">
        <!--<ivy pattern="http://repository.springsource.com/ivy/bundles/release/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" />-->
        <!-- or this one? -->
        <ivy pattern="http://repository.springsource.com/ivy/bundles/release/[organisation]/[module]/[revision]/ivy-[revision].xml" />
        <artifact pattern="http://repository.springsource.com/ivy/bundles/release/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" />
    </url>

    <url name="com.springsource.repository.bundles.external">
        <!--<ivy pattern="http://repository.springsource.com/ivy/bundles/external/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" />-->
        <ivy pattern="http://repository.springsource.com/ivy/bundles/external/[organisation]/[module]/[revision]/ivy-[revision].xml" />
        <artifact pattern="http://repository.springsource.com/ivy/bundles/external/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" />
    </url>

    </chain>
</resolvers>

</ivysettings>

ivy.xml

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="file:///home/nikem/workspace/ark/test.xsl"?>
<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="com.foo-corp" module="bar" /> 

<configurations>
    <conf name="runtime" description="Modules needed for running the application"/>
</configurations>

<dependencies>

    <dependency org="org.apache.batik" name="com.springsource.org.apache.batik.dom.svg" rev="1.7.0" conf="runtime->runtime">
        <exclude type="src" ext="jar" conf="runtime"/>
    </dependency>
    <dependency org="org.apache.batik" name="com.springsource.org.apache.batik.bridge" rev="1.7.0" conf="runtime->runtime" />

    <exclude type="src" ext="jar" conf="runtime"/>
    <exclude type="javadoc" ext="jar" conf="runtime"/>
    <exclude type="license" ext="txt" conf="runtime"/>
</dependencies>
</ivy-module>

build.xml

<project name="yunowork" default="ivy-runtime" basedir="." xmlns:ivy="antlib:org.apache.ivy.ant">

<property name="run.lib.dir" value="projlib"/>
<property name="lib.dir" value="lib"/>

<taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant" classpath="${lib.dir}/ivy.jar"/>

<target name="clean-lib" description="Removes all libraries">
    <delete dir="${run.lib.dir}" includes="*.jar"/>
</target>

<target name="ivy-clean-cache" description="Cleans Ivy cache">
    <ivy:cleancache />
</target>

<target name="ivy-runtime">
    <ivy:settings file="ivyconf.xml"/>
    <ivy:resolve file="ivy.xml"/>
    <ivy:retrieve pattern="${run.lib.dir}/[artifact].[ext]" conf="runtime"/>
</target>
</project>

在 Ivy 的缓存中我看到:

<publications>
    <artifact name="com.springsource.org.apache.batik.dom.svg"/>
    <artifact name="com.springsource.org.apache.batik.dom.svg-sources" type="src" ext="jar"/>
    <artifact name="license" type="license" ext="txt"/>
    <artifact name="notice" type="license" ext="txt"/>
</publications>

默认情况下,它们会针对所有配置发布。

问题是:为什么源文件和许可证文件没有被排除?

最佳答案

实现我想要的(没有来源,没有许可证/通知文件)的一种解决方法是添加 type<ivy:retrieve>任务。

<ivy:retrieve pattern="${run.lib.dir}/[artifact].[ext]" type="jar" />

在这种情况下,我不需要任何 <exclude>标签。然而,这并没有回答为什么排除一开始不起作用的问题。

关于ant - 无法让 Apache Ivy 不从 Spring 存储库下载源代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6506114/

相关文章:

java - Ant:从ant执行java程序并存储返回值

git - Heroku 'Permission denied (publickey) fatal: Could not read from remote repository' 困境

Symfony2 - 多对多关系和 LIMIT

java - 为 Apache Ivy 提供特定于开发人员的配置

Apache Ivy : Dependency Ivy FIles

java - 针对多个浏览器运行 selenium webdriver 测试用例

java - 如何将 <junit> 任务的工作目录设置为 basedir 以外的目录?

ivy - Apache ivy 取消发布任务?

java - eclipse 火星 : ANT Task references missing SWT library

object - 在 DDD 中定义多对多关系