Search code examples
grailsdependency-managementtwitter-hbc

how do I integrate hosebird client library to a Grails project?


My goal is to use the hosebird client provided by Twitter to stream tweets in my Grails project.

I'm really not sure how I will approach this, but I first tried including it in the dependencies in my BuildConfig.groovy like this:

dependencies {
    compile 'com.twitter:hbc-core:2.2.0'
}

And then, when I tried to mimic the example code, FilterStreamExample.java, in my TwitterService.groovy, GGTS (the IDE) just shows me errors as I write these lines of code:

import com.google.common.collect.Lists
import com.twitter.hbc.ClientBuilder
import com.twitter.hbc.core.Client
import com.twitter.hbc.core.Constants
import com.twitter.hbc.core.endpoint.StatusesFilterEndpoint
import com.twitter.hbc.core.processor.StringDelimitedProcessor
import com.twitter.hbc.httpclient.auth.Authentication
import com.twitter.hbc.httpclient.auth.OAuth1

Obviously, this makes me unable to run the code because of the compile time error. It just tells that the error is something "Groovy was unable to resolve".

Can you tell what am I missing?

Is it just a groovy syntax error that I'm not noticing? I'm new to Groovy so please bear with me.

OR

Is the problem here is in the inclusion of the library in the dependencies?

My first aim is to be able to use the library this way as I have told it above (the BuildConfig way) before trying to make jars and put it in the src/java. Who knows, the compile time error will appear too. I just want to know if the current obstacle in the approach I did is easy to fix.


Solution

  • GGTS and STS don't parse BuildConfig.groovy - they get all classpath information from Grails. When you update BuildConfig.groovy with a new plugin or jar dependency, right-click on the project node in the tree on the left and select Grails Tools | Refresh Dependencies and GGTS will rebuild its classpath based on the current state of the app.