2012-02-01 108 views
3

我如何知道哪些配置可用于特定的依赖关系?我该如何知道常春藤依赖项中有哪些配置可用?

我明白这些都是常见的配置:默认情况下,主,编译,提供测试,系统,资源,javadoc的,可选的,运行时

但一些依赖性不具备所有这些定义,其他定义其他自定义配置。我没有看到关于springource或maven回购的可用配置的任何提及。

下面是我尴尬的黑客一起ivy.xml。请注意,我将org.springframework.spring-library conf定义为“runtime”。这会失败,因为org.springframework.spring-library没有“运行时”配置文件。

<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>  

回答

2

org.springframework.spring-library确实出现有runtime配置。特别是对于弹簧库中的配置是:

<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 specfied)

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

然后我看了一下我缓存中的org.springframework.spring-library的常青藤文件(通常在${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是上面所用技术的更多努力。

+1

那么人们是这样做的吗?这似乎很荒谬(在常春藤的部分)。如果知道哪些配置可用于依赖关系如此重要,那么为什么没有一种简单高效的方式来获取这些数据? – vopilif 2012-02-01 21:10:59

+0

可浏览的常春藤库更容易。例如[Ivy Roundup回购](http://ivyroundup.googlecode.com/svn/trunk/repo/modules.xml)使得它很容易得到这些信息。例如http://ivyroundup.googlecode.com/svn/trunk/repo/modules/org.apache.activemq/activeio/3.1.0/ivy.xml – 2012-02-01 22:33:03

+0

看起来像ivyroundup没有弹簧3.1.0。虽然我想配置可能是相同的,这正是我与常春藤的挫折感。 – vopilif 2012-02-01 23:24:22

相关问题