Gradle, artifactory - Trying to publish project with lib that depends on another

Hi! :smiley:

I have an app which uses two libraries projects, libDevice and libCloud. My app has libDevice as a dependency and libDevice has libCloud as a dependency. Here are some extracts of my build.gradle files :

Top-level app 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}"
        }
    }
}

}

Int the app build.gradle , I add libDevice in dependencies :

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

In the libDevice build.gradle, I add libCloud as a dependency and define publishing settings

in dependencies

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

and at bottom of 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") } }

And in libCloud I’m also adding publication settings

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")
}
}

When i’m trying gradlew assembleRelease publishartifactory, I’ve got BUILD SUCCESSFUL but not all aar / pom are done / deployed, only libDevice 's. This is not good, it results in a lot of class not found exceptions :wink:

I can make it work when I :

  1. remove publish settings in libDevice
  2. gradlew assembleRelease artifactoryPublish
  3. remove publish settings in libCloud and put publish settings in libDevice
  4. gradlew assembleRelease artifactoryPublish

Doing this, my two aar are generated, deployed, and my app launches and is happy.
But I would like to know how no to do those four steps .

I would like to launch gradlew assembleRelease artifactoryPublish and have my two aar published. It should be possible, should it? :slight_smile: