wupdigital / android-maven-publish

Modification of the standard Maven Publish plugin to be compatible with android-library projects (aar).
Apache License 2.0
326 stars 39 forks source link

Error:groovy.lang.MissingPropertyException: No such property: project for class: digital.wup.android_maven_publish.VariantPublishConfiguration #5

Closed lsuski closed 7 years ago

lsuski commented 7 years ago

I have this exception when trying to use components.androidDebug or components.androidRelease with Gradle 4.2.1 and AGP 3.0.0

magneticflux- commented 7 years ago

@lsuski How did you work around this issue? I came here from dcendents/android-maven-gradle-plugin#64.

magneticflux- commented 7 years ago

For future reference, I added maven { url = 'https://oss.sonatype.org/content/repositories/snapshots' } to my buildscript repositories and then updated to 3.3.1-SNAPSHOT where the bug is fixed.

warnyul commented 7 years ago

3.1.1 has been released.

lsuski commented 7 years ago

Having 2 separate publications for debug and release has some drawback - it performs 2 separate uploads to maven repository (for Maven they are separate versions so for SNAPSHOT it increment version counter) but I wanted to have single upload with artifacts: my-lib-debug.aar and my-lib-release.aar. To workaround this I have this in build.gradle


publishing.publications {
 "mavenAll"(MavenPublication) {
        def addAll=true
        pom.packaging = 'aar'
        android.libraryVariants.all { v ->
            if (addAll) {
                addAll=false
                from components.android // this can be called only once
                setArtifacts([])    //clears artifact added by components.android - my-lib.aar
                artifact(tasks.sourcesJar) //add sources my-lib-sources.jar - optional
            }
            artifact(tasks."bundle${v.name.capitalize()}") {    // add aar artifact my-lib-<variant>.aar
                classifier v.name
            }
        }
    }
}
magneticflux- commented 7 years ago

@lsuski Unfortunately, that prevents your variants from having different dependencies because Maven can only have one pom.xml file per version per artifact ID. The way Google Guava separates their JVM and Android builds is by appending it to the end of the version: guava:23.3-android or guava:23.3-jvm.

lsuski commented 7 years ago

Yeah, I know that but in this case I have the same dependencies.

magneticflux- commented 7 years ago

@lsuski Okay, I'm just clarifying and bringing up all of the options for any other people looking for a solution here.