Android Gradle在Android build / run / debug上执行任务依赖

时间:2015-06-29 09:09:15

标签: android android-studio android-gradle

我有一个Android库模块。我已将两个任务包含在它的.gradle中,如下所示:

task createSDK(type: Zip) {
    dependsOn assemble

    def jarFile = file('build/intermediates/bundles/release/classes.jar')
    def outputDir = file("build/libs")
    archiveName = "mylib.jar"
    destinationDir = outputDir
    from {
        configurations.compile.filter({ (it.name =~ /androidannotations-api.*\.jar/) }).collect {
            it.isDirectory() ? it : zipTree(it)
        }
    } {
        exclude "META-INF/**/*.*"
    }

    from {
        zipTree(jarFile)
    } 
}

// Copy "mylib.jar" file from the Library module to app module.
task copySDKJar(type: Copy)

copySDKJar {
    from('./build/libs')
    into('../app/libs')
    include('*.jar')
}

copySDKJar.dependsOn createSDK

我想执行" copySDKJar"用户从Android Studio IDE中选择构建/运行/调试时自动执行任务。 " copySDKJar"任务取决于" createSDK"所以它将执行" createSDK"当我们执行" copySDKJar"时的任务。我试过和#34;依赖"," mustRunAfter"但不幸的是它没有用。我是新手,请帮助我。

注意: 不建议添加模块依赖项。

0 个答案:

没有答案