android {
...
sourceSets {
main {
manifest.srcFile {
/* 多个AndroidManifest拼接,
修改AndroidManifest运行时及时更新,
clean后不会自动创建,需手动sync,可能是因为分两步的问题*/
def _manifests = ['src/comm/AndroidManifest.xml', 'src/pay/AndroidManifest.xml']
def main = file('src/main/AndroidManifest.xml')
def targetFile = new File(getBuildDir(), "AndroidManifest.xml")
if (!targetFile.getParentFile().exists()) {
targetFile.getParentFile().mkdirs();
}
def main_text = main.getText("utf-8")
def appIndex = main_text.lastIndexOf("</application>")
def targetContent = main_text.substring(0, appIndex)
for (item in _manifests) {
def c = file(item).getText("utf-8");
def appTag = "<application>"
def ct = c.substring(c.indexOf(appTag) + appTag.length(), c.lastIndexOf("</application>"))
targetContent += ct;
}
targetContent += main_text.substring(appIndex)
targetFile.write(targetContent, "utf-8")
return targetFile.getAbsolutePath()
}
jniLibs.srcDirs = ["libs", 'src/comm/libs', 'src/libs',
'src/main/jniLibs', 'src/main/libs',
'src/view/libs', 'src/pay/libs',
]
res.srcDirs = ['src/main/res', 'src/comm/res', "src/view/res", "src/pay/res"]
java.srcDirs = ['src/main/java', 'src/comm/java', 'src/view/java', "src/pay/java"]
}
}
...
}
网友评论