Monday, 3 May 2021

Could not get unknown property 'release' for SoftwareComponentInternal - Maven publish plugin project gradle

I have an Android project with multiple modules and I want to publish them to self-hosted maven repo. I earlier had the publishing code present in individual modules and things worked just fine. I am now trying to move the publishing code into the project build.gradle so that I can reuse the code. The code inside my individual modules was:

afterEvaluate {
        // To avoid publishing of the applications inside the project ..
        if (!plugins.hasPlugin("android")) {
            publishing {
                publications {
                    mavenAar(MavenPublication) {
                        artifactId "$project.name"
                        from components.release
                    }
                }
                repositories {
                    .... My repo details and credentials .......
                }
            }
        }
    }

and things worked just fine. When I moved the code to the project build.gradle, like this:

subprojects {
    apply plugin: 'maven-publish'

    afterEvaluate {
        // To avoid publishing of the applications inside the project ..
        if (!plugins.hasPlugin("android")) {
            publishing {
                publications {
                    mavenAar(MavenPublication) {
                        artifactId "$project.name"
                        from components.release
                    }
                }
                repositories {
                    .... My reop details and creddentials  .....
                }
            }
        }
    }
}

I started getting the following error when running the publish task:

A problem occurred configuring project ':mymodule'.
> Could not get unknown property 'release' for SoftwareComponentInternal set of type org.gradle.api.internal.component.DefaultSoftwareComponentContainer.

Can someone point out the problem here?



from Could not get unknown property 'release' for SoftwareComponentInternal - Maven publish plugin project gradle

No comments:

Post a Comment