How to access extra properties from project build.gradle in modules

3.6k Views Asked by At

So I'm trying to setup Maven Publish in my library which has several modules in it.

I am following this tutorial since the whole process is imo not that well documented on the Android Documentation. However, I am stuck at the point Customizing POM File Generation — Basics. I added the external info in my project build.gradle and try to add the publishing information in the modules build.gradle. When I try to sync Gradle I get the following error:

A problem occurred configuring project ':projectname'.
> Failed to notify project evaluation listener.
   > Cannot get property 'pomGroupID' on extra properties extension as it does not exist
   > Cannot get property 'pomGroupID' on extra properties extension as it does not exist

The code in my build.gradle files looks like this:

Project:

buildscript {

    // POM information for publishing the library
    ext {
        pomVersion = '4.23'
        pomGroupID = "com.randomname.stackoverflowquestion"
    }
....

Module:

project.afterEvaluate {
    publishing {
        publications {
            maven(MavenPublication) {
                groupId project.ext.pomGroupID
                artifactId project.name
                version project.ext.pomVersion

                artifact(bundleReleaseAar)
            }
        }
    }
}

Any idea on what could be the problem in my case?

1

There are 1 best solutions below

1
On BEST ANSWER

The problem was very simple. Only had to change

project.ext.pomVersion

to

project.pomVersion