Skip to content

Instantly share code, notes, and snippets.

@marukami
Created February 26, 2020 21:22
Show Gist options
  • Save marukami/22de2f5e3efcd0e6f30bbfcdbd3a9e55 to your computer and use it in GitHub Desktop.
Save marukami/22de2f5e3efcd0e6f30bbfcdbd3a9e55 to your computer and use it in GitHub Desktop.
Wire proto3 Android Gradle BuildTask
import org.gradle.api.file.FileCollection
import org.gradle.api.tasks.CacheableTask
import org.gradle.api.tasks.InputFiles
import org.gradle.api.tasks.InputFile
import org.gradle.api.tasks.JavaExec
import org.gradle.api.tasks.OutputDirectory
import java.io.File
import javax.inject.Inject
@CacheableTask
open class WireBuildTask @Inject constructor(
@get:InputFile val compilerPath: File,
@get:OutputDirectory val outputDirectory: File,
@get:InputFiles val protoSource: FileCollection
) : JavaExec() {
init {
classpath = project.rootProject.files(compilerPath)
args = listOf(
"--proto_path=${protoSource.asPath}",
"--kotlin_out=${outputDirectory.path}",
"--android",
protoSource.asFileTree.files.joinToString { " ${it.name}" }.trim()
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment