Publishing and consuming both debug and release libraries to Maven for Android

Viewed 1075

Given that now you can get Gradle to generate both mylib-debug.aar and mylib-release.aar in build\outputs\aar by issuing the ./gradle build for a libary, when I try to publish both types to Maven I get an error unless I classify them.

publishing {
    publications {
        aar(MavenPublication) {
            groupId 'com.mydomain'
            artifactId 'mylib'
            version '0.1'
            artifact bundleRelease { classifier 'release' }
            artifact bundleDebug { classifier 'debug' }
            ...
            //code for source and pom
            ...
        }
    }

Issuing ./gradle publishToMavenLocal I end up with these files in ~/.m2/repository

+--com
  +--mydomain
    +--mylib
      +--0.1
         + mylib-0.1.pom
           mylib-0.1-debug.aar
           mylib-0.1-release.aar
           mylib-0.1-sources.jar
           maven-metadata-local.xml

Now when I try to import this using

dependencies {
    debugImplementation  group: 'com.mydomain', name:  'mylib', version: '0.1', configuration: 'debug'
    releaseImplementation  group: 'com.mydomain', name:  'mylib', version: '0.1', configuration: 'release'

it doesn't work. I have tried other combinations, but have found nothing that works.

0 Answers
Related