Как разрешить файлу aar исправлять зависимость частных репозиториев maven от Artifactory - PullRequest
0 голосов
/ 17 апреля 2019

У меня есть сервер Artifactory, и у меня есть AAR-библиотека с кодом, Библиотека "B" является внутренней библиотекой, а библиотека A реализует библиотеку B, Но когда я использую библиотеку «А», она не может скомпилироваться

apply plugin: 'com.android.library'
apply plugin: 'com.jfrog.artifactory'
apply plugin: 'maven-publish'

android {
    compileSdkVersion 26

    defaultConfig {
        minSdkVersion 19
        targetSdkVersion 26
        versionCode 2
        versionName "1.1"
        multiDexEnabled true
    }

    def LibraryVersion = "1.0"
    def ECComponentVersion = "01"


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

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.davemorrissey.labs:subsampling-scale-image-view:3.6.0'
    compile 'smart:library:0.0.2@aar'
    implementation 'com.android.support:multidex:1.0.1'
}

repositories {
    google()
    flatDir {
        dirs 'libs'
    }
}


def ARTIFACT_ID = 'library-plugin'
def LIBRARY_VERSION = '0.0.6'
def PACKAGE_NAME = 'com.ec'

publishing {
    publications {
        mavenArr(MavenPublication) {
            groupId = PACKAGE_NAME
            version = LIBRARY_VERSION
            artifactId ARTIFACT_ID

            // Tell maven to prepare the generated "*.aar" file for publishing
            artifact("$buildDir/outputs/aar/${project.getName()}-release.aar")

            pom.withXml {
                def root = asNode()
                def dependenciesNode = root.appendNode('dependencies')
                def repositoriesNode = root.appendNode('repositories')
                //let dependency library to add on POM file.
                configurations.compile.allDependencies.each {
                    if (it.group != null) {
                        def dependencyNode = dependenciesNode.appendNode('dependency')
                        dependencyNode.appendNode('groupId', it.group)
                        dependencyNode.appendNode('artifactId', it.name)
                        dependencyNode.appendNode('version', it.version)
                        dependencyNode.appendNode('scope', "runetimeOnly")
                    }


                }
//
                project.repositories.each {
                    if (it.name.startsWith('artifactory')) {
                        def repositoryNode = repositoriesNode.appendNode('repository')
                        repositoryNode.appendNode('url', "http://10.100.83.64:8081/artifactory/smart_lib/")
                        repositoryNode.appendNode('name', it.name)
                        repositoryNode.appendNode('releases').appendNode("enabled", true)
                        repositoryNode.appendNode('snapshots').appendNode("enabled", false)
                    }
                }
            }
        }
    }
}

artifactory {
    contextUrl = 'http://xxx.xxx.xxx/artifactory/'
    publish {
        repository {
            // The Artifactory repository key to publish to.
            repoKey = 'essential-snapshot-local'
            username = 'test'
            password = 'test'
            maven = true
        }
        defaults {
            //publishing/publications/mavenArr
            publications('mavenArr')
            publishArtifacts = true
            properties = ['qa.level': 'basic', 'dev.team': 'core']
            // Publish generated POM files to Artifactory.
            publishPom = true
        }
    }
    resolve {
        repoKey = 'jcenter'
    }
}
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0'

        classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.5.4"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven {
            url "http://xxx.xxx.xxx/artifactory/smart/"
        }
    }
}

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

Я ожидаю, что Project может просто реализовать 'com.ec:library-plugin:0.0.6' и может использовать 'smart: library: 0.0.2@aar'

...