Android Studio uses Gradle to publish AAR to local Maven repository

After researching for several days to package lib into aar in Android Studio and then publish it to the local Maven repository, the good information from Baidu is too complicated and cumbersome, either outdated or irrelevant, and finally found a blog today, After learning, I realized my needs and recorded the results:

 

Reference blog: http://blog.csdn.net/qq_30254897/article/details/47275583

 

After learning, I made the following configuration on the normal project:

1. Add maven plugin

apply plugin: 'maven'

 

2. Increase the task of packaging and execution

uploadArchives {
    repositories.mavenDeployer {
        name='mavenCentralReleaseDeployer'
        repository(url: "http://nexus private server ip address: private server port number/nexus/content/repositories/releases/")
        {
            authentication(userName:"Administrator account",password:"Administrator password")
        }
        pom.version  = "1.0.0"
        pom.artifactId = "core-library"
        pom.groupId = "com.xwalk.core"
        pom.name = "core-library"
        pom.packaging = "aar"
    }
}

in: 

        pom.version = "maven version number"
        pom.artifactId = "maven's coordinate number"
        pom.groupId = "maven's group"
        pom.name = "package name"
        pom.packaging = "aar"

 

 

3. Execute the packaging task, open the Terminal terminal of AndroidStudio, and enter the root directory of the current lib

gradle uploadArchives

 If the first execution will download some plug-in jars, BUILD SUCCESSFUL will appear after the execution is completed, indicating that the release is successful

 

 4, gradle call

 

// configure to use local repository
allprojects {
    repositories {
// jcenter ()
        maven{
            url="http://nexus private server ip address: private server port number/nexus/content/groups/public/"
        }
    }
}

// Reference, the focus is on the following @aar
dependencies {
    compile ('com.xwalk.core:core-library:1.0.0@aar')
}
 Note: The focus is on the @aar behind , otherwise the jar package will be read by default, indicating that the jar package cannot be found, I have been confused by this problem,

 I also know what to configure so that it can find the aar package, and it was only when I saw this blog that I was enlightened.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326657541&siteId=291194637