如何从命令行运行单个gradle任务 [英] How to run a single gradle task from command line

查看:415
本文介绍了如何从命令行运行单个gradle任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目中,我在build.gradle中有几个任务。我希望这些任务在运行时是独立的。即我需要从命令行运行一个任务。但命令gradle taskA将运行我不想要的taskA和taskB。如何防止正在运行的任务?



下面是我正在做的一个示例。

  task runsSQL {
描述'run sql queries'
apply插件:'java'
apply插件:'groovy'

print'运行SQL'}

任务runSchema {
apply plugin:'java'
apply plugin:'groovy'

print'Run Schema'}

这是我得到的输出。

解决方案您可以使用 -x 选项或 - exclude-task 开关排除来自任务图的任务。但提供可运行的示例是个好主意。


In my project I have several tasks in my build.gradle. I want those tasks to be independent while running. ie I need to run a single task from command line. But the command "gradle taskA" will run both taskA and taskB which I do not want. How to prevent a task being running?.

Here's a sample of what I am doing.

   task runsSQL{
    description 'run sql queries'
    apply plugin: 'java'
    apply plugin: 'groovy'

    print 'Run SQL'  }

task runSchema{
    apply plugin: 'java'
    apply plugin: 'groovy'

    print 'Run Schema' }

Here's the output I'm getting.

解决方案

You can use -x option or --exclude-task switch to exclude task from task graph. But it's good idea to provide runnable example.

这篇关于如何从命令行运行单个gradle任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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