Add generated file to META-INF

I got this to work and wanted to share the final code; this is an example of how to copy a LICENSE file into the APK’s META-INF directory; many thanks to Aviv for his solution (which this is very close to):

    task put_files_in_META_INF  {
    	def resDir = new File(buildDir, 'generated/files_for_META_INF/')
    	def destDir = new File(resDir, 'META-INF/')
    	// THIS IS KEY: Add resDir as a resource directory so that it is
    	//              automatically included in the APK
    	android {
    		sourceSets {
    			main.resources {
    				srcDir resDir
    			}
    		}
    	}
    	doLast {
    		destDir.mkdirs()
    		copy {
    			into destDir
    			from <SOURCE_LOCATION_OF_LICENSE_FILE>
    		}
    	}
    }
    // Specify when put_files_in_META_INF should run
    project.afterEvaluate {
    	tasks.findAll { task ->
    		task.name.startsWith('merge') && task.name.endsWith('Resources')
	  }.each { t -> t.dependsOn put_files_in_META_INF }
	}