Problem:
Want to use Gradle in an existing Eclipse ADT project
Solution:
Eclipse ADT Plugin can help generate Gradle files
Discuss:
The ADT plugin for Eclipse was the main Android development tool before the launch of Gradle in 2013. The ADT project is now being replaced by Android studio, but there are still legacy projects.
ADT Plug-ins can be based on existing project structures and dependencies that help you build gradle profiles.
Although this is not a mainstream mechanism, but in practice will encounter such a project. This is also a good opportunity to showcase the sourceset mapping in Gradle, and how to match the old project structure to the new Gradle-based project.
The structure of Eclipse ADT trial teaching all the code in the root directory, preceded by a directory called SRC. The resource is placed under the directory called res in the root directory. The manifest file is also under the root directory. All of these locations have changed under the new project structure.
The Gradle file generated by the ADT plugin shows partial conversions:
You will be interesting to find the map in the Sourcesets block completed. The source files under the new project structure are stored under Src/main/java. An existing project has a SRC directory. So the Sourcesets block uses the Srcdirs property to make a mapping from the Src/main/java to the SRC directory. In fact, the entire folder uses this mechanism to map from the old structure to the new structure.
Android Development: "Gradle Recipes for Android" read notes (translation) 2.3--Export app with Eclipse ADT