role

  • Save your own Internet broadband
  • Speed up the Build process
  • Deploying third-party Artifacts
  • Improved stability and enhanced control
  • Reduce the load of the central warehouse

steps

  1. (Win environment) Download nexus

2. Go to the bin directory and run nexus /run. 3

4. Login Account Default account name: admin Password: a disk in this path :\nexus-3.19.1-01-win64\sonatype-work\nexus3\admin.password4. Create Repositorie

5. Copy the Maven address

6. Add the repository to the root gradle file

Maven repositories {/ / for gradle build add warehouse {url 'http://localhost:8081/repository/test_releases/' credentials {username 'admin' password 'admin' } } maven { url 'http://localhost:8081/repository/test_snapshots/' credentials { username Google () jCenter ()}} AllProjects {// Add repository for project repositories {maven {url 'http://localhost:8081/repository/test_releases/' credentials { username 'admin' password 'admin' } } maven { url 'http://localhost:8081/repository/test_snapshots/' credentials { username 'admin' password 'admin' } } } }Copy the code
  1. Constants are configured in the root gradle.properties directory for easy setting
NEXUS_REPOSITORY_URL = http://localhost:8081/repository/imooc-snapshots/ # group name POM_GROUPID = com. Test. The android # type aar/jar and so on POM_PACKAGING=aar NEXUS_USERNAME= user name NEXUS_PASSWORD= passwordCopy the code
  1. Configure Maven uploads in submodule build.gradle
Plugins {id 'com.android.library' id 'maven' // plugins} def pomName = this.getName() def pomVersionName = plugins {id 'com.android.library' id 'maven' // plugins} def pomName = this.getName() def pomVersionName = '1.0.0-SNAPSHOT' def pomDescription = 'The audio library for all project' dependencies {// UploadArchives {repositories {mavenDeployer {repository(url: NEXUS_REPOSITORY_URL) {// Fix snapshots URL // Fix user names and passwords authentication(userName: NEXUS_USERNAME, password: NEXUS_PASSWORD) } pom.project { name pomName version pomVersionName description pomDescription artifactId pomVersionName  groupId POM_GROUPID packaging POM_PACKAGING } } } }Copy the code