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

Not automatically publishing dependency modules. #40

Closed PrasannaKumarChalla closed 4 years ago

PrasannaKumarChalla commented 5 years ago

I have an android project which includes 3 modules ModuleA, ModuleB, ModuleC. ModuleA depends on both ModuleB and ModuleC. I'm trying to publish the ModuleA to a maven repository using android-maven-publish plugin and looks like it is not automatically publishing ModuleB and ModuleC to maven when I run publishToMavenLocal. When I try to use published ModuleA as a dependency in a different project gradle could not resolve ModuleB, ModuleC.

Is there something that I am missing?.

I am using gradle plugin version 3.5.0, gradle version 5.4.1 and mavenPublishVersion 3.6.2.

This is how project's gradle looks like build.gradle(project)

buildScript {
     ...
     dependencies {
        classpath "digital.wup:android-maven-publish:3.6.2"
     }
}

allprojects {
    apply plugin: "digital.wup.android-maven-publish"
}

and ModuleA's build.gradle build.gradle(ModuleA)

...
dependencies {
    api project(":moduleB")
    api project(":moduleC")
}

publishing {

    repositories {
       ...
       mavenLocal()
    }

    publications {
        mavenSrcModuleA(MavenPublication) {
            from components.android
            groupId = "com.example.sdk"
            artifactId = "moduleA"
            version = "1.0.0"
        }
    }
}

and ModuleB's build.gradle build.gradle(ModuleB)

...
publishing {

    repositories {
       ...
       mavenLocal()
    }

    publications {
        mavenSrcModuleB(MavenPublication) {
            from components.android
            groupId = "com.example.sdk"
            artifactId = "moduleB"
            version = "1.0.0"
        }
    }
}

and ModuleC's build.gradle build.gradle(ModuleC)

...
publishing {

    repositories {
       ...
       mavenLocal()
    }

    publications {
        mavenSrcModuleC(MavenPublication) {
            from components.android
            groupId = "com.example.sdk"
            artifactId = "moduleC"
            version = "1.0.0"
        }
    }
}
warnyul commented 4 years ago

Could you please provide the published pom.xml files? I think the cause of the problem is the use of different maven coordinates The Gradle will write the group and name of the project in the pom file when you add project('name') to the dependencies block. So, you should publish these project with the same coordinates. The easiest way if you do not define these coordinates, in this case the android-maven-publish will use the project parameters for publishing.

The modified build.gradle file of ModuleC:

publishing {

    repositories {
       ...
       mavenLocal()
    }

    publications {
        mavenSrcModuleC(MavenPublication) {
            from components.android
        }
    }
}