Skip to content

Instantly share code, notes, and snippets.

@XavierTalpe
Created March 14, 2013 03:17
Show Gist options
  • Select an option

  • Save XavierTalpe/5158552 to your computer and use it in GitHub Desktop.

Select an option

Save XavierTalpe/5158552 to your computer and use it in GitHub Desktop.
Bugfix for copying assets using v0.3 of the Android Gradle build system. This allows assets to be recursively copied into the APK.
task copyAssetsRec {
description 'Temporary fix to recursively add folders and files from assets. Remove in v0.4.'
ext.assetsSrcDir = file( "${projectDir}/src/main/assets" )
ext.assetsBuildDir = file( "${buildDir}/assets" )
inputs.dir assetsSrcDir
outputs.dir assetsBuildDir
doLast {
android.buildVariants.each { target ->
copy {
from assetsSrcDir
into "${assetsBuildDir}/${target.dirName}"
}
}
}
}
copyAssetsRec.dependsOn {
tasks.matching { task -> task.name.startsWith( 'merge' ) && task.name.endsWith( 'Assets' ) }
}
tasks.withType( Compile ) {
compileTask -> compileTask.dependsOn copyAssetsRec
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment