Bob Kuhar
Bob Kuhar

Reputation: 11110

Can I get gradle to update my existing Eclipse project?

I'm new to Gradle, so please excuse me if this question seems naive or simple.

My eclipse project exists and works well and I want to add Logback for my logging. It is easy enough to get the dependencies set up in build.gradle...

dependencies {
    groovy group: 'org.codehaus.groovy', name: 'groovy', version: '1.8.3'

    // Logback dependencies    
    compile 'org.slf4j:slf4j-api:1.6.4'
    compile 'ch.qos.logback:logback-core:1.0.3'
    compile 'ch.qos.logback:logback-classic:1.0.3'
}

...and this allows my build to succeed, but how can I get it to update the "Referenced Libraries" section of my eclipse project? In other words, can I get gradle to update eclipse's .classpath adding the appropriate entries for any new libraries that are brought in via the gradle dependencies?

As it currently stands, I have to figure out where in ~/.gradle the dependencies became JAR files and by hand I create Reference Libraries to point at them. Yuk. There has to be a way to automate this.

Upvotes: 3

Views: 4953

Answers (1)

rodion
rodion

Reputation: 15029

I think what you are looking for is Gradle Eclipse Plugin.

Just add apply plugin: 'eclipse' at the beginning of your build.gradle and then try running gradle eclipse. This will generate all eclipse settings files based on your gradle set-up.

If you need to just generate .classpath you can do so by running gradle eclipseClasspath.

Upvotes: 10

Related Questions