有人可以解释的ivy.xml依赖的conf属性? [英] Can someone explain the ivy.xml dependency's conf attribute?

查看:1467
本文介绍了有人可以解释的ivy.xml依赖的conf属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找不到任何详尽的解释常春藤依赖标签的的的conf 的属性:

 <依赖有机=休眠NAME =休眠转=3.1.3的conf =运行时,独立 - >运行时(*)/>

请参阅的conf 的属性?我找不到任何解释(即我可以理解)有关的右手边 - > 符号。请记住,我不知道关于Maven的第一件事情,所以请解释与考虑这个属性。

是的,我已经看了这样的:<一href=\"http://ant.apache.org/ivy/history/latest-milestone/ivyfile/dependency.html\">http://ant.apache.org/ivy/history/latest-milestone/ivyfile/dependency.html

谢谢,结果


解决方案

首先,常春藤没有Maven的;)结果
Maven2的是一个软件项目管理和COM prehension工具,而常春藤只是一个依赖管理工具。

常春藤在很大程度上依赖于一种称为独特的概念的配置。结果
在常春藤,一个模块配置是一个的方式来使用或查看模块。结果
例如,你可以有你的模块在测试和运行时配置。但你也可以有一个MySQL和Oracle配置。或休眠和JDBC配置。

在每个配置中,可以声明:


  • 什么工件(JAR,WAR,...)是必需的。

  • 您对其他模块的依赖关系,并说明你需要依赖哪些配置。这就是所谓的配置映射

于是的conf 属性确实precisely说:描述了一个相关性的配置映射。结果
href=\"http://ant.apache.org/ivy/history/latest-milestone/ivyfile/mapped.html\">映射子元素的 - &GT; 符号,并重新presents映射的依赖配置的名称。 '*'通配符可用于指定该模块的所有配置。


Maven2的在其一侧有一种叫做范围。结果
你可以声明一个依赖作为是测试范围,或构建时范围的一部分。结果
然后,根据这个范围,你会得到的依赖神器(每个模块只有一个工件在Maven2的)与根据其范围的依赖。作用域是Maven2的pdefined $ P $,你不能改变这一点。

这意味着:


  

有一个的很多的下载了许多图书馆不必要的依赖。结果
  例如,Hibernate的下载了一堆JBoss的JAR和显示标签下载所有的各种Web框架JAR的。我发现自己几乎排除尽可能多的依赖关系我补充道。


问题是,Hibernate可以与几个缓存实现,有几个连接池的实现,...可以使用这不能与范围进行管理,哪来的Ivy配置提供了一个优雅的解决这种问题。结果
例如,在常春藤,假设休眠有像这样的ivy文件,然后你可以声明这样的依赖关系:

 &LT;依赖有机=休眠NAME =休眠转=2.1.8的conf =默认 - &GT;的proxool,OSCache的/&GT;

要得到其的proxool和OSCache的实现冬眠,这样的:

 &LT;依赖有机=休眠NAME =休眠转=2.1.8的conf =默认 - &GT;二溴氯丙烷,swarmcache/&GT;

要获得与DBCP和swarmcache冬眠。

通过映射默认配置 Proxool的,OSCache的 DBCP,swarmcache ,可以指定你需要什么的究竟的从模块休眠。


您可以通过列出每个模块联想到库中定义的常春藤配置发现那些Proxool的,......的论点。例如:

 &LT;常春藤模块版本=2.0&GT;
&LT;信息组织=SSN-SRC模块=PC/&GT;
&LT;配置defaultconfmapping =默认 - &GT;默认&GT;
    &LT;的conf NAME =默认/&GT;
    &LT;的conf NAME =提供的说明=他们是由ENV提供的。 /&GT;
    &LT;的conf NAME =编译扩展=默认情况下,提供/&GT;
    &LT;的conf NAME =战争扩展=默认/&GT;
&LT; /配置&GT;
&LT;依赖和GT;

<一个href=\"http://mail-archives.apache.org/mod_mbox/ant-ivy-user/200812.mbox/%3C7916a6a60812030821u6f831ad2ub0921b2bfac8ec63@mail.gmail.com%3E\">Example:


  

让我们假设 MODA 有两种配置,默认和测试。结果
  作为一个实际问题,这将是极不寻常的想离开了 conf下dependency元素的属性。结果
  在的ivy.xml MODA 可能有依赖性:


 &LT;依赖有机=theteamNAME =商业方法REV =1.0的conf =默认 - &GT; */&GT;


  

您是从默认开始,而不是从默认和测试。


  
  

上面的例子,使MODA的默认依赖于商业方法的CONF1,CONF2和conf3。结果
  或者你可能想说,MO​​DA的默认情况下只依赖于商业方法的CONF1:


 &LT;依赖有机=theteamNAME =商业方法REV =1.0的conf =默认 - &GT; * * CONF1/&GT;

I can't find any thorough explanation of the Ivy dependency tag's conf attribute:

<dependency org="hibernate" name="hibernate" rev="3.1.3" conf="runtime, standalone -> runtime(*)"/>

See that conf attribute? I can't find any explanation (that I can understand) about the right hand side of the -> symbol. PLEASE keep in mind I don't know the first thing about Maven so please explain this attribute with that consideration.

Yes, I've already looked at this: http://ant.apache.org/ivy/history/latest-milestone/ivyfile/dependency.html

Thanks,
Dan

解决方案

First of all, Ivy is not Maven ;)
Maven2 is a software project management and comprehension tool, whereas Ivy is only a dependency management tool.

Ivy heavily relies on a unique concept called configuration.
In ivy, a module configuration is a way to use or to see the module.
For instance, you can have a test and runtime configuration in your module. But you can also have a mysql and an oracle configuration. Or an hibernate and a jdbc configuration.

In each configuration you can declare:

  • what artifacts (jar, war, ...) are required.
  • your dependencies on other modules, and describe which configuration of the dependency you need. This is called configuration mapping.

So the conf attribute does precisely that: Describes a configuration mapping for a dependency.
The mapped child element is your "right hand side of the -> symbol" and represents the name of the dependency configuration mapped. '*' wildcard can be used to designate all configurations of this module.


Maven2 on its side has something called the scope.
You can declare a dependency as being part of the test scope, or the buildtime scope.
Then depending on this scope you will get the dependency artifact (only one artifact per module in maven2) with its dependencies depending on their scope. Scopes are predefined in maven2 and you can't change that.

That means :

There are a lot of unnecessary dependencies downloaded for many libraries.
For example, Hibernate downloads a bunch of JBoss JARs and the Display Tag downloads all the various web framework JARs. I found myself excluding almost as many dependencies as I added.

The problem is that hibernate can be used with several cache implementations, several connection pool implementation, ... And this can't be managed with scopes, wheres Ivy configurations offers an elegant solution to this kind of problem.
For instance, in ivy, assuming hibernate has an ivy file like this one, then you can declare a dependency like that:

<dependency org="hibernate" name="hibernate" rev="2.1.8" conf="default->proxool,oscache"/>

to get hibernate with its proxool and oscache implementations, and like that:

<dependency org="hibernate" name="hibernate" rev="2.1.8" conf="default->dbcp,swarmcache"/>

to get hibernate with dbcp and swarmcache.

By mapping your default master configuration to "proxool,oscache" or to "dbcp,swarmcache", you specify what you need exactly from the module "hibernate".


You can find those "proxool,..." arguments by listing the ivy configuration defined for each modules associate with the library. For instance:

<ivy-module version="2.0">
<info organisation="ssn-src" module="pc"/>
<configurations defaultconfmapping="default->default">
    <conf name="default" />
    <conf name="provided" description="they are provided by the env." />
    <conf name="compile" extends="default,provided" />
    <conf name="war" extends="default"/>
</configurations>
<dependencies>

Example:

let's suppose modA has two configurations, default and test.
As a practical matter, it's going to be highly unusual to want to leave out the conf attribute of the dependency element.
The ivy.xml for modA might have a dependency:

<dependency org="theteam" name="modB" rev="1.0" conf="default->*" />

You're starting from default, rather than from both default and test.

The above example makes modA's default depend on modB's conf1, conf2, and conf3.
Or you might want to say that modA's default only depends on modB's conf1:

<dependency org="theteam" name="modB" rev="1.0" conf="default->*conf1*" />

这篇关于有人可以解释的ivy.xml依赖的conf属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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