1. Starting Gradle
gradle source official website https://android.googlesource.com/platform/tools/base/+/gradle_2.3.0/build-system/
1.1 Overall Implementation Diagram
The source code corresponding to the above figure is the Stage in DefaultGradleLauncher
1.2 Specific analysis
When we execute a build task, we always execute commands like ./gradlew assembleDebug, where the gradlew script is the entry point of the entire gradle build. Let's start from here.
The previous code is basically to judge the environment and set variables, just look at the last line:
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" |
The final command executed is basically as follows:
exec $JAVA_HOME/bin/java -classpath $APP_HOME/gradle/wrapper/gradle-wrapper.jar org.gradle.wrapper.GradleWrapperMain |
Here we know that the entrance of the whole gradle is GradleWrapperMain. Basically, we can see that the org.gradle.wrapper.GradleWrapperMain in gradle/wrapper/gradle-wrapper.jar is executed, so we know, gradle