Android gradle: 如何在build.gradle 脚本中获取合并后的资源目录?

Android gradle: How do I get the merged resources directory in the build.gradle script?

有问题的代码看起来像

applicationVariants.all{ variant ->
   if(variant.buildType.name == 'test'){
      println 'path res: ' + //need directory path here
   }
}
variant.mergeResourcesProvider.get().outputDir.get()

似乎是 return 我需要的路径。同样对于 mergeAssetsProvider