android使用本地maven仓库

主要用途:

1.加载本地仓库速度快;

2.自封装的jar或aar包可以直接传到本地maven中;

 

project gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    gradle.projectsEvaluated {
        tasks.withType(JavaCompile) {
            options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
        }
    }
    repositories {
        //本地maven
        maven{url 'file://D://repository/'}
        //亚洲中心maven
        jcenter()
        //谷歌maven
        google()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

优先本地仓库,本地没有的去亚洲看,亚洲没的去谷歌看;

model gradle:

apply plugin: 'com.android.library'

//引入maven
apply plugin: 'maven'
//对maven进行操作,增
uploadArchives{
    repositories.mavenDeployer{
        // 本地仓库路径
        repository(url:"file://D://repository/")
        // 唯一标识
        pom.groupId = "com.huangxudong.pay"
        // 项目名称
        pom.artifactId = "Pay"
        // 版本号
        pom.version = "1.0.0"
    }
}
android {
    compileSdkVersion 28



    defaultConfig {
        minSdkVersion 17
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:28.0.0-alpha3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

android使用本地maven仓库