gradle配置 uploadArchives上传文件到私服仓库

简要

      很多时候,Android Studio中所创建的工程,会依赖一个或多个Module。Module 生成的AAR库,可以上传到maven或者私服Nexus作为公用的SDK。

Gradle子工程之间通过 compile/implementation project(":XXX")这种方式依赖是非常便利的,但是这样的时候,如果用uploadArchives上传AAR到Maven,就可以通过api引用,很是方便。

配置及编译

配置分播放器部分配置和App引用配置

ijkplayer配置及编译

以armv7a为例

build.gradle

apply from: new File(rootProject.projectDir, "tools/gradle-on-demand.gradle");
gradle.startParameter.taskNames.each { task ->
    def taskName = task.split(":").last()
    switch (taskName) {
        case "uploadArchives":
            // apply from: new File(rootProject.projectDir, 'tools/gradle-mvn-push.gradle')
            apply from: new File(rootProject.projectDir, 'tools/gradle-private-upload.gradle')
            break;
        case "bintrayUpload":
            apply from: new File(rootProject.projectDir, 'tools/gradle-bintray-upload.gradle')
            break;
        default:
            // do nothing
            break;
    }
}

其中uploadArchives指令会执行gradle-private-upload.gradle

def getReleaseRepositoryUrl() {
    return hasProperty('PRIVATE_REPO_RELEASE') ? PRIVATE_REPO_RELEASE
            : "http://120.24.92.79:9982/repository/internal"
}

def getSnapshotRepositoryUrl() {
    return hasProperty('PRIVATE_REPO_SNAPSHOT') ? PRIVATE_REPO_SNAPSHOT
            : "http://120.24.92.79:9982/repository/snapshots"
}
def getRepositoryUsername() {
    return hasProperty('PRIVATE_REPO_DEPLOY_USERNAME') ? PRIVATE_REPO_DEPLOY_USERNAME : ""
}

def getRepositoryPassword() {
    return hasProperty('PRIVATE_REPO_DEPLOY_PASSWORD') ? PRIVATE_REPO_DEPLOY_PASSWORD : ""
}
afterEvaluate { project ->
    uploadArchives {
        repositories {
            mavenDeployer {
                beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }

                pom.groupId = GROUP
                pom.artifactId = POM_ARTIFACT_ID
                pom.version = VERSION_NAME

这里定义类仓库地址及用户名和密码,同时还引用了GROUP和版本号等

仓库地址、用户名、密码和GROUP等都是在gradle.properties中定义

VERSION_NAME=1.0.1
VERSION_CODE=100001
GROUP=tv.rapid.media

PRIVATE_REPO_RELEASE=http://120.24.92.79:9982/repository/internal
PRIVATE_REPO_SNAPSHOT=http://120.24.92.79:9982/repository/snapshots

PRIVATE_REPO_DEPLOY_USERNAME=RepoReadWrite
PRIVATE_REPO_DEPLOY_PASSWORD=iQmDauxISZU1M7j8Lbvy

 配置好后,就可以执行gradle uploadArchives进行上传私服仓库

路径:

ijkplayer/android

指令:

gradle uploadArchives

gradle配置 uploadArchives上传文件到私服仓库_第1张图片

上传好后,可以在私服仓库里看到这些文件

App引用配置

app引用私服仓库的文件,这个步骤很简单,只需修改两个地方

build.gradle

gradle配置 uploadArchives上传文件到私服仓库_第2张图片

1、添加路径和账户和密码

        maven {
            url 'http://120.24.92.79:9982/repository/internal'
            credentials {
                username 'RepoReadOnly'
                password 'BLa80AF3xnwlCze9qrvm'
            }
        }

2、引用

    // ijkplayer
    implementation 'tv.rapid.media:ijkplayer-java:1.0.1'
    implementation 'tv.rapid.media:ijkplayer-armv5:1.0.1'
    implementation 'tv.rapid.media:ijkplayer-armv7a:1.0.1'

 

你可能感兴趣的:(流媒体,android,studio,ijkplayer)