Comments (3)
I am not at length familiar with the android build declaration/configuration in Gradle.
Can you shed some light onto what exactly is not compatible?
From your comment, I assume the Android build does not use 'java' plugin, but something else?
from gradle-plugin-protobuf.
There's a way to make it work. First of all, you'll have to create a new Java library module in your project just for the protos. Then, if you follow the instructions in the README, gradle
will already happily build your project. Unfortunately, Android Studio will not see the generated files with the default Gradle configuration, which ignores the whole build directory. It will still build, but you won't get autocomplete and you'll get unresolved symbol errors in the editor. I was able to get it to work with the following configuration:
proto/build.gradle
apply plugin: 'protobuf'
apply plugin: 'idea'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'ws.antonov.gradle.plugins:gradle-plugin-protobuf:0.8'
}
}
idea {
module {
// The whole build dir is excluded by default, but we need build/generated-sources,
// which contains the generated proto classes.
excludeDirs = [
file('.gradle'),
file("$buildDir/classes"),
file("$buildDir/docs"),
file("$buildDir/dependency-cache"),
file("$buildDir/libs"),
file("$buildDir/reports"),
file("$buildDir/resources"),
file("$buildDir/test-results"),
file("$buildDir/tmp"),
]
}
}
dependencies {
compile group: 'com.google.protobuf', name: 'protobuf-java', version: '2.5.0'
}
protocPath = '/usr/local/bin/protoc'
app/build.gradle
dependencies {
// ...
compile project(':proto')
// ...
}
settings.gradle
include ':app', ':proto'
Hope this saves someone else some time. Alternatively, changing generatedFileDir
should work also, but I prefer to have all build artifacts in the build dir.
from gradle-plugin-protobuf.
A slight more succinct and reliable way of achieving the same effect...
excludeDirs = [file('.gradle')]
if (buildDir.exists()) {
excludeDirs += files(buildDir.listFiles())
excludeDirs -= file("$buildDir/generated-sources")
}
from gradle-plugin-protobuf.
Related Issues (15)
- Specify repository as a dependency HOT 3
- Update methods to be deprecated in Gradle 2.0 HOT 4
- How to generate output?
- Add support for the other built-in code generators HOT 1
- Adding directory to protoc's include path HOT 1
- Plugin should have an simpler name HOT 1
- Prevent copying protos to extractedProtosDir
- Plugin prints "error" message when running Gradle 2.1 HOT 1
- Don't compile protos in extracted-protos HOT 4
- protobufCodeGenPlugins strips everything after colon in Windows filenames
- Assumption of 'proto' subdir is too restrictive
- proto import statement from Android project to Android project broken? HOT 1
- Specify directory or list of files as a dependency HOT 9
- Unable to build proto in generateProto task HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gradle-plugin-protobuf.