当我在ivy.xml中使用Red5(或任何项目)的依赖项时,我想只检索库jar。无论我如何配置它,我仍然会得到依赖项的"源"jar。我已经搜索了文档和谷歌,但还没有找到一个使用Ivy 2.2.0的解决方案。
我的ivy.xml中的这组节点似乎对大多数库工作得最好,但是Spring忽略了它们。
<exclude ext="txt" />
<exclude type="src" />
<exclude artifact="!sources" />
如果有人有任何可行的建议,让我们听听!!
指向xml源文件的链接
http://red5.googlecode.com/svn/java/server/trunk/ivy.xml http://red5.googlecode.com/svn/java/server/trunk/ivysettings.xml http://red5.googlecode.com/svn/java/server/trunk/build.xml注意
不要说这是重复的,他们的回答不起作用:
ivy:阻止下载源文件和。txt文件
让ivy不下载源代码和license文件
更新1
<dependency org="org.springframework" name="org.springframework.core" rev="3.0.5.RELEASE" transitive="false" />
在我的lib目录中生成以下两个文件:
org.springframework.core-3.0.5.RELEASE.jar
org.springframework.core-sources-3.0.5.RELEASE.jar
更新2 为了赏金,我希望你的解决方案能与Red5主干一起工作,Red5主干作为开源对每个人都可用。源文件罐对我来说只是一个烦恼,非常值得赏金点。
我在build.xml中使用这个只检索jar
<ivy:retrieve type="jar"/>
我修改了你的ivy.xml和ivysettings.xml文件。
为了抑制源文件,我使用了默认配置映射,以避免需要为每个依赖项添加"conf"属性。
<configurations defaultconfmapping="default">
..
..
Spring现在通过Maven中心发布他们的软件,所以我修改了ivy设置文件,使用这些来代替旧的ivy bundle存储库。
修订中
<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="red5" module="server" />
<configurations defaultconfmapping="default">
<conf name="default"/>
<conf name="java6" extends="default" description="Java 6 dependencies"/>
<conf name="eclipse" description="Special dependencies in Eclipse"/>
<conf name="utest" extends="eclipse" description="Unit testing dependencies"/>
</configurations>
<dependencies>
<dependency org="javax" name="javaee-api" rev="5.1.2" />
<!-- Spring -->
<dependency org="org.springframework" name="spring-asm" rev="3.0.5.RELEASE"/>
<dependency org="org.springframework" name="spring-beans" rev="3.0.5.RELEASE" />
<dependency org="org.springframework" name="spring-context" rev="3.0.5.RELEASE" />
<dependency org="org.springframework" name="spring-core" rev="3.0.5.RELEASE" />
<dependency org="org.springframework" name="spring-expression" rev="3.0.5.RELEASE" />
<dependency org="org.springframework" name="spring-web" rev="3.0.5.RELEASE" />
<!-- Logging -->
<dependency org="org.slf4j" name="com.springsource.slf4j.api" rev="1.6.1" transitive="false" />
<dependency org="org.slf4j" name="com.springsource.slf4j.bridge" rev="1.6.1" transitive="false" />
<dependency name="jul-to-slf4j" rev="1.6.1" />
<dependency name="log4j-over-slf4j" rev="1.6.1" />
<dependency name="jcl-over-slf4j" rev="1.6.1" />
<dependency name="logback-classic" rev="0.9.28" />
<dependency name="logback-core" rev="0.9.28" />
<!-- General -->
<dependency org="commons" name="commons-beanutils" rev="1.8.2" />
<dependency org="org.apache.commons" name="com.springsource.org.apache.commons.codec" rev="1.4.0" transitive="false" />
<dependency org="org.apache.commons" name="com.springsource.org.apache.commons.collections" rev="3.2.1" transitive="false" />
<dependency org="commons" name="httpcore" rev="4.1.3" />
<dependency org="commons" name="httpclient" rev="4.1.2" />
<dependency org="commons" name="commons-lang3" rev="3.0-beta" />
<dependency org="org.apache.commons" name="com.springsource.org.apache.commons.modeler" rev="2.0.1" transitive="false" />
<dependency org="commons" name="commons-pool" rev="1.5.6" />
<dependency name="quartz" rev="1.8.5" />
<dependency name="ehcache" rev="2.2.0" />
<!-- XML -->
<dependency org="org.apache.xerces" name="com.springsource.org.apache.xerces" rev="2.9.1" transitive="false" />
<dependency name="xmlrpc" rev="2.0.1" />
<!-- Mina -->
<dependency org="mina" name="mina-integration-beans" rev="2.0.4" />
<dependency org="mina" name="mina-integration-jmx" rev="2.0.4" />
<dependency org="mina" name="mina-core" rev="2.0.4" />
<!-- Scripting -->
<dependency org="org.objectweb.asm" name="com.springsource.org.objectweb.asm" rev="3.2.0" transitive="false" />
<dependency org="org.objectweb.asm" name="com.springsource.org.objectweb.asm.commons" rev="3.2.0" transitive="false" />
<dependency org="org.antlr" name="com.springsource.org.antlr" rev="3.1.3" transitive="false" />
<dependency org="org.codehaus.groovy" name="com.springsource.org.codehaus.groovy" rev="1.7.0" transitive="false" />
<dependency name="jruby-complete" rev="1.1.6" />
<dependency name="jython" rev="2.5" />
<dependency org="org.mozilla.javascript" name="com.springsource.org.mozilla.javascript" rev="1.7.0.R2" transitive="false" />
<dependency org="javax.xml.stream" name="com.springsource.javax.xml.stream" rev="1.0.1" transitive="false" />
<dependency org="org.springframework" name="spring-context-support" rev="3.0.5.RELEASE" />
<!-- Crypto -->
<dependency name="bcprov-jdk16" rev="145" conf="java6->*" />
<!-- MP3 -->
<dependency name="jaudiotagger" rev="2.0.4-SNAPSHOT" />
<!-- Testing support -->
<!-- until Eclipse updates their junit version, we have to use this -->
<dependency org="org.junit" name="com.springsource.org.junit" rev="4.8.1" conf="eclipse->*" transitive="false" />
<dependency name="GroboUtils" rev="5-core" conf="eclipse->*" />
<dependency org="org.springframework" name="org.springframework.test" rev="3.0.5.RELEASE" conf="eclipse->*" transitive="false" />
<dependency org="org.springframework" name="org.springframework.transaction" rev="3.0.5.RELEASE" conf="eclipse->*" transitive="false" />
</dependencies>
</ivy-module>
修订ivysettings.xml
<ivysettings>
<settings defaultResolver="chain"/>
<resolvers>
<chain name="chain">
<ibiblio name='central' m2compatible='true'/>
<ibiblio name='springsource-external' m2compatible='true' root='http://repository.springsource.com/maven/bundles/external'/>
<url name="googlecode">
<artifact pattern="http://red5.googlecode.com/svn/repository/[artifact](-[revision]).[ext]" />
<artifact pattern="http://red5.googlecode.com/svn/repository/[organisation]/[artifact](-[revision]).[ext]" />
</url>
</chain>
</resolvers>
</ivysettings>
我建议不要在依赖声明中使用"transitive"属性,而是尝试使用配置来解决你的问题。
ivy中的配置在功能上与Maven中的作用域相同,但要灵活得多。
我通常在我的代码中至少声明以下3个配置
<configurations>
<conf name="compile" description="Compile time dependencies"/>
<conf name="runtime" description="Compile time dependencies" extends="compile"/>
<conf name="test" description="Compile time dependencies" extends="runtime"/>
</configurations>
对应于任何java项目所需的3组依赖项。
秘诀在于如何将依赖映射到配置。如果你只想要一个没有依赖关系的jar,那么像这样声明它:
<dependency org="org.springframework" name="org.springframework.core" rev="3.0.5.RELEASE" conf="compile->master"/>
本地编译配置映射到远程Maven模块的主作用域。Maven中的master作用域排除任何可传递的依赖项。
如果您想要工件包含它的传递依赖,那么按照下面的方式声明配置映射:
<dependency org="org.springframework" name="org.springframework.core" rev="3.0.5.RELEASE" conf="compile->default"/>
工作ivy.xml文件
这将下载一个jar。
<?xml version="1.0" encoding="UTF-8"?>
<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="red5" module="server" />
<configurations>
<conf name="default"/>
<conf name="java6" extends="default" description="Java 6 dependencies"/>
<conf name="utest" extends="eclipse" description="Unit testing dependencies"/>
<conf name="eclipse" description="Special dependencies in Eclipse"/>
</configurations>
<dependencies>
<dependency org="org.springframework" name="org.springframework.core" rev="3.0.5.RELEASE" conf="default->master"/>
</dependencies>
</ivy-module>
修改后的设置文件
我还建议使用ibiblio解析器,该解析器旨在理解Maven 1和Maven 2存储库格式:
<ivysettings>
<settings defaultResolver="local"/>
<resolvers>
<chain name="local">
<ibiblio name='springsource-releases' m2compatible='true' root='http://repository.springsource.com/maven/bundles/release'/>
..
..
</chain>
</resolvers>
</ivysettings>
注意,我使用的是Springsource Maven存储库,它更有可能是最新的。
您可以尝试这样做。它使用工件和匹配器,这对排除标记是有效的。但是不要把exclude放在依赖中(这似乎是错误的,请参阅我的评论):
<dependencies>
<dependency org="org.springframework" name="org.springframework.core" rev="3.0.5.RELEASE"">
</dependency>
<exclude org="org.springframework" name="org.springframework.core" artifact="*sources*" matcher="glob"/>
</dependencies>
在您的依赖项中,只需通过使用工件节点调用它们来指定您想要检索的单个工件。试试吧:
<dependency org="org.springframework" name="org.springframework.core" rev="3.0.5.RELEASE" transitive="false">
<artifact name="org.springframework.core" ext="jar" />
</dependency>