I have a frontend and a backend repository for my app. The backend is written in Go and serves the API over gRPC. The generated gRPC Java files end up in backend-repo/proto-gen/java/
(so backend-repo/proto-gen/java/com/myApp/Users.java
).
In my frontend android repo I have submoduled the backend repo to a folder called server
. I want to modify my build.gradle
to compile the .java
files from the backend.
android-repo/
app/
build.gradle
server/proto-gen/java/com/myApp/
Users.java
AnotherService.java
I'm very new to Android development and am struggling to figure out the right approach.
This is a snippet from my app/build.gradle
but it fails because it can't find the package com.google.protobuf
.
task compileGrpc (type: JavaCompile) {
source = fileTree(dir: '../server/proto-gen/java/', include: '**/*.java')
destinationDir = file('build/classes')
classpath = files('../server/proto-gen/java/')
options.compilerArgs = ["-sourcepath", "$projectDir/../server/proto-gen/java/"]
}
dependencies {
compile 'com.google.protobuf:protobuf-java:3.0.0-alpha-2'
compileGrpc.execute()
}
Simply including the path to the
src
sourceset for the project would include them within the compilation:You'll be able to see the src files/directories included within the Android View/Project Explorer on the right side and edit the files directly.