preface
In the last article we mentioned that the CloudDisk team decided to split the team into five teams that manage files, dynamics, user center, platform, and common libraries. Instead of using a single Git repository for code management, each team can maintain its own code repository independently.
However, although the modules have been decoupled, they are still compiled in the form of source dependencies. To split the business into separate repositories, we need to adjust the source dependencies to binary dependencies. In this article, we will transform CloudDisk to unlock the source code compilation dependency.
Binary publishing configuration
Here we choose the common Maven for management. For the purposes of the demonstration, we use local Maven for the configuration. In the actual project, we only need to set the address to the maven address of the server, and then add the following code to the module’s build.gradle:
apply plugin: 'maven'
group = 'com.cloud.disk'
archivesBaseName = 'library'
version = '1.0.0'
repositories.mavenCentral()
uploadArchives {
repositories.mavenDeployer {
repository(url: 'file:'+ rootDir.getPath()+'/lib')}}Copy the code
Add the following code to the root directory of build.gradle:
allprojects {
repositories {
maven{
url 'file:'+ rootDir.getPath()+'/lib'}}}Copy the code
Your project will be able to reference the local Maven released JAR package.
To trigger version release, run the following command:
./gradlew :library:uploadArchives
Copy the code
CloudDisk Example of reconstruction
See Github for sample code for specific Library modifications
Gradle dependency: App Gradle dependency: App Gradle dependency: App Gradle dependency: App Gradle dependency
implementation 'com. Cloud. Disk: library: 1.0.0'
implementation 'com. Cloud. Disk: API: 1.0.0'
implementation 'com. Cloud. Disk: platform: 1.0.0'
implementation 'com. Cloud. Disk. Bundle: file: 1.0.0'
implementation 'com. Cloud. Disk. Bundle: dynamic: 1.0.0'
implementation 'com. Cloud. Disk. Bundle: user: 1.0.0'
Copy the code
conclusion
Based on the previous decouple work we have done, we are using local Maven for binary management. In real projects, these AAR are managed in remote Maven. We can also manage individual business features in separate warehouses.
In architectural design, App is the integration of the whole project, for integration and final release. After warehousing, all business bundles are maintained in independent warehouses, and we hope that the Bundle can be compiled and debutted independently. In the next part of Mobile Application Legacy System Reconstruction (12) – Compilation and debugging, we will continue to transform CloudDisk to enable the business Bundle to support independent compilation and debugging.
CloudDisk example code
CloudDisk
Series of links
Refactoring legacy Systems for mobile Applications (1) – Start
Refactoring legacy systems for mobile applications (2) – Architecture
Refactoring legacy systems for mobile applications (3) – Examples
Refactoring legacy Systems in Mobile Applications (4) – Analysis
Mobile application legacy System refactoring (5) – Refactoring methods
Refactoring legacy Systems for mobile applications (6) – Test
Mobile application legacy System refactoring (7) – Decoupled refactoring Demonstration (1)+ video demonstration
Refactoring legacy Systems for mobile applications (8) – Dependency Injection
Refactoring legacy systems for mobile applications (9) – Routing
Refactoring legacy Systems in Mobile applications (10) — Decoupled Refactoring (2)
The outline
about
- Author: Huang Junbin
- Blog: junbin. Tech
- GitHub: junbin1011
- Zhihu: @ JunBin