在android之前在gradle中运行任务

时间:2016-08-02 11:35:39

标签: android gradle

您好我希望创建将在android-defaultConfig之前运行的任务。 我的代码:

apply plugin: 'com.android.application'

task generateExternalData (){

    doFirst(){
        println 'generateExternalData-App'

        _versionName = 'MyApp'
        _versionCode = '1.0.1a'
        _buildRequest = 'B-00123'
    }
}

assembleRelease
        {
         dependsOn 'generateExternalData'
             doFirst(){
                println 'assembleRelease-App'
            }
        }


task writeReleaseNotes(dependsOn: 'assembleRelease') {

    doFirst() {
        println('writeReleaseNotes-App')
    }
}

task ACreleace(dependsOn: 'writeReleaseNotes') {

    doFirst() {
        println('ACreleace-App')
    }
}

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"
    lintOptions {
        abortOnError false
    }

    defaultConfig {

        println 'At defaultConfig-App'
        applicationId _applicationId
        minSdkVersion 15
        targetSdkVersion 23
        versionCode _versionCode
        versionName _versionName
        multiDexEnabled true
        resValue 'string', 'BUILD_NUMBER_RES', BuildNumber


    }
}

当我跑步时:

gradlew -q MyApp:ACrelease

我的输出:

At defaultConfig-App
generateExternalData-App
assembleRelease-App
writeReleaseNotes-App
ACreleace-App

我需要的是generateExternalData在defaultConfig之前运行,因此希望输出为:

generateExternalData-App
At defaultConfig-App
assembleRelease-App
writeReleaseNotes-App
ACreleace-App

0 个答案:

没有答案