0

我正在将常春藤用于春季批处理项目。

常春藤.xml

<ivy-module version="2.0">
    <info organisation="apache" module="hello-ivy"/>
    <dependencies>
        <dependency org="commons-lang" name="commons-lang" rev="2.0"/>
        <dependency org="commons-cli" name="commons-cli" rev="1.0"/>
        <dependency org="commons-net" name="commons-net" rev="3.1" />

        <dependency org="com.jcraft" name="jsch" rev="0.1.48"/><!-- used for SFTP-->
        <dependency org="log4j" name="log4j" rev="1.2.17"/>
        <dependency org="com.google.guava" name="guava" rev="14.0-rc2"/>
        <dependency org="joda-time" name="joda-time" rev="2.1"/>

        <dependency org="org.springframework" name="spring-aspects" rev="3.1.2.RELEASE"/>
        <dependency org="org.springframework" name="spring-aop" rev="3.1.2.RELEASE"/>
        <dependency org="org.springframework" name="spring-context" rev="3.1.2.RELEASE"/>
        <dependency org="org.springframework" name="spring-core" rev="3.1.2.RELEASE"/>
        <dependency org="org.springframework" name="spring-test" rev="3.1.2.RELEASE" />
        <dependency org="org.springframework" name="spring-beans" rev="3.1.2.RELEASE" />
        <dependency org="org.springframework" name="spring-jdbc" rev="3.1.2.RELEASE" />

        <dependency org="org.springframework" name="spring-tx" rev="3.1.2.RELEASE" />
        <dependency org="org.springframework" name="spring-asm" rev="3.1.2.RELEASE" />
        <dependency org="org.springframework" name="spring-expression" rev="3.1.2.RELEASE" />
        <dependency org="org.springframework" name="spring-context-support" rev="3.1.2.RELEASE" />

        <dependency org="org.springframework.batch" name="spring-batch-core" rev="2.1.9.RELEASE"/>
        <dependency org="org.springframework.batch" name="spring-batch-infrastructure" rev="2.1.9.RELEASE"/>
    </dependencies>
</ivy-module>

常春藤设置.xml

<ivysettings>
<settings defaultResolver="spring.chain"/>
<resolvers>
    <chain name="spring.chain">
        <url name="com.springsource.repository.bundles.release">
            <ivy pattern="http://repository.springsource.com/ivy/bundles/release/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" />
            <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]" />
            <artifact pattern="http://repository.springsource.com/ivy/bundles/external/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" />
        </url>
        <ibiblio name="ibiblio" m2compatible="true"/>
    </chain>
</resolvers>
</ivysettings>

在我需要 joda2 之前,一切都很棒。这里的问题是 ivy 带来了 com.springsource.org.joda.time-1.6.0.jar 和 joda-time-2.1.jar 之类的东西。有没有一种方法可以让常春藤不从 spring 中带来所有这些克隆 jar(com.springsource.org.joda.time-1.6.0.jar、com.springsource.org.apache.regexp-1.5.0.jar 等)?

谢谢

4

1 回答 1

1

可以使用ivy 文件中的exclude指令排除依赖关系。

<exclude module="com.springsource.org.joda.time"/>

此示例的第二个功能是使用ibiblio解析器从 Maven 存储库中检索内容。

最后,该示例包括对 ivy cleancache任务的调用。如果您大幅更改解析器设置,则需要这样做。它将确保常春藤不会重复使用缓存中的陈旧数据。

例子

构建.xml

<project name="demo" default="resolve" xmlns:ivy="antlib:org.apache.ivy.ant">

    <target name="resolve">
        <ivy:resolve/>
        <ivy:report todir="build/ivy" graph="false"/>
    </target>

    <target name="clean">
        <delete dir="build"/>
    </target>

    <target name="clean-all" depends="clean">
        <ivy:cleancache/>
    </target>

</project>

笔记:

  • 具有“清除所有”目标,将清除常春藤缓存
  • 常春藤报告任务对于生成依赖管理报告很有用。

常春藤设置.xml

<ivysettings>
    <settings defaultResolver="central"/>
    <resolvers>
        <ibiblio name="central" m2compatible="true"/>
        <ibiblio name="springsource-external" m2compatible="true" root="http://repository.springsource.com/maven/bundles/external"/>
    </resolvers>
    <modules>
        <module name="com.springsource.*" resolver="springsource-external"/>
    </modules>
</ivysettings>

笔记:

  • 默认为 Maven 中心。
  • 从其“外部”Maven 存储库中检索重新打包的 springsource 包
  • 与使用“链式”解析器相比,这种方法提供了更多的控制。

常春藤.xml

<ivy-module version="2.0">
    <info organisation="apache" module="hello-ivy"/>
    <dependencies>
        <dependency org="commons-lang" name="commons-lang" rev="2.0"/>
        <dependency org="commons-cli" name="commons-cli" rev="1.0"/>
        <dependency org="commons-net" name="commons-net" rev="3.1" />

        <dependency org="com.jcraft" name="jsch" rev="0.1.48"/><!-- used for SFTP-->
        <dependency org="log4j" name="log4j" rev="1.2.17"/>
        <dependency org="com.google.guava" name="guava" rev="14.0-rc2"/>
        <dependency org="joda-time" name="joda-time" rev="2.1"/>

        <dependency org="org.springframework" name="spring-aspects" rev="3.1.2.RELEASE"/>
        <dependency org="org.springframework" name="spring-aop" rev="3.1.2.RELEASE"/>
        <dependency org="org.springframework" name="spring-context" rev="3.1.2.RELEASE"/>
        <dependency org="org.springframework" name="spring-core" rev="3.1.2.RELEASE"/>
        <dependency org="org.springframework" name="spring-test" rev="3.1.2.RELEASE" />
        <dependency org="org.springframework" name="spring-beans" rev="3.1.2.RELEASE" />
        <dependency org="org.springframework" name="spring-jdbc" rev="3.1.2.RELEASE" />

        <dependency org="org.springframework" name="spring-tx" rev="3.1.2.RELEASE" />
        <dependency org="org.springframework" name="spring-asm" rev="3.1.2.RELEASE" />
        <dependency org="org.springframework" name="spring-expression" rev="3.1.2.RELEASE" />
        <dependency org="org.springframework" name="spring-context-support" rev="3.1.2.RELEASE" />

        <dependency org="org.springframework.batch" name="spring-batch-core" rev="2.1.9.RELEASE"/>
        <dependency org="org.springframework.batch" name="spring-batch-infrastructure" rev="2.1.9.RELEASE"/>

        <exclude module="com.springsource.org.joda.time"/>
    </dependencies>
</ivy-module>

笔记:

  • 有一个“排除”标签来阻止springsource重新打包的joda time模块的解析。
于 2013-02-09T13:49:55.277 回答