常春藤:我如何删除传递依赖? [英] Ivy: how do I remove transitive dependencies?

查看:32
本文介绍了常春藤:我如何删除传递依赖?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Ivy 来管理我的项目的依赖项.

I'm using Ivy to manage the dependencies on my project.

到目前为止,我已经指定了对 Hibernate 和 servlet-api 的依赖.但是,hibernate jar 本身有很多并不是真正需要的依赖项,例如 jaasjacc.

So far, I've specified a dependency on Hibernate and servlet-api. However, the hibernate jar itself has a lot of dependencies that aren't really needed, such as jaas and jacc.

这成为一个阻碍,因为 jaas 和 jaac 是 Sun 库,因此它们的许可证禁止将它们放在 Maven 存储库中,因此 Ivy 在那里找不到它们.

This becomes a show-stopper because jaas and jaac are Sun libraries and therefore their licenses forbid to place them in the Maven repos, so Ivy can't find them there.

  • 如何让 Ivy 下载 Hibernate 而不是这两个?
  • 作为奖励,如果我真的需要这些并从 Sun 下载它们的 Jars,Ivy 会在我机器的哪个文件夹中查找它们?

推荐答案

如何让 Ivy 下载 Hibernate 而不是这两个?

Ivy 使用它所谓的配置"来做到这一点.代表 Hibernate 的 ivy.xml 需要提供不同的配置来代表 Hibernate 的不同用例.(显然有些使用 hibernate 确实需要 jaas 和 jacc,但显然您没有使用这种情况.)

Ivy does this using what it calls "configurations." Your ivy.xml that represents Hibernate will need to provide different configurations to represent different use-cases for hibernate. (There is obviously some use of hibernate that does require jaas and jacc, but apparently you don't make use of that case.)

这里是关于配置的文档.如果您想提供用于休眠的 ivy.xml,我可以提供有关构建配置的指示,这些配置将删除您想要删除的特定库.

Here is the documentation on configurations. If you want to provide the ivy.xml you are using for hibernate, I can provide pointers on building configurations that will remove the specific libraries you want removed.

如果我真的需要这些并从 Sun 下载它们的 Jars,Ivy 会在我机器的哪个文件夹中查找它们?

ivy 查找 ivy 文件和工件的目录"由您使用的解析器列表指定.解析器列表在 ivy 设置文件(通常命名为 ivysettings.xml)中指定.通常,这些不是本地目录,而是远程 URL.有;但是,本地文件解析器类型适用于此.

The "directories" that ivy looks in for ivy files and artifacts are specified by the list of resolvers you are using. The list of resolvers is specified in the ivy settings file (usually named ivysettings.xml.) Typically, these aren't local directories, but remote URLs. There is; however, a local-file resolver type that will work for this.

如果您这样做,您将需要提供常春藤文件和工件(jar),每个文件的文件名都与解析器模式相匹配.有关详细信息,请参阅文档.

If you do this, you will need to provide both ivy files and the artifacts (jars), each with file-names that match the resolvers patterns. Details on that are in the documentation.

以下是来自 ivy 设置文件的本地文件解析器示例:

Here is an example local-file resolver from an ivy settings file:

<filesystem name="myfiles" checkconsistency="false" checksums="" transactional="false">
   <ivy pattern="/data/repo/[organisation]/[module]-[revision].ivy.xml"/>
   <artifact pattern="/data/repo/[organisation]/[module]-[revision].[ext]"/>
</filesystem>

另请注意,您需要将常春藤任务指向正确的解析器.您可以使用 ant 任务上的 resolver 属性来执行此操作,或者使用 ivy 设置文件中 settings 元素上的 defaultResolver 属性.

Also note that you will need to point your ivy tasks to the correct resolver. You can do this with the resolver attribute on the ant tasks, or with the defaultResolver attribute on the settings element in the ivy settings file.

这里是关于解析器.

OP 为他的特定原始问题找到了一种耗时较少的解决方法.依赖标签的排除"子标签为他完成了这项工作:

The OP found a less-time intensive workaround for his specific original problem. The "exclude" child-tag of the dependency tag did the job for him:

<dependencies>  
   <dependency org="org.hibernate" name="hibernate-core" rev="3.3.1.GA" conf='..'> 
       <exclude name='jaas' /> 
       <exclude name='jacc' />
   </dependency>
</dependencies>

这篇关于常春藤:我如何删除传递依赖?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆