3

I'm developing a multi-module android project using gradle build.

I'm using maven-publish plugin to publish artifact to sonartype nexus.

The current setup is inside every module there is a publication job

plugins{
    id(Plugins.kotlinAndroidApplication)
    id(Plugins.kotlinAndroid)
    id(Plugins.kotlinAndroidExtensions)
    id(Plugins.mavenPublish)
    id(Plugins.dokkaAndroid)
}

publishing {
    repositories {
        maven {
        credentials {
            username = project.properties["mavenUser"] as? String
            password = project.properties["mavenPassword"] as? String
        }
        url = https://mynexus
    }
    }
    publications {
        create<MavenPublication>("mavenAar") {
            groupId = rootProject.extra.get("groupId") as String
            artifactId = rootProject.extra.get("artifactId") as String
            version = (rootProject.extra.get("versionName") as String) + (if (project.hasProperty("release")) "" else "-SNAPSHOT")

            from(components["android"])
            //artifact(tasks["javadocJar"])
            artifact(tasks["dokkaJar"])
        }
    }
}

When my Jenkin CI build the project with deploy = true, every module will be published. The problem is some module depend on other, so the dependency module will be published twice. Re-deploy module with same version is not allowed on release nexus maven repo.

Anyway to only publish certain module only or to ensure every module is only deploy once?

halfer
  • 19,824
  • 17
  • 99
  • 186
Lê Khánh Vinh
  • 2,591
  • 5
  • 31
  • 77

0 Answers0