Android Gradle任务在构建后复制文件

时间:2015-08-20 02:38:27

标签: android gradle build

我正在尝试将几个文件从源代码树复制到Gradle最终生成apk文件的目录中。构建似乎很好,但我似乎没有看到副本工作。我在我的模块build.gradle

中添加了以下任务
task copySupportFiles(type: Copy){
    from 'src/main/support'
    into 'build/outputs/apk'
    include '**/.dat'
    include '**/.txt'
}

assembleDebug {}.doLast{
    tasks.copySupportFiles.execute()
}

2 个答案:

答案 0 :(得分:5)

正如@Steffen Funke在评论中提到的那样,错误在附加的星号中:

sails.sockets.join(req, 'myCustomRoomName'); 应为sails.sockets.broadcast("myCustomRoomName", "nameOfEvent", {someData: "can also be just string instead of obj, i prefer objects..."});

答案 1 :(得分:2)

您的doLast应放在afterEvaluate

afterEvaluate {
    assembleRelease.doLast {
        tasks.copySupportFiles.execute()
    }
}