Created
February 26, 2020 21:22
-
-
Save marukami/22de2f5e3efcd0e6f30bbfcdbd3a9e55 to your computer and use it in GitHub Desktop.
Wire proto3 Android Gradle BuildTask
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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