AS uses Apache Maven to build a local warehouse

1. Apache Maven 3.6.1 installation and configuration

Home Page: https://maven.apache.org/
Downloads: https://maven.apache.org/download.html

Maven installation and configuration

2. AS releases aar to local warehouse

Reference: Use Nexus3.16.2 to build maven private server, upload aar

2.1. New local_maven.gradle file:

// 发布maven配置
apply plugin: 'maven'

def GROUP_ID = 'com.kedacom.nexuslib'
def ARTIFACT_ID = 'nexusLibrary'
def VERSION_NAME = "1.0.2"
//def VERSION_NAME = '1.0.1-SNAPSHOT'
def REPOSITORY_URL = "D:/soft/apache-maven-3.6.1/maven-repository/"

uploadArchives {
    repositories {
        mavenDeployer {
            pom.groupId = GROUP_ID
            pom.artifactId = ARTIFACT_ID
            pom.version = VERSION_NAME
            pom.packaging = 'aar'
            repository(url: uri(REPOSITORY_URL))
        }
    }
}

You can also refer to LegoArch (BD Netdisk).

2.2. The configuration file referenced in the module's build.gradle (Placed after android {}):

apply from: 'local_maven.gradle'

2.3. After synchronizing gradle, click uploadArchives to start publishing. After successful publishing, the local repository is as follows:

Insert picture description here
You will find that the file path and configuration information are consistent.

3. Use Library

Add in the project's build.gradle:

allprojects {
    repositories {
        maven { url 'D:/soft/apache-maven-3.6.1/maven-repository/' }
        jcenter()
    }
}

Add in APP's build.gradle:

implementation "com.kedacom.nexuslib:nexusLibrary:1.0.2"
Published 45 original articles · Like 24 · Visits 50,000+

Guess you like

Origin blog.csdn.net/zhijiandedaima/article/details/91040665
Recommended