如何拆分Gradle任务执行 [英] How to split a gradle task execution

查看:75
本文介绍了如何拆分Gradle任务执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的gradle项目中,我有一个任务Task1,其中包含许多依赖项任务Task1Dep1,Task1Dep2,Task1Dep3 ... Task1DepN.有没有一种方法可以拆分我的Task1执行,以便在一个执行中拆分Task1Dep1,Task1Dep2,然后在第二个执行中运行Task1Dep3 ... Task2DepN.

In my gradle project I have a task Task1 with many dependency tasks Task1Dep1, Task1Dep2, Task1Dep3... Task1DepN. Is there a way to split my execution of Task1 such that Task1Dep1, Task1Dep2 in one execution and then run Task1Dep3 ... Task2DepN in a second execution.

我想这样做的原因是,如果可能的话,这将是我在此处发布的一个问题的解决方案:

The reason I want to do this is that if this is possible then it will be a solution to a problem I posted about here: How to read latest property in property file that is updated earlier in gradle execution.

推荐答案

我能够如下解决此问题.

I was able to solve this issue as follows.

我要运行的gradle任务是用于运行 Townsfolk gradle-release插件的发布任务.

The gradle task I wanted to run was the release task for running the Townsfolk gradle-release plugin.

通常这可以通过以下方式完成:

Normally this would be done as:

./gradlew release

由于各种问题,我在该插件中使用了svn支持,然后将其与Android一起使用,因此我不得不按如下方式拆分此插件的基本子任务:

Due to various issue sI ran into with the svn support in this plugin and using it with Android I had to split the underlying sub-tasks for this plugin as follows:

./gradlew -PusesSnapshot=true -PversionModified=true initScmPlugin checkCommitNeeded checkUpdateNeeded unSnapshotVersion  
./gradlew -PusesSnapshot=true -PversionModified=true initScmPlugin confirmReleaseVersion checkSnapshotDependencies build preTagCommit 
svn update
./gradlew -PusesSnapshot=true -PversionModified=true initScmPlugin createReleaseTag updateVersion commitNewVersion

我使用以下方法找到了基本任务:

I found the underlying tasks using:

./gradlew tasks --all

这篇关于如何拆分Gradle任务执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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