gradle publish 不拾取工件:“尽管执行了操作,但任务尚未声明任何输出。”
Posted
技术标签:
【中文标题】gradle publish 不拾取工件:“尽管执行了操作,但任务尚未声明任何输出。”【英文标题】:gradle publish does not pick up artifacts: "Task has not declared any outputs despite executing actions." 【发布时间】:2019-04-05 12:15:29 【问题描述】:我正在将一个 java 项目从 gradle 2.x 迁移到 5.3.1。
最后一个问题是没有人工制品(在我们的例子中是 tar)被发布到人工制品。
main build.gradle
中的配置是
subprojects
apply plugin: "com.jfrog.artifactory"
project.ext
artifactoryConfig = new File(project.gradle.gradleUserHomeDir, "artifactory.gradle")
if (artifactoryConfig.exists())
apply plugin: 'maven'
apply from: artifactoryConfig
sourceCompatibility = 1.8
repositories
mavenCentral()
maven url $OUR_ARTIFACTORY
publishing
publications
mavenJava(MavenPublication)
from components.java
artifactory
publish
contextUrl = "$artifactoryBaseUrl"
repository
repoKey = "libs-release-local"
username = "$artifactoryUsername"
password = "$artifactoryPassword"
resolve
repoKey = 'repos'
在模块中
task('dist', type: Tar)
dependsOn('jar')
archiveName "$MODULE-$version.$extension"
...
publishing
publications
mavenJava(MavenPublication)
artifact dist
configurations.archives.artifacts.clear()
artifacts
archives dist
现在,当我执行 ./gradlew --info :$MODULE:artifactoryPublish
时,它会抱怨缺少输出并且不会将 tar 发布到工件。
如何解决这个问题?
> Task :$MODULE:artifactoryPublish
Task ':$MODULE:artifactoryPublish' is not up-to-date because:
Task has not declared any outputs despite executing actions.
:$MODULE:artifactoryPublish (Thread[Execution worker for ':',5,main]) completed. Took 0.002 secs.
:artifactoryDeploy (Thread[Execution worker for ':',5,main]) started.
> Task :artifactoryDeploy
Task ':artifactoryDeploy' is not up-to-date because:
Task has not declared any outputs despite executing actions.
Deploying build descriptor to: $OUR_ARTIFACTORY/artifactory/api/build
Build successfully deployed. Browse it in Artifactory under $OUR_ARTIFACTORY/artifactory/webapp/builds/$MODULE/1554465369336
:artifactoryDeploy (Thread[Execution worker for ':',5,main]) completed. Took 0.155 secs.
【问题讨论】:
关于“它抱怨缺少输出”:这对我本身来说并不可疑,因为所讨论的任务没有任何基于文件的输出。 Artifactory 上实际部署了什么?我问是因为它说:“构建成功部署。” @Chriki 没有将任何内容部署到工件(构建为空)。这就是问题所在。 运气好吗? @Abhimaan 是的;查看接受的答案。 【参考方案1】:对我来说,问题是 url 和凭据为空。它导致了相同的错误消息(任务未声明任何输出)。
artifactory
contextUrl = artifactoryUrl
publish
repository
username = artifactoryPublishUser
password = artifactoryPublishPassword
【讨论】:
【参考方案2】:最有价值的提示是运行示例
https://github.com/jfrog/project-examples/tree/master/gradle-examples/gradle-android-example
【讨论】:
【参考方案3】:原来解决方案是添加
artifactoryPublish
publications('mavenJava')
【讨论】:
以上是关于gradle publish 不拾取工件:“尽管执行了操作,但任务尚未声明任何输出。”的主要内容,如果未能解决你的问题,请参考以下文章
Gradle maven-publish 不构建独立的 spring-boot 应用程序