For as-based development projects, specific functional modules are often extracted into independent libraries for management, and then uploaded to the Maven library for reference through Gradle dependency.

Its advantages are as follows: 1. Independent Git project library, module functions and responsibilities are clearly defined; 2. External users generally do not need to pay attention to the specific implementation and logical details of this Git project library, but only need to call it in the corresponding exposed way; 3. Generally, such Git project libraries have special administrators and technical personnel to implement iteration, maintenance and update of their functions, as well as corresponding version management; 4. The user only references the Git project library through Gradle, which is further guaranteed in terms of security.

But in actual development, sometimes need to Git project changes, the corresponding need for alignment and the main engineering test and so on, as if every time modify the Git project library code, update to the Maven repository, and then in the main project update corresponding Maven version, whether the implementation process, or the actual debugging, etc., were too cumbersome.

Gradle provides specific syntactic structures that allow you to introduce such independent Git libraries directly during debugging in the same way that other modules of the project are introduced.

Settings. gradle file:

include ':cornlog'
project(':cornlog').projectDir = new File('.. /CornLogSDK/cornlogsdk')
Copy the code

Main project build.gradle file:

dependencies {
    ......

    api(project(':cornlog')) {
        exclude group: 'com.abc.mlog', module: 'mlog'}... }Copy the code

After sync, you can find that the independent Git project library will appear in the project navigation view on the left of the current main project. You can directly modify, compile, debug, etc. Similar to other independent module effects within the main project.

Git commit is still valid only for the master project. If you need to commit the independent Git project library, you need to submit it to its independent Git local project (the code is the same as the code in the main project view to modify the independent Git project library).


The configuration is as follows:

AfterEvaluate {project -> uploadArchives {repositories {mavenDeployer {.... // Publish the artifact snapshotRepository(url: uri('/Users/corn/localRepo'))... }}}}Copy the code
Maven {url: allProjects {repositories} //'/Users/corn/localRepo'}... }... }Copy the code