yodle / griddle

A gradle plugin that enables it to handle .thrift idl files and generate them with Thrift or Scrooge
Other
13 stars 7 forks source link

IntelliJ doesn't autocomplete for thrift generated classes on it's consumer java projects #2

Closed selvin closed 7 years ago

selvin commented 8 years ago

Hi,

I've setup the following

idl-base/build.gradle

apply plugin: 'idl'

idl-base/scrooge/build.gradle

apply plugin: 'scrooge-java'

dependencies {
  idl project.getParent()

  scroogeGen "com.twitter:scrooge-generator_2.11:4.3.0"

  compile "org.scala-lang:scala-library:2.11.7"
  compile "com.twitter:scrooge-runtime_2.11:4.3.0"
  compile "org.apache.thrift:libthrift:0.5.0"
}

repositories {
  mavenCentral()
  maven { url "http://maven.twttr.com" }
}

consumer/build.gradle

apply plugin: 'idea'

dependencies {
  compile project(':idl-base:scrooge')
}
dkesler commented 8 years ago

My initial guess would be that the directory the generated files are being put into isn't getting marked as a source directory in intellij. Can you look at the idl-base/scrooge project and see if build/gen-java is marked as a source directory or not?

The plugin should be marking it as a source directory for you, so if it's not there's probably some kind of issue.

Couple questions before I try to reproduce locally. How are you generating the intellij project? Are you running gradle idea or importing the gradle project from intellij? Also, what versions of gradle and intellij are you using?

selvin commented 8 years ago

I see this for idl-base/scrooge in it's .iml file

<content url="file://$MODULE_DIR$">
  <sourceFolder url="file://$MODULE_DIR$/build/gen-src" isTestSource="false" />
  ..

I tried both approaches: once gradle idea and then importing and once by just importing the project as a gradle project

IntelliJ 15.0.2

------------------------------------------------------------
Gradle 2.9
------------------------------------------------------------

Build time:   2015-11-17 07:02:17 UTC
Build number: none
Revision:     b463d7980c40d44c4657dc80025275b84a29e31f

Groovy:       2.4.4
Ant:          Apache Ant(TM) version 1.9.3 compiled on December 23 2013
JVM:          1.8.0_65 (Oracle Corporation 25.65-b01)
OS:           Mac OS X 10.11.2 x86_64
dkesler commented 8 years ago

I haven't been able to reproduce. I had to add a root build.gradle as well:

buildscript {
  repositories {
    mavenCentral()
  }
  dependencies {
    classpath 'com.yodle.griddle:griddle:1.7'
  }
}

task wrapper(type: Wrapper) {
  gradleVersion = '2.9'
}

allprojects {
  apply plugin: 'java'
  apply plugin: 'idea'
}

When I run gradle idea with gradle 2.9, I can properly import stuff from idl-base/scrooge into a sample class in consumer within intellij.

If you can reproduce in a freestanding project, zip up the whole project and attach it and I'll take a look at that.

Also, can you try to clarify the exact error case you're seeing a bit more? Can you write java code that compiles if you run gradle build? But when you try to open that code in IntelliJ, the ide doesn't recognize the class?

selvin commented 8 years ago

correct! I am able to write java code that can use the imported classes that were thrift-generated and have it be compliled under gradle build or gradle distZip. However, auto-complete in Idea fails!

I'll try to isolate the issue. Sorry for your trouble. I should have isolated the issue before posting a bug

selvin commented 7 years ago

sorry for the delayed response to this, but I was able to get around this by the following steps

gradle cleanIdea idea

and then instead of importing project, I opened the .ipr file that was generated. In this case, everything was auto-completable by IntelliJ (per compile time deps)