简体   繁体   English

常春藤依赖conf映射通配符

[英]Ivy dependency conf map wildcard

In an ivy dependency, 在常春藤依赖中,

Q1. Q1。 What is the difference between 有什么区别

conf="runtime->compile" CONF = “runtime->编译”

vs VS

conf="runtime->compile(*)" CONF = “runtime->编译(*)”

What does the extra bracketed wildcard do? 额外的括号内的通配符有什么作用?

Q2. Q2。

What does the following do? 以下是做什么的?

conf="compile->compile(*)" CONF = “编译期>编译(*)”

Isn't it a cyclical/self dependency? 这不是周期性/自我依赖吗? What is the point of mapping a conf back to itself? 将conf映射回自身有什么意义?

The brackets are a fallback : 括号是后备

since 1.3 a fallback mechanism can be used when you are not sure that the dependency will have the required conf. 从1.3开始,当您不确定依赖项是否具有所需的conf时,可以使用回退机制。 You can indicate to ivy that you want one configuration, but if it isn't present, use another one. 您可以向常春藤指出您想要一个配置,但如果它不存在,请使用另一个配置。 The syntax for specifying this adds the fallback conf between parenthesis right after the required conf. 指定此语法的语法会在所需的conf之后添加后缀括号。 For instance, 例如,

test->runtime(default)
means that in the test configuration of the module the 意味着在模块的test配置中
runtime
conf of the dependency is required, but if doesn't exist, it will use the 需要conf的conf,但如果不存在,它将使用
default
conf instead. 相反。 If default conf doesn't exist then it will be considered as an error. 如果默认conf不存在,那么它将被视为错误。 Note that the * wildcard can be used as fallback conf. 请注意,*通配符可用作后备conf。

For Question2: a conf is always read like: 问题2:conf总是如下:

ConfFromThisFile -> ConfFromDependency

So 所以

compile->compile

will map the compile configuration of the dependency to the compile configuration of this file. 会在地图compile依赖的配置在compile这个文件的配置。 It is no cycle. 这不是循环。 The bracket says: If compile does not exist in the dependency then use * . 括号说:如果依赖项中不存在compile ,则使用*

See the Configuration Mapping Section of the ivy documentation for dependencies . 有关依赖项,请参阅常春藤文档的配置映射部分。

This syntax is for dependency fallback. 此语法用于依赖性回退。 runtime->compile means that the runtime configuration depends on the compile config. runtime->compile意味着运行时配置依赖于编译配置。 The compile config must be present or Ivy will report an error. 编译配置必须存在或Ivy将报告错误。 However, runtime->compile(*) will try the compile configuration first to satisfy dependencies. 但是, runtime->compile(*)将首先尝试编译配置以满足依赖性。 But if compile doesn't exist, it will try all the other configurations. 但是如果编译不存在,它将尝试所有其他配置。 See the Configurations mapping section of the Ivy docs for more info. 有关详细信息,请参阅常春藤文档的配置映射部分。

Based on that, compile->compile(*) would indicate that compile needs any (all?) configurations. 基于此, compile->compile(*)将指示编译需要任何(所有?)配置。 I am guessing that compile->(*) isn't valid syntax so the extra compile guarantees the fallback is used since compile isn't defined until after the configuration XML stanza is complete. 我猜测compile->(*)是无效的语法,因此额外的compile保证使用回退,因为直到配置XML节完成之后才定义compile

Note that it's not clear from the documentation if (*) means 'any' or 'all' configurations. 请注意,文档中不清楚if (*)表示“任何”或“所有”配置。 So, I am not sure if Ivy will stop at the first configuration that matches all dependencies (if there is one) or if it brings in all the other configurations in a union. 所以,我不确定Ivy是否会停止匹配所有依赖项的第一个配置(如果有的话),或者它是否会引入union中的所有其他配置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM