Harkish
Harkish

Reputation: 2372

Android Gradle task to copy files after build

I am trying to copy a couple of files from the source tree to the directory where Gradle finally generates the apk files. The build seems to go fine but I do not seem to see the copy working. I added the following task in my modules build.gradle

task copySupportFiles(type: Copy){
    from 'src/main/support'
    into 'build/outputs/apk'
    include '**/.dat'
    include '**/.txt'
}

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

Upvotes: 15

Views: 8788

Answers (2)

drakeet
drakeet

Reputation: 2714

Your doLast should be placed in afterEvaluate:

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

Upvotes: 4

miv
miv

Reputation: 349

As mentioned by @Steffen Funke in comments the error is in the additional asterisk :

'**/.dat'should be '**/*.dat'

Upvotes: 6

Related Questions