2

I'm in the process of trying to create a fat AAR to distribute my Android library. I'm using the Mobbeel Fataar plugin to package all of my dependencies into an AAR for ease of distribution. This works perfectly, and when I run ./gradlew build, I get an AAR file in mylibrary/build/outputs/aar/ called mylibrary-release.aar and it includes all of my dependencies in its libs directory. The issue arises when I attempt to distribute the AAR.

In order to distribute, I found this tutorial to take me through it, which I'm using virtually unchanged. Here's that code (in my build.gradle):

apply plugin: 'maven'
apply plugin: 'signing'

def isReleaseBuild() {
        return VERSION_NAME.contains("SNAPSHOT") == false
}

def getReleaseRepositoryUrl() {
        return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL
                        : "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
}

def getSnapshotRepositoryUrl() {
        return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL
                        : "https://oss.sonatype.org/content/repositories/snapshots/"
}

def getRepositoryUsername() {
        return hasProperty('NEXUS_USERNAME') ? NEXUS_USERNAME : ""
}

def getRepositoryPassword() {
        return hasProperty('NEXUS_PASSWORD') ? NEXUS_PASSWORD : ""
}

afterEvaluate { project ->
        uploadArchives {
                repositories {
                        mavenDeployer {
                                beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }

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

                                repository(url: getReleaseRepositoryUrl()) {
                                        authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
                                }
                                snapshotRepository(url: getSnapshotRepositoryUrl()) {
                                        authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
                                }

                                pom.project {
                                        name POM_NAME
                                        packaging POM_PACKAGING
                                        description POM_DESCRIPTION
                                        url POM_URL

                                        scm {
                                                url POM_SCM_URL
                                                connection POM_SCM_CONNECTION
                                                developerConnection POM_SCM_DEV_CONNECTION
                                        }

                                        licenses {
                                                license {
                                                        name POM_LICENCE_NAME
                                                        url POM_LICENCE_URL
                                                        distribution POM_LICENCE_DIST
                                                }
                                        }

                                        developers {
                                                developer {
                                                        id POM_DEVELOPER_ID
                                                        name POM_DEVELOPER_NAME
                                                }
                                        }
                                }
                        }
                }
        }

        signing {
                required { isReleaseBuild() && gradle.taskGraph.hasTask("uploadArchives") }
                sign configurations.archives
        }

        task androidSourcesJar(type: Jar) {
                classifier = 'sources'
                from android.sourceSets.main.java.sourceFiles
        }

        artifacts {
                archives androidSourcesJar
        }
}

The issue is that, when I run ./gradlew :mylibrary:uploadArchives, it creates a mylibrary-1.0.aar file in mylibrary/build/outputs/aar/ and uploads that file. The problem is that it doesn't have my dependencies bundled in.

I'd like to somehow create mylibrary-1.0.aar with all of my dependencies bundled, and then have that be uploaded. Unfortunately I don't have a completely clear understanding of how the upload code I'm using works. Does anyone know how I can do what I want?

user1902853
  • 399
  • 1
  • 12

0 Answers0