使用Gradle的“Artifact only notation”带有自定义工件名称 [英] Using Gradle's "Artifact only notation" with a custom artifact name
问题描述
我想使用神器只有符号下载文件名与模块名称完全不同的单个工件。我常春藤神器模式配置为:
ivy {
artifactPattern'http:// host / [organization] / [module] / [revision] / [artifact] - [revision]。[ext]'
}
然而,Artifact only notation似乎只支持:
$ b $ ul
group
(映射到 [organization]
), name
(映射到 [模块]
), 版本
(映射到 ext
(映射到) [map] )和
classifier
(映射到 [classifier]
,这里没有用到)。 [artifact]
部分网址似乎总是被替换为 name
。 有没有一种方法可以显式设置Gradle在URL中替换了 [artifact]
?在普通的Ivy XML中,我可以通过指定一个工件标签,并在依赖项
标签内设置名称
attibute。
我的问题与相关除了我没有服务器端 ivy.xml
文件,我不能使用这个技巧来滥用分类器 code>,因为我的工件名称不仅与模块名称的后缀不同。
原来,正确的语法来指定名称与模块名称不同的工件的依赖关系,作为这个例子。为了将上述URL中的 [artifact]
替换为 [module]
以外的其他内容,将依赖项声明为如下所示:
compile('group-or-org-name:module-name:module-version'){
$ artifact {
name ='artifact-name-different-from-module-name'
type ='type-must-not-null-null'
}
}
编辑:以下是该功能的官方文档, a href =http://www.gradle.org/docs/current/dsl/org.gradle.api.artifacts.dsl.DependencyHandler.html#N15F3A =nofollow noreferrer>高级依赖关系配置部分。
I'd like to use the Artifact only notation to download a single artifact whose filename is completely different from the module name. My Ivy artifact pattern is configured as:
ivy {
artifactPattern 'http://host/[organization]/[module]/[revision]/[artifact]-[revision].[ext]'
}
However, the "Artifact only notation" seem to only support:
group
(maps to[organization]
),name
(maps to[module]
),version
(maps to[revision]
),ext
(maps to[exp]
) andclassifier
(maps to[classifier]
, not used here).
The [artifact]
part of the URLs seems to always be replaced with name
.
Is there a way to explicitly set in Gradle what [artifact]
gets replaced with in the URL? In plain Ivy XML I'm able to achieve this by specifying an artifact tag with the name
attibute set inside the dependency
tag.
My question is somewhat related to this question except that I do not have a server-side ivy.xml
file and I cannot use the trick to misuse the classifier
because my artifact name does not just differ in a suffix from the module name.
Turns out that the correct syntax to specify a dependency on a artifact whose name is different from its module name is given as part of this example. In order to get [artifact]
in the URL above replaced with something else than [module]
, declare the dependency as follows:
compile ('group-or-org-name:module-name:module-version') {
artifact {
name = 'artifact-name-different-from-module-name'
type = 'type-must-not-be-null'
}
}
Edit: Here are the official docs for that feature as part of the Advanced dependency configuration section.
这篇关于使用Gradle的“Artifact only notation”带有自定义工件名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!