Integrate asset preprocessing into Android Gradle build

Viewed 54

What is the best method to integrate asset preprocessing into Android Gradle builds? My specific use case is packing images into a texture atlas.

The best mechanism I have discovered so far is to include an additional directory in the asset set:

sourceSets {
    main.assets.srcDirs += file("${rootProject.projectDir}/build/assets")
 }

And then wire up the tasks to produce these assets into the build:

android.applicationVariants.all { variant ->
  variant.javaCompileProvider.configure {
    it.dependsOn finalizeAssets
  }
}

This approach is functional but cumbersome, especially the awkward dependency.

Is there a canonical way to preprocess Android assets in Gradle?

0 Answers
Related