文章序號
- Android gradle打包涉及task源碼解析(一)準備工作
- Android gradle打包涉及task源碼解析(二)
- Android gradle打包涉及task源碼解析(三)
- Android gradle打包涉及task源碼解析(四)
- Android gradle打包涉及task源碼解析(五)
- Android gradle打包涉及task源碼解析(六)
工欲善其事,必先利其器
-
Android構建過程
構建過程.png - Gradle入門
相關知識如果不了自行網上查找
- 涉及到的源碼
- Android 編譯過程調試
- 測試程序
測試程序鏈接
測試程序寫一點gradle邏輯,用于打印出相應task的inputs和outputs文件
// 打印task的輸入和輸出
gradle.taskGraph.afterTask { task ->
try {
println("---- task name:" + task.name)
task.inputs.files.each { fileTemp ->
println 'input file:' + fileTemp.absolutePath
}
println '---------------------------------------------------'
task.outputs.files.each { fileTemp ->
println 'output file:' + fileTemp.absolutePath
}
} catch (Exception e) {
}
}
相關task
新建一個Android Project默認的task如下(構建環境android gradle plugin:3.0.0):
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:checkDebugManifest UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:prepareLintJar UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:createDebugCompatibleScreenManifests UP-TO-DATE
:app:processDebugManifest
:app:splitsDiscoveryTaskDebug UP-TO-DATE
:app:processDebugResources
:app:generateDebugSources
:app:javaPreCompileDebug
:app:compileDebugJavaWithJavac
:app:compileDebugNdk NO-SOURCE
:app:compileDebugSources
:app:mergeDebugShaders
:app:compileDebugShaders
:app:generateDebugAssets
:app:mergeDebugAssets
:app:transformClassesWithDexBuilderForDebug
:app:transformDexArchiveWithExternalLibsDexMergerForDebug
:app:transformDexArchiveWithDexMergerForDebug
:app:mergeDebugJniLibFolders
:app:transformNativeLibsWithMergeJniLibsForDebug
:app:processDebugJavaRes NO-SOURCE
:app:transformResourcesWithMergeJavaResForDebug
:app:validateSigningDebug
:app:packageDebug
:app:assembleDebug
后面將分6篇文章來分別分析相關所有的task。