Access providers in EnterpriseRepositoryPlugin in init.gradle

in my init.gradle i use EnterpriseRepositoryPlugin with System.properties['someValue'] which is discouraged due to configuration caching ( Configuration cache )

Now my issue is using providers.environmentVariable('someValue') inside void apply does not work, it cannot be accessed. On the global level in init.gradle it is accessible.

class EnterpriseRepositoryPlugin implements Plugin<Gradle> {
    void apply(Gradle gradle) {
        gradle.settingsEvaluated { settings ->
            // old variant
            // System.properties['someValue']

            // not working
            providers.environmentVariable('someValue')
        }
    }
}

Any ideas how to access providers?

should be accessible via settings.providers.environmentVariable(...).forUseAtConfigurationTime()

1 Like

Thank you a lot, this indeed has worked with

settings.providers.environmentVariable()
settings.providers.systemProperty()

This one is followed up by a new problem Set pluginManagement.repositories in init.gradle which really lets me think about what changes in the first place. Any clues?

Maybe as an important notice, this does only work with gradle 7.x - it is not functional for gradle 6.x