How to read local.properties file inside setting.gradle

Viewed 112

before this, we used this code in build.gradle but after Gradle updated repositories moved to setting.gradle. currently, I don't know how to read properties inside the setting.gradle file.

def propFile = rootProject.file("./local.properties")
def properties = new Properties()
properties.load(new FileInputStream(propFile))

ext.alias = properties['mavenprivate.alias']
ext.key = properties['mavenprovate.key']

and using them for maven repo:

credentials {
   username = alias
   password = key
}

I got this error:

Could not get unknown property 'alias' for Credentials [username: null] of type org.gradle.internal.credentials.DefaultPasswordCredentials_Decorated.

Android-studio Arctic fox, Gradle 7.0.2

0 Answers
Related