# ComposingBuildDemo **Repository Path**: cbfg5210/ComposingBuildDemo ## Basic Information - **Project Name**: ComposingBuildDemo - **Description**: 统一管理插件和依赖库信息 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: https://juejin.im/post/6884042637234405389/ - **GVP Project**: No ## Statistics - **Stars**: 5 - **Forks**: 4 - **Created**: 2020-10-13 - **Last Updated**: 2022-12-10 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # ComposingBuildDemo 初识 Composing builds 是从这篇文章:[再见吧 buildSrc, 拥抱 Composing builds 提升 Android 编译速度](https://juejin.im/post/6844904176250519565),在这里衷心感谢文章的作者:[HiDhl](https://juejin.im/user/2594503168898744)。 本项目在 [ComposingBuilds-vs-buildSrc](https://github.com/hi-dhl/ComposingBuilds-vs-buildSrc) 基础上结合个人想法做了一些小修改,下面介绍一下使用方法: 1、Clone 本项目,复制 plugin_version 文件夹到项目目录下(Ps:见 ①); 2、在 settings.gradle 中引入该插件模块:includeBuild 'plugin_version' ; 3、在项目根目录下的 build.gradle 中添加: ```gradle // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { ... } //The use of apply false adds the plugin to the overall project, but does not add it to the root project. plugins { id 'plugin.version' apply true } ``` 经过前面三步就已经完成了版本管理插件的引入,接下来就可以像 buildSrc 那样引用依赖了: ```gradle dependencies { implementation fileTree(dir: "libs", include: ["*.jar"]) implementation Deps.kotlinStdlibJdk7 implementation Deps.appcompat implementation Deps.constraintLayout } ``` 这里的版本管理延续了 [BuildSrcDemo](https://github.com/cbfg5210/BuildSrcDemo) 里的方式,在 plugin_version 模块中的 versions.gradle 中配置依赖/插件信息进行统一管理修改版本, 因为其中可以看到依赖/插件是否有新版本的提示,通过执行 task:updateDenpendencies 把 versions.gradle 中的配置信息同步到 Deps.groovy 中供模块 build.gradle 使用。 Ps: ①:把插件模块放入到项目目录中,在执行 'Clean Project' 操作的时候会有以下提示,但是并不影响操作的执行,所以我还是选择像 buildSrc 一样把它放到项目目录中: ```gradle Project directory 'E:\workspace\AndroidStudio\ComposingBuildDemo\plugin_version' is not part of the build defined by settings file 'E:\workspace\ ```