java 在常春藤检索中忽略源 jar
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7046198/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Ignore sources jar in Ivy retrieve
提问by Paul Gregtheitroade
I would like to retrieve ONLY the library jar when I make use of a dependency entry in my ivy.xml for Red5 (or any project for that matter). No matter how I have configured it, I still get "sources" jars for dependencies. I have scoured the docs and google and have yet to find a solution that works using Ivy 2.2.0.
当我在我的 ivy.xml 中为 Red5(或任何项目)使用依赖项时,我只想检索库 jar。无论我如何配置它,我仍然会获得依赖项的“源”jar。我已经搜索了文档和谷歌,但还没有找到可以使用 Ivy 2.2.0 的解决方案。
This set of nodes in my ivy.xml seems to work the best for most libraries, but Spring ignores them.
我的 ivy.xml 中的这组节点似乎最适合大多数库,但 Spring 忽略了它们。
<exclude ext="txt" />
<exclude type="src" />
<exclude artifact="!sources" />
If anyone has any tips that would work, lets hear them!!
如果有人有任何有用的提示,让我们听听他们!!
Links to the source xml files
指向源 xml 文件的链接
http://red5.googlecode.com/svn/java/server/trunk/ivy.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/ivysettings.xml
http://red5.googlecode.com/svn/java/server/trunk/build.xml
http://red5.googlecode.com/svn/java/server/trunk/build.xml
Note
笔记
Don't say this is a duplicate, their answers do NOT work:
不要说这是重复的,他们的答案不起作用:
ivy: prevent downloading sources and .txt files
make ivy not to download sources and license files
Update 1
更新 1
<dependency org="org.springframework" name="org.springframework.core" rev="3.0.5.RELEASE" transitive="false" />
Produces these two files in my lib directory:
在我的 lib 目录中生成这两个文件:
org.springframework.core-3.0.5.RELEASE.jar
org.springframework.core-sources-3.0.5.RELEASE.jar
Update 2For the bounty, I expect your solution to work with Red5 trunk which is available to everyone as open source. The sources jars are just a annoyance for me and well worth the bounty points.
更新 2作为赏金,我希望您的解决方案能够与 Red5 主干一起使用,该主干作为开源提供给所有人。来源罐子对我来说只是一个烦恼,非常值得赏金点。
采纳答案by Mark O'Connor
I revised your ivy.xmland ivysettings.xmlfiles.
我修改了你的ivy.xml和ivysettings.xml文件。
To suppress source files I used a default configuration mapping to avoid the need to add a "conf" attribute to each dependency.
为了抑制源文件,我使用了默认配置映射以避免需要向每个依赖项添加“conf”属性。
<configurations defaultconfmapping="default">
..
..
Spring now release their software via Maven central so I revised the ivy settings file to use these instead of the old ivy bundle repositories.
Spring 现在通过 Maven 中心发布他们的软件,所以我修改了 ivy 设置文件以使用这些而不是旧的 ivy 包存储库。
Revised ivy.xml
修改ivy.xml
<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>
Revised ivysettings.xml
修改了 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>
回答by natros
i'm using this in build.xml to only retrieve the jars
我在 build.xml 中使用它来只检索罐子
<ivy:retrieve type="jar"/>
回答by Mark O'Connor
I would advise to notuse the "transitive" attribute on the dependency declaration and instead attempt to solve your problem using configurations.
我建议不要在依赖项声明中使用“transitive”属性,而是尝试使用配置来解决您的问题。
Configurations in ivy are functionally the same as scopes in Maven, but far more flexible.
ivy 中的配置在功能上与 Maven 中的作用域相同,但更加灵活。
I normally declare at least the following 3 configurations in my code
我通常在我的代码中至少声明以下 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>
Corresponds to 3 groups of dependencies I'll need for any java project.
对应于任何 Java 项目所需的 3 组依赖项。
The secret is how you map you depdencies to your configurations. If you only want the jar without it's dependencies, then declare it as follows:
秘诀在于如何将依赖项映射到配置。如果您只想要没有依赖项的 jar,请按如下方式声明它:
<dependency org="org.springframework" name="org.springframework.core" rev="3.0.5.RELEASE" conf="compile->master"/>
The local compileconfiguration mapped to the masterscope of the remote Maven module. The masterscope in Maven excludes any transitive dependencies.
本地编译配置映射到远程 Maven 模块的主作用域。Maven 中的主作用域不包括任何传递依赖项。
If you want the artifact to include it's transitive dependencies then declare the configuration mapping as follows:
如果您希望工件包含其传递依赖项,请按如下方式声明配置映射:
<dependency org="org.springframework" name="org.springframework.core" rev="3.0.5.RELEASE" conf="compile->default"/>
Working ivy.xml file
工作ivy.xml文件
This will download a single jar.
这将下载一个 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>
Revised settings file
修改后的设置文件
I would also recommend using the ibiblioresolver, which is designed to understand the Maven 1 and Maven 2 repository formats:
我还建议使用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>
Note I'm using the Springsource Maven repository, which is more likely to be up-to-date. I don't know if they maintain the old ivy repositories properly or not anymore.
注意我使用的是 Springsource Maven 存储库,它更有可能是最新的。我不知道他们是否再正确地维护旧的常春藤存储库。
回答by oers
You could try something like this. It uses the artifact and matcher, which is valid for exclude-tags. But don't put the exclude inside the dependency (this seems to be buggy, see my comment):
你可以尝试这样的事情。它使用artifact 和 matcher,这对 exclude-tags 有效。但是不要将排除放在依赖项中(这似乎有问题,请参阅我的评论):
<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>
回答by Sam T.
Within your dependency, simply specify the individual artifacts that you'd like to retrieve by calling them out with an artifact node. Give this a try:
在您的依赖项中,只需通过使用工件节点调用它们来指定您想要检索的单个工件。试试这个:
<dependency org="org.springframework" name="org.springframework.core" rev="3.0.5.RELEASE" transitive="false">
<artifact name="org.springframework.core" ext="jar" />
</dependency>