cn.hx.plugin.junkcode.task.ManifestMergeTask.groovy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of android-junk-code Show documentation
Show all versions of android-junk-code Show documentation
generate junk code for android
The newest version!
package cn.hx.plugin.junkcode.task
import org.gradle.api.DefaultTask
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.tasks.InputFile
import org.gradle.api.tasks.OutputFile
import org.gradle.api.tasks.TaskAction
abstract class ManifestMergeTask extends DefaultTask {
@InputFile
abstract RegularFileProperty getGenManifestFile()
@InputFile
abstract RegularFileProperty getMergedManifest()
@OutputFile
abstract RegularFileProperty getUpdatedManifest()
@TaskAction
void taskAction() {
String genManifest = new String(getGenManifestFile().get().asFile.readBytes())
genManifest = genManifest.substring(genManifest.indexOf("") + "".length(), genManifest.indexOf(" "))
String manifest = new String(getMergedManifest().get().asFile.readBytes())
manifest = manifest.replace(" ", "$genManifest\n")
getUpdatedManifest().get().asFile.write(manifest)
}
}