1

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"
        }
    }
}
cha77a
  • 266
  • 1
  • 3
  • 14
  • Hi, did you fix this ? I'm having similar problem with same gradle version and mavenPublishVersion.. – Walid Dec 11 '19 at 14:54
  • 3
    @Walid It eventually worked without any changes for local maven repository but if you are using a remote maven repository like I was, you need to publish these individual modules separately. Luckily `android-maven-publish` plugin comes with handy gradle tasks to publish all artifacts to your maven repo. So, for example if you added your remote maven repo with the name `Foo`, you should have `publishAllPublicationsToFooRepository` generated in your gradle tasks. Run that and it should publish all dependencies. – cha77a Dec 11 '19 at 19:02
  • Thank you for your response, will try that – Walid Dec 12 '19 at 10:12

0 Answers0