gradle构建后执行任务 [英] gradle execute task after build

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

问题描述

我正在使用gradle和以下build.gradle文件构建项目:

I am building my project with gradle, with the following build.gradle file:

project('a'){
    apply plugin: 'java'
    apply plugin: 'eclipse'
    apply plugin: 'application'

    buildDir = 'build'

    [compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
    repositories {
        mavenCentral()
    }
    dependencies {
        compile 'org.slf4j:slf4j-api:1.7.7'
    } 
}

何时我输入了 gradle build 命令,我希望gradle在构建后执行任务。

When I input the gradle build command, I want gradle to execute a task after the build.

我发现了 mustRunAfter 在互联网上,我尝试了多种方法,但都失败了。

I found a mustRunAfter on the Internet, and I have tried a variety of ways but failed.

请告诉我是否知道。

推荐答案

您需要的是 finalizedBy ,请参见以下脚本:

What you need is finalizedBy, see the following script:

apply plugin: 'java'

task finalize {
    doLast {
       println('finally!')
    }
}

build.finalizedBy(finalize)

此处是文档。

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

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