Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

incompatible with the android plugin #12

Open
bsagal opened this issue Dec 15, 2013 · 3 comments
Open

incompatible with the android plugin #12

bsagal opened this issue Dec 15, 2013 · 3 comments

Comments

@bsagal
Copy link

bsagal commented Dec 15, 2013

This plugin applies the java plugin witch is incompatible with the android new build system plugin (com.android.tools.build:gradle:0.6.3).

Is there any way make this plugin to make them compatible with andriod?

@aantono
Copy link
Owner

aantono commented Apr 1, 2014

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?

@sorccu
Copy link

sorccu commented Apr 28, 2014

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.

@louiscryan
Copy link

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")
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants