Using Gradle's “Artifact only notation” with a custom artifact name

纵饮孤独 提交于 2019-12-06 05:50:18

问题


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]) and
  • classifier (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.


回答1:


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.



来源:https://stackoverflow.com/questions/24908203/using-gradles-artifact-only-notation-with-a-custom-artifact-name

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!