spring - 我应该如何知道 Ivy 依赖项中有哪些可用配置?

标签 spring maven ant ivy

我如何知道哪些配置可用于特定依赖项?

我了解这些是常见配置:默认、主、编译、提供、测试、系统、源、javadoc、可选、运行时

但某些依赖项并未定义所有这些,而其他依赖项则定义了其他自定义配置。我在 springsource 或 maven repo 上没有看到任何可用配置的提及。

下面是我令人尴尬地破解的 ivy.xml。请注意,我将 org.springframework.spring-library conf 定义为“运行时”。这会失败,因为 org.springframework.spring-library 没有“运行时”conf。

<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.myapp" module="MyAppName" revision="1.0"/>
    <configurations>
        <conf name="compile" visibility="public" description="Dependencies needed for compile"/>
        <conf name="runtime" visibility="public" extends="compile" description="Dependencies needed for runtime"/>
        <conf name="test" visibility="private" description="Test dependencies"/>
    </configurations>
    <dependencies>
        <dependency org="org.springframework" name="org.springframework.spring-library" rev="3.1.0.RELEASE" conf="runtime"/>
        <dependency org="org.springframework.security" name="spring-security-web" rev="3.1.0.RELEASE" transitive="false" conf="*"/>
        <dependency org="org.springframework.security" name="spring-security-config" rev="3.1.0.RELEASE" transitive="false" conf="*"/>
        <dependency org="org.springframework.security" name="spring-security-core" rev="3.1.0.RELEASE" transitive="false" conf="*"/>
        <dependency org="org.codehaus.jackson" name="com.springsource.org.codehaus.jackson" rev="1.4.3" conf="runtime->*"/>
        <dependency org="org.codehaus.jackson" name="com.springsource.org.codehaus.jackson.mapper" rev="1.4.3" conf="runtime->*"/>
        <dependency org="org.apache.httpcomponents" name="com.springsource.org.apache.httpcomponents.httpclient" rev="4.1.1" conf="runtime->*" />
        <dependency org="org.aspectj" name="org.aspectj-library" rev="1.6.5.RELEASE" conf="runtime,compile->runtime(default)"/>
        <dependency org="net.sourceforge.cglib" name="com.springsource.net.sf.cglib" rev="2.2.0" conf="compile->*"/>
        <dependency org="log4j" name="log4j" rev="1.2.14" conf="runtime->*"/>
        <dependency org="joda-time" name="joda-time" rev="2.0" conf="runtime,compile->runtime(default)"/>
        <exclude type="license" ext="txt"/>
        <exclude type="notice" ext="txt"/>
        <exclude org="javax.servlet" conf="runtime"/>
        <exclude org="javax.el" conf="runtime"/>
        <exclude org="javax.faces" conf="runtime"/>
        <exclude org="javax.portlet" conf="runtime"/>
        <exclude org="javax.xml.rpc" conf="runtime"/>
        <exclude org="javax.xml.soap" conf="runtime"/>
        <exclude org="javax.xml.ws" conf="runtime"/>
        <exclude org="commons-logging" conf="runtime"/>
    </dependencies>
</ivy-module>    

最佳答案

org.springframework.spring-library 似乎有一个 runtime 配置。具体 spring-library 的配置是:

<configurations>
    <conf name="compile" visibility="public" extends="aspects" description="Maven compile dependencies"/>
    <conf name="optional" visibility="public" extends="compile" description="Maven optional dependencies"/>
    <conf name="provided" visibility="public" description="Maven provided dependencies"/>
    <conf name="dm-server-provided" visibility="public" description="Maven provided dependencies that already exist in the platform"/>
    <conf name="runtime" visibility="public" extends="compile" description="Runtime dependencies"/>
    <conf name="test" visibility="private" description="Test dependencies"/>
    <conf name="aspects" visibility="private" description="Aspects to be woven"/>
    <conf name="external" visibility="private" description="External candidates to be woven"/>
    <conf name="additional" visibility="private" description="Additional candidates to be included in the PAR"/>
</configurations>

为了获取此列表,我添加了以下依赖项并执行了解析(注意:未指定 conf)

<dependency org="org.springframework" name="org.springframework.spring-library" rev="3.1.0.RELEASE"/>

然后我查看了缓存中 org.springframework.spring-library 的 ivy 文件(通常位于 ${user.home}/.ivy2/cache/org .springframework/org.springframework.spring-library/ivy-3.1.0.RELEASE.xml)。

可能有一种更简单的方法来获取配置列表,但上面的方法对我来说很有效。

由于SpringSource EBR提供了ivy文件,您可以直接从 http://repository.springsource.com/ivy/libraries/release/org.springframework/org.springframework.spring-library/3.1.0.RELEASE/ivy-3.1.0.RELEASE.xml ,但 IMO 找出正确的 url 比上面使用的技术更费力。

关于spring - 我应该如何知道 Ivy 依赖项中有哪些可用配置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9102292/

相关文章:

java - 处理队列的NoSuchMethodException

java - JSP 和 Java - 使用 jslt forEach 在 JSP 中显示数据 - 如何访问较低的元素

java - 使用 Jetty 运行多模块 Maven Web 应用程序,HTTP 错误 : 503 SERVICE_UNAVAILABLE

linux - 无法运行 ' Ant exec executable="zip"'

java - 运行 Ant 脚本时出现代理问题

java - Hibernate 逆向工程从数据库表生成带注释的 POJO 类

spring - 注销会在浏览器上留下 JSESSIONID。如何清除它?

maven - eclipse maven项目中的 Sonar 插件错误

Java OSGI。 Maven vs Eclipse+Ant - 最佳实践

java - 为什么我们需要@Lookup,scope=prototype 有什么问题吗?