Innovation in platforms and tooling is necessary for companies to remain competitive, and Android development is no exception. The Android team at Google has been working hard in this department, with their latest major new thing being improved Java 8 support. This involves some big changes to the Android build system, which unfortunately has caused some casualties in tooling such as this previous approach to using Eclipse for Android development.

With the prospect of cleaning up my Android codebase with Java 8 lambdas, I was unable to resist the new Java 8 tooling. A suggestion from Johannes Brodwall got me thinking about a Gradle plug-in to simplify generating an Eclipse .classpath in a way that is compatible with the innovation going on in Android tooling. Feeling inspired, I created this plugin which does the heavy lifting, adding the necessary classpath entries and expanding Android Archive (AAR) files so that their nested jars can be included.

To use the plugin, add the following to your build.gradle:

apply plugin: 'com.greensopinion.gradle-android-eclipse'
apply plugin: 'eclipse'

buildscript {
    repositories {
        maven {
          url "https://plugins.gradle.org/m2/"
        }
    }
    dependencies {
      classpath "gradle.plugin.com.greensopinion.gradle-android-eclipse:android-eclipse:1.0"
    }
}

eclipse {
  classpath {
    plusConfigurations += [ configurations.compile, configurations.testCompile ]
    downloadSources = true
  }
}

Then from the command-line run:

$ gradle eclipse

When done, a .classpath and .project file should be in the current folder. You’ll need to run gradle eclipse whenever changes are made to your classpath.

To find out more about the plugin, head on over to https://github.com/greensopinion/gradle-android-eclipse

Enjoy!