0

I intend to publish my modules in a nexus repository with the following steps.

first step:

Create a android-publications.gradle file and add the following contents to it

android-publications.gradle :

apply plugin: 'maven-publish'

ext.moduleVersion = "0.0.0"

def moduleGroupId = "team.techvida.framework"
def moduleRepoUrl = "http://url/repository/maven-releases/"

afterEvaluate {
    publishing {
        publications {
            debug(MavenPublication) {
                from components.debug
                groupId = moduleGroupId
                artifactId = "$project.name-debug"
                version = moduleVersion
            }
            release(MavenPublication) {
                from components.release
                groupId = moduleGroupId
                artifactId = project.name
                version = moduleVersion
            }
        }
        repositories {
            maven {
                name "nexus"
                url moduleRepoUrl
                allowInsecureProtocol = true
                credentials {
                    username findProperty("nexusUsername")
                    password findProperty("nexusPassword")
                }
            }
        }
    }
}

Step two Use it in all modules as follows:

core module =>

apply from: "$rootDir/android-library-build.gradle"
apply from: "$rootDir/buildSrc/android-publications.gradle"
ext.moduleVersion = "0.0.1"
dependencies {

}

presentation module =>

apply from: "$rootDir/android-library-build.gradle"
apply from: "$rootDir/buildSrc/android-publications.gradle"
ext.moduleVersion = "0.0.1"
dependencies {

}

Third step Use in a module that uses other modules

di module =>

apply from: "$rootDir/android-library-build.gradle"
apply from: "$rootDir/buildSrc/android-publications.gradle"
ext.moduleVersion = "0.0.1"

dependencies {
    implementation(project(Modules.core))
    implementation(project(Modules.imageLoading))
    implementation(project(Modules.prettyLogger))
}

Note 1 : Publishing the second step modules is done successfully.

Step 4 (which leads to a compilation error) Publish the third step module (di)

Received error:

 What went wrong:
Could not determine the dependencies of task ':di:publishReleasePublicationToNexusRepository'.
> Publishing is not able to resolve a dependency on a project with multiple publications that have different coordi
nates.
  Found the following publications in project ':image_loading':
    - Maven publication 'debug' with coordinates team.techvida.framework:image_loading-debug:0.0.1
    - Maven publication 'release' with coordinates team.techvida.framework:image_loading:0.0.1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run
with --scan to get full insights.

Would you please tell me how to solve this problem?

Alias Cartellano
  • 366
  • 1
  • 3
  • 12
Vahid Garousi
  • 546
  • 4
  • 17
  • I'm not familiar with Gradle and the `maven-publish` plugin, but maybe this helps: https://stackoverflow.com/questions/42908823/publish-to-sonatype-using-new-gradle-plugin-maven-publish. – Oliver Feb 19 '22 at 14:54
  • @Oliver Thank you for your attention, this link did not solve my problem – Vahid Garousi Feb 20 '22 at 04:34
  • Does this answer your question? [Publishing is not able to resolve a dependency on a project with multiple publications that have different coordinates](https://stackoverflow.com/questions/51247830/publishing-is-not-able-to-resolve-a-dependency-on-a-project-with-multiple-public) – baywet Jan 09 '23 at 18:04

0 Answers0