Gradle:只检索多个发布的工件中的一个? [英] Gradle: retrieve only one of multiple published artifacts?

查看:159
本文介绍了Gradle:只检索多个发布的工件中的一个?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个拥有多个已发布构件的常青藤资源库,如下所示:

  /mygroup/mymodule/1.1。 1 / mymodule-1.1.1.jar 
/mygroup/mymodule/1.1.1/mymodule-client-1.1.1.jar
/mygroup/mymodule/1.1.1/ivy-1.1.1。 xml

如果我放入下面的gradle依赖关系行,它将检索两个jar。我只想检索mymodule-client.jar,但我无法弄清楚这个工作的咒语。这是我现在的路线。

  compile('mygroup:mymodule:1.1.11'){transitive = false} 

Gradle文档似乎表明有一种方法可以获得特定的工件,但是我可以' t获取正确的咒语。



以下是常青藤文件的内容。

 <?xml version =1.0为了简洁起见,只更改了模块/工件名称和一些标准依赖项。编码= UTF-8 >?; 


<出版物>
< artifact name =mymodule/>
< artifact name =mymodule-client/>
< / publications>

<依赖关系>
...
< /依赖关系>
< / ivy-module>


解决方案

在很多试用版中找到合适的行和错误:
$ b

  compile('mygroup:mymodule:1.1.1:client @ jar')

我认为它仅适用,因为client是模块名称的扩展名(显然称为分类器)。如果我有不同的命名,我不知道我是如何解决它的。

我找到了这样的例子:
http://scratchpad.pietschy.com/gradle/dependency_management.html


20.2。 2.2。只有工件符号只有工件符号才会创建仅下载一个工件文件的模块相关性。对于这样的依赖关系,
符号遵循以下模式:
[group]:[artifact]:[version] @ [extension]或
[group]:[artifact]:[version]: [分级] @ [延伸]。例如:

依赖关系{
compileorg.apache.ant:ant-junit:1.7.0@jar}



I've got an Ivy repository with multiple published artifacts, something like this:

/mygroup/mymodule/1.1.1/mymodule-1.1.1.jar
/mygroup/mymodule/1.1.1/mymodule-client-1.1.1.jar
/mygroup/mymodule/1.1.1/ivy-1.1.1.xml

If I put in the following gradle dependency line, it retrieves both jars. I want to only retrieve the mymodule-client.jar, but I can't figure out the incantation to make that work. Here's the line I have now. I've purposefully excluded transitive dependencies for other reasons.

compile ('mygroup:mymodule:1.1.11') {transitive=false}

Gradle docs seem to indicate there's a way to get just a specific artifact, but I can't get the incantation correct.

Here's the contents of the ivy file. Only the module/artifact names were changed and some standard dependency stuff removed for brevity.

<?xml version="1.0" encoding="UTF-8"?>
<ivy-module version="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd">

    <info organisation="mygroup" module="mymodule" revision="1.1.1" status="integration" publication="20120111091627"/>

    <publications>
        <artifact name="mymodule"/>
        <artifact name="mymodule-client"/>
    </publications>

    <dependencies> 
       ...          
    </dependencies>
</ivy-module>

解决方案

Managed to find the appropriate line after a lot of trial and error:

compile ('mygroup:mymodule:1.1.1:client@jar')

I think it only works because the "client" is an extension of the module name (called a classifier apparently). If I'd had something named differently, I'm not sure how I'd have resolved it.

I found the example that gave me the clue here: http://scratchpad.pietschy.com/gradle/dependency_management.html

20.2.2.2. Artifact only notation An artifact only notation creates a module dependency which only downloads one artifact file. The notation for such a dependency follows the pattern: [group]:[artifact]:[version]@[extension] or [group]:[artifact]:[version]:[classifier]@[extension]. For example:

dependencies { compile "org.apache.ant:ant-junit:1.7.0@jar" }

这篇关于Gradle:只检索多个发布的工件中的一个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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