简体   繁体   中英

Gradle - Run Existing Task Before Sub Task

I'm using researchgate's gradle release plugin to perform version management and maven-publish plugin to upload generated artifact to a private maven repository. When I run gradle-release-plugin's release task it runs following sub-tasks ( user-dao-plugin is my dummy project's name) -

: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

I want to run maven-publish's publish task right after check sub-task. I'm struggling on finding a way to do this.

I tried setting task dependencies but I'm not getting a reference to the check sub-task.

How can I go about achieving this?

@Vampire irrespective of the order, can you tell how to run publish after any release sub task?

Based on your last comment, what you are after is

release.finalizedBy publish

Or maybe (your usage of sub task is confusing, because there is nothing called sub task in Gradle.)

subprojects { release.finalizedBy publish }

And you might also need

publish.dependsOn build

or

subprojects { publish.dependsOn build }

so that build is run always before publish eben if you it without release .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM