Gradle,人工的-尝试使用依赖于另一个的lib发布项目

时间:2018-12-13 14:36:29

标签: android gradle artifactory lib maven-publish

我有一个使用两个库项目的应用程序li​​bDevice和libCloud。我的应用程序将libDevice作为依赖项,而libDevice将libCloud作为依赖项。这是我的build.gradle文件的一些摘录:

顶级应用build.gradle:

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.0.1"
    }
}
apply plugin: 'com.jfrog.artifactory'
apply plugin: 'maven-publish'

allprojects {
    artifactory {
        contextUrl = 'http://localhost:8081/artifactory'
    publish {
        repository {
            repoKey = 'example-repo-local'
            username = artifactory_username
            password = artifactory_password
        }
        defaults {
            publications('aar')
            publishArtifacts = true
            properties = ['qa.level': 'basic', 'q.os': 'android', 'dev.team': 'core']
            publishPom = true
        }
    }
}
repositories {
    google()
    jcenter()
    maven {
        url "http://localhost:8081/artifactory/example-repo-local"
        credentials {
            username = "${artifactory_username}"
            password = "${artifactory_password}"
        }
    }
}

}

插入应用程序build.gradle,我在依赖项中添加libDevice:

implementation project(path: ':..:deviceLibrary:libDevice')

在libDevice build.gradle中,我将libCloud添加为依赖项并定义发布设置

依存关系

implementation project(path: ':..:cloudlibrary:libCloud')

以及build.gradle的底部:

publishing.publications {
    aar(MavenPublication) {
        groupId lib_device_library_group_id
        version lib_device_library_version
        artifactId lib_device_library_artifact_id

artifact("$buildDir/outputs/aar/${artifactId}.aar") } }

在libCloud中,我还添加了发布设置

publishing.publications {
aar(MavenPublication) {
    groupId lib_cloud_library_group_id
    version lib_cloud_library_version
    artifactId lib_cloud_library_artifact_id

    artifact("$buildDir/outputs/aar/${artifactId}.aar")
}
}

当我尝试gradlew assembleRelease publishartifactory时,我已经成功构建,但并非所有aar / pom都已完成/部署,只有libDevice。这不好,它会导致很多类未找到异常;)

我可以在工作时使它起作用:

1)删除libDevice中的发布设置

2)gradlew assemblyRelease人工制品发布

3)在libCloud中删除发布设置,并将发布设置放入libDevice

4)gradlew assemblyRelease人工制品发布

这样做,我的两个aar生成,部署,并且我的应用程序启动并很高兴。 但是我想知道如何不执行这四个步骤。

我想启动gradlew assembleRelease artifactoryPublish并发布我的两个aar。应该有可能吧? :)

0 个答案:

没有答案