Gradle - 在子任务

时间:2017-08-02 15:22:37

标签: java gradle

我正在使用researchgate's gradle release plugin执行版本管理,并使用maven-publish插件将生成的工件上传到私有maven存储库。当我运行gradle-release-plugin的发布任务时,它运行以下子任务( user-dao-plugin 是我的虚拟项目名称) -

:user-dao-plugin:createScmAdapter
:user-dao-plugin:initScmAdapter
:user-dao-plugin:checkCommitNeeded
:user-dao-plugin:checkUpdateNeeded
:user-dao-plugin:unSnapshotVersion
:user-dao-plugin:confirmReleaseVersion
:user-dao-plugin:checkSnapshotDependencies
:user-dao-plugin:runBuildTasks
:user-dao-plugin:user-dao-plugin:beforeReleaseBuild UP-TO-DATE
:user-dao-plugin:user-dao-plugin:compileJava
:user-dao-plugin:user-dao-plugin:processResources
:user-dao-plugin:user-dao-plugin:classes
:user-dao-plugin:user-dao-plugin:findMainClass
:user-dao-plugin:user-dao-plugin:jar
:user-dao-plugin:user-dao-plugin:bootRepackage
:user-dao-plugin:user-dao-plugin:assemble
:user-dao-plugin:user-dao-plugin:compileTestJava
:user-dao-plugin:user-dao-plugin:processTestResources NO-SOURCE
:user-dao-plugin:user-dao-plugin:testClasses
:user-dao-plugin:user-dao-plugin:test
2017-08-02 20:48:47.430  INFO 27013 --- [       Thread-5] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@649f626d: startup date [Wed Aug 02 20:48:46 IST 2017]; root of context hierarchy
:user-dao-plugin:user-dao-plugin:check
:user-dao-plugin:user-dao-plugin:build
:user-dao-plugin:user-dao-plugin:afterReleaseBuild UP-TO-DATE
:user-dao-plugin:preTagCommit
:user-dao-plugin:createReleaseTag
:user-dao-plugin:updateVersion
:user-dao-plugin:commitNewVersion

我想在publish子任务之后立即运行maven-publish的check任务。我正在努力寻找办法。

我尝试设置任务依赖项,但我没有获得对check子任务的引用。

我怎样才能实现这个目标?

1 个答案:

答案 0 :(得分:3)

@Vampire无论顺序如何,您能告诉我如何在任何publish子任务之后运行release吗?

根据您的上一条评论,您所追求的是

release.finalizedBy publish

或者也许(您对子任务的使用令人困惑,因为在Gradle中没有任何称为子任务。)

subprojects { release.finalizedBy publish }

你可能还需要

publish.dependsOn build

subprojects { publish.dependsOn build }

如果没有build,那么publish始终在release eben之前运行。