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

Executing task ':generateInterfaces' results in failure #4

Open
lu4nm3 opened this issue May 18, 2016 · 2 comments
Open

Executing task ':generateInterfaces' results in failure #4

lu4nm3 opened this issue May 18, 2016 · 2 comments

Comments

@lu4nm3
Copy link

lu4nm3 commented May 18, 2016

Hello. I'm trying to use the griddle plugin to generate the default Java classes that you normally get from Thrift (ie. without Scrooge). To do this I configured my build.gradle file like so:

buildscript {
    repositories {
        jcenter()
        mavenCentral()
    }

    dependencies {
        classpath 'com.google.protobuf:protobuf-gradle-plugin:0.7.7'
        classpath 'com.yodle.griddle:griddle:1.7'
    }
}

plugins {
    id "com.commercehub.gradle.plugin.avro" version "0.8.0"
}

apply plugin: 'idl'
apply plugin: 'thrift'
apply plugin: 'scala'
apply plugin: "com.google.protobuf"
apply plugin: 'idea'

repositories {
    mavenCentral()
}

dependencies {
    compile 'org.scala-lang:scala-library:2.11.7',
            'com.google.protobuf:protobuf-java:3.0.0-beta-2',
            'com.google.protobuf:protobuf-java-util:3.0.0-beta-2',
            'org.apache.tinkerpop:tinkerpop:3.2.0-incubating',
            'org.apache.tinkerpop:gremlin-core:3.2.0-incubating',
            'com.michaelpollmeier:gremlin-scala_2.11:3.1.0-incubating.2',
            'com.trueaccord.scalapb:scalapb-runtime_2.11:0.5.26',
            'com.trueaccord.scalapb:scalapb-json4s_2.11:0.1.1',
            'org.apache.avro:avro:1.7.7'

    compile 'org.apache.thrift:libthrift:0.9.3'
}

sourceSets {
    main {
        proto {
            srcDirs = ['src/main/protobuf']
        }
        scala {
            srcDirs = ['src/main/scala', "$protobuf.generatedFilesBaseDir", "$thriftGenDir"]
        }
    }
    test {
        proto {
            srcDirs = ['src/test/protobuf']
        }
        scala {
            srcDirs = ['src/test/scala', "$protobuf.generatedFilesBaseDir", "$thriftGenDir"]
        }
    }
}

idea {
    module {
        sourceDirs += file("$protobuf.generatedFilesBaseDir");
    }
}

protobuf {
    // Configure the protoc executable
    protoc {
        // Download from repositories
        artifact = 'com.google.protobuf:protoc:3.0.0-beta-2'
    }
    //    generatedFilesBaseDir = "$buildDir/generated-sources/main"
}

avro {
    createSetters = false
    fieldVisibility = "PRIVATE"
}

/**
 * Task will use the ScalaPB binary to generate Scala classes using the .proto IDL files
 * */
task generateScalaPB(type: Exec) {
    workingDir 'src/main/protobuf'
    commandLine './scalapbc-0.5.26/bin/scalapbc'
    def protoFiles = fileTree(dir: "src/main/protobuf", include: '**/*.proto').
            getFiles().
            collect() { file -> file.name }
    args = [protoFiles, "--scala_out=flat_package:$protobuf.generatedFilesBaseDir"].flatten()
}

compileScala {
    dependsOn generateScalaPB
}

thriftSrcDir = "${projectDir}/src/main/idl"

Excuse the length build.gradle file. I'm in the process of testing out Protobuf and Avro in addition to Thrift but I thought I would provide the entire file in case there is a known compatibility issue in any of that.

Anyways, when I go to run the generateInterfaces task for gradle, I get the following output:
Note: That I'm running Gradle 2.13 on IntelliJ but the command above I ran from the terminal.

bash$ ./gradlew generateInterfaces --info
...
os.detected.name=osx
os.detected.arch=x86_64
os.detected.classifier=osx-x86_64
All projects evaluated.
Selected primary task 'generateInterfaces' from project :
Tasks to be executed: [task ':copyDependencyIdl', task ':copyIncludedIdl', task ':generateInterfaces']
:copyDependencyIdl (Thread[main,5,main]) started.
:copyDependencyIdl
Skipping task ':copyDependencyIdl' as it is up-to-date (took 0.017 secs).
:copyDependencyIdl UP-TO-DATE
:copyDependencyIdl (Thread[main,5,main]) completed. Took 0.022 secs.
:copyIncludedIdl (Thread[main,5,main]) started.
:copyIncludedIdl
Skipping task ':copyIncludedIdl' as it is up-to-date (took 0.001 secs).
:copyIncludedIdl UP-TO-DATE
:copyIncludedIdl (Thread[main,5,main]) completed. Took 0.002 secs.
:generateInterfaces (Thread[main,5,main]) started.
:generateInterfaces
Executing task ':generateInterfaces' (up-to-date check took 0.005 secs) due to:
  Task ':generateInterfaces' has changed type from 'com.yodle.griddle.GenerateInterfacesScroogeTask_Decorated' to 'com.yodle.griddle.GenerateInterfacesThriftTask_Decorated'.
Starting process 'command 'thrift''. Working directory: /Users/luis.medina/code/protobuf Command: thrift -o /Users/luis.medina/code/protobuf/build/gen-src --gen java:hashcode -I /Users/luis.medina/code/protobuf/build/idl/dependency -I /Users/luis.medina/code/protobuf/build/idl/included /Users/luis.medina/code/protobuf/src/main/idl/test.thrift
:generateInterfaces FAILED
:generateInterfaces (Thread[main,5,main]) completed. Took 0.044 secs.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':generateInterfaces'.
> A problem occurred starting process 'command 'thrift''

* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output.

BUILD FAILED

Total time: 3.366 secs
Stopped 0 compiler daemon(s).

Any idea what might be going on when it says that the "generateInterfaces" task changed type?

@dkesler
Copy link
Collaborator

dkesler commented May 18, 2016

Did you try the scrooge plugin at first? it looks like gradle is saying the reason it's running generateInterfaces is because the task type changed. I think your issue is unrelated.

Can you paste a copy of your test.idl file?

@dkesler
Copy link
Collaborator

dkesler commented May 19, 2016

Actually, instead of just your test.idl file, would it be possible for you to tar up your entire project as is?

Also, two other things that may be useful to try:

  1. Try running with --stacktrace to see if that gives you more info on why the thrift command failed.
  2. Try manually running the thrift command gradle is trying to run to see if that gives you a better error message about why the thrift command is failing.

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

2 participants