gradle execute task after build

非 Y 不嫁゛ 提交于 2019-12-20 10:22:36

问题


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'
    } 
}

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

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

Please tell me if you know how.


回答1:


What you need is finalizedBy, see the following script:

apply plugin: 'java'

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

build.finalizedBy(finalize)

Here are the docs.



来源:https://stackoverflow.com/questions/30857350/gradle-execute-task-after-build

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!