gpt4 book ai didi

upload - 为什么 uploadArchives 会从其他配置上传 Artifact ?

转载 作者:行者123 更新时间:2023-12-02 09:38:07 24 4
gpt4 key购买 nike

我很困惑为什么 Gradle 的 uploadArchive 会从其他配置上传 Artifact 。我的理解是,当您声明配置时,它将为您获取上传任务,并且在调用时它将上传分配给其配置的 Artifact 。

这不是我看到的行为:

apply plugin: 'base'

configurations {
foo
}

task fooIt(type: Zip) {
from 'blah.txt'
baseName 'foo'
}

task barIt(type: Zip) {
from 'blah.txt'
baseName 'bar'
}

artifacts {
foo fooIt
}

repositories {
flatDir {
name 'local'
dirs 'repo'
}
}

uploadArchives {
repositories {
add project.repositories.local
}
}

uploadFoo {
repositories {
add project.repositories.local
}
}

在此示例中,没有为 archives 配置分配任何 Artifact ,但当我调用 gradle uploadArchives 时,它将上传 foo 的 Artifact 。

$ gradle -i uploadArchives
All projects evaluated.
Selected primary task 'uploadArchives' from project :
Tasks to be executed: [task ':fooIt', task ':uploadArchives']
:fooIt (Thread[Daemon Thread 17,5,main]) started.
:fooIt
Skipping task ':fooIt' as it is up-to-date (took 0.008 secs).
:fooIt UP-TO-DATE
:fooIt (Thread[Daemon Thread 17,5,main]) completed. Took 0.017 secs.
:uploadArchives (Thread[Daemon Thread 17,5,main]) started.
:uploadArchives
Executing task ':uploadArchives' (up-to-date check took 0.0 secs) due to:
Task has not declared any outputs.
Publishing configuration: configuration ':archives'
Publishing to Repository 'local'
Published :gradle:unspecified:foo.zip to file:/private/tmp/gradle/repo/foo-unspecified.zip
Published :gradle:unspecified:ivy.xml to file:/private/tmp/gradle/repo/ivy-unspecified.xml
:uploadArchives (Thread[Daemon Thread 17,5,main]) completed. Took 0.017 secs.

BUILD SUCCESSFUL

由此产生的两个问题:

  1. 为什么 fooIt 被执行?
  2. 为什么 uploadArchives 上传 foo 的 Artifact ?

谢谢

$ gradle --version
------------------------------------------------------------
Gradle 2.1
------------------------------------------------------------

Build time: 2014-09-08 10:40:39 UTC
Build number: none
Revision: e6cf70745ac11fa943e19294d19a2c527a669a53

Groovy: 2.3.6
Ant: Apache Ant(TM) version 1.9.3 compiled on December 23 2013
JVM: 1.7.0_45 (Oracle Corporation 24.45-b08)
OS: Mac OS X 10.10.2 x86_64

最佳答案

archives配置包含所有配置的所有 Artifact 。我相信这种困惑来自于这样一个事实:您还可以将 Artifact 直接添加到 archives 中。如果你想要配置。既然如此,uploadArchives任务将始终上传所有声明的 Artifact 。如果您想上传 Artifact 的子集,那么您应该调用 upload<<ConfigurationName>>任务。

关于upload - 为什么 uploadArchives 会从其他配置上传 Artifact ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28369326/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com