//~ 自定义Gradle Plugin中
def outputDir = project.file(new File(project.buildDir, "generated/source/CConfig"))
variant.addJavaSourceFoldersToModel(outputDir)
大家讲道理2017-04-18 09:19:02
In gradle plugin
中你可以使用ASM生成你需要的类,当然需要了解一些字节码相关知识。还有一种做法,也是你上一个问题我有提到的,就是使用APT
, this method is similar to the method in Jake Whartonbutterknife. Hope it helps.
伊谢尔伦2017-04-18 09:19:02
I haven’t studied this in detail, but a simpler way is to add custom fields in BuildConfig. All fields in BuildConfig come from defaultConfg in build.gradle. You can add custom fields by adding buildConfigFiled