• Gradle Goodness: Excluding Tasks for Execution


    In Gradle we can create dependencies between tasks. But we can also exclude certain tasks from those dependencies. We use the command-line option -x or --exclude-task and specify the name of task we don't want to execute. Any dependencies of this task are also excluded from execution. Unless another task depends on the same task and is executed. Let's see how this works with an example:

    00.task copySources << {
    01.println 'Copy sources.'
    02.}
    03. 
    04.task copyResources(dependsOn: copySources) << {
    05.println 'Copy resources.'
    06.}
    07. 
    08.task jar(dependsOn: [copySources, copyResources]) << {
    09.println 'Create JAR.'
    10.}
    11. 
    12.task deploy(dependsOn: [copySources, jar]) << {
    13.println 'Deploy it.'
    14.}

    We execute the deploy task:

    $ gradle -q deploy
    Copy sources.
    Copy resources.
    Create JAR.
    Deploy it.

    Now we exclude the jar task. Notice how the copySources task is still executed because of the dependency in the deploy task:

    $ gradle -q deploy -x jar
    Copy sources.
    Deploy it.
  • 相关阅读:
    Redis涉及的概念
    Redis高级教程
    Redis基础入门
    Java多线程面试题
    Java集合面试题
    Java集合基础
    Java基础面试题总结
    Zookeeper Basics
    GitLab基础入门
    阿里云ECS服务器Docker安装Tomcat过程记录
  • 原文地址:https://www.cnblogs.com/GoAhead/p/4189133.html
Copyright © 2020-2023  润新知