Last active
February 4, 2018 16:19
-
-
Save mohsenoid/754c72f84d5b6e01a3392540a5adb040 to your computer and use it in GitHub Desktop.
protobuf module build.gradle https://medium.com/@mohsenoid/how-to-setup-your-android-app-to-use-protobuf-96132340de5c
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
apply plugin: 'java-library' | |
apply plugin: 'com.google.protobuf' | |
sourceSets { | |
main.java.srcDirs += "${protobuf.generatedFilesBaseDir}/main/javalite" | |
} | |
dependencies { | |
implementation fileTree(dir: 'libs', include: ['*.jar']) | |
implementation 'com.google.protobuf:protobuf-lite:3.0.0' | |
} | |
protobuf { | |
protoc { | |
// You still need protoc like in the non-Android case | |
artifact = 'com.google.protobuf:protoc:3.0.0' | |
} | |
plugins { | |
javalite { | |
// The codegen for lite comes as a separate artifact | |
artifact = 'com.google.protobuf:protoc-gen-javalite:3.0.0' | |
} | |
} | |
generateProtoTasks { | |
all().each { task -> | |
task.builtins { | |
// In most cases you don't need the full Java output | |
// if you use the lite output. | |
remove java | |
} | |
task.plugins { | |
javalite {} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment