Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Source code of Google's Gradle Plugin for building Android

Tags:

I want to learn how it works to build Android program. Do you know where I can download the source code of the build plugin of com.android.build.gradle?

like image 887
user3236879 Avatar asked Dec 29 '16 11:12

user3236879


People also ask

What is Android Gradle plugin?

The Android Gradle plugin (AGP) is the official build system for Android applications. It includes support for compiling many different types of sources and linking them together into an application that you can run on a physical Android device or an emulator.

Where is Android Gradle plugin located?

You can specify the Gradle version in either the File > Project Structure > Project menu in Android Studio, or update your Gradle version using the command line.

Which Gradle is required for Android project development?

If you are using Gradle for Android, you need to move to version 3.3 or higher of both the Android Gradle Plugin and Android Studio.

What is Gradle code?

Gradle is a build automation tool known for its flexibility to build software. A build automation tool is used to automate the creation of applications. The building process includes compiling, linking, and packaging the code. The process becomes more consistent with the help of build automation tools.


1 Answers

If you have Android Studio, the android gradle plugin and an android app that builds, you should be able to find gradle plugin source code on your own development machine.

  1. cd into your home dir
  2. cd into .gradle/caches/modules-2/files-2.1/com.android.tools.build/gradle-core/
  3. use a deep search tool (such as find) to look for a file with a name like 'gradle-core-2.3.1-sources.jar' (Note: the '2.3.1' in this example is only one possibility. You may have a different version. And there may be multiple versions on your machine.)

In other words, the downloaded plugin source jar files are stored by gradle down a path that looks something like:

~/.gradle/caches/modules-2/files-2.1/com.android.tools.build/gradle-core/2.3.1/59c72f62795f6ce6dd95c0b2e91c16dc16a1c8c7/gradle-core-2.3.1-sources.jar

(On your machine the hash and version in this path may be different.)

You can copy that jar file to another location and then unzip it to see the actual source files for the android gradle plugin:

./com/android/build/gradle/api/AndroidArtifactVariant.java ./com/android/build/gradle/api/AndroidSourceDirectorySet.java ./com/android/build/gradle/api/AndroidSourceFile.java ./com/android/build/gradle/api/AndroidSourceSet.java ./com/android/build/gradle/api/ApkOutputFile.java
./com/android/build/gradle/api/ApkVariant.java ./com/android/build/gradle/api/ApkVariantOutput.java ./com/android/build/gradle/api/ApplicationVariant.java ./com/android/build/gradle/api/AtomVariant.java ./com/android/build/gradle/api/AtomVariantOutput.java ./com/android/build/gradle/api/BaseVariant.java ./com/android/build/gradle/api/BaseVariantOutput.java
. . .

like image 154
albert c braun Avatar answered Sep 21 '22 11:09

albert c braun