Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide access to Gradle.StartParameter property value in a configuration cache compliant way #19474

Open
ZakTaccardi opened this issue Jan 3, 2022 · 5 comments
Labels
a:feature A new functionality @configuration-cache in:build-environment Gradle, project, system and environment properties, CLI flags in:configuration-cache Configuration Caching

Comments

@ZakTaccardi
Copy link

ZakTaccardi commented Jan 3, 2022

The following provider does not support the configuration cache.

private fun ProviderFactory.startParameterGradleProperty(
    project: Project,
    propertyName: String
): Provider<String> = provider<String?> {
        project.gradle
            .startParameter
            .projectProperties
            .get(propertyName) as String?
}

Is there a way to access a gradle property defined as a StartParameter (-PsomeProperty=..) that is config cache friendly? Unfortunately, providers.gradleProperty(..) does not work for me here as I need to differentiate between a gradle property passed as a start parameter and one passed in a gradle.properties file.

Use case is https://gist.github.com/ZakTaccardi/a4e1b62b31a7e1069c309a2a169b1058 - which is an attempted workaround to:

@Vampire
Copy link
Contributor

Vampire commented May 19, 2022

Besides that there are a few unnecessary explicit types or casts, what is not configuration cache friendly with your code?
Works perfectly fine here.

@ALikhachev
Copy link
Contributor

ALikhachev commented Jun 7, 2022

@Vampire There's a problem that with configuration cache the value of property from start parameters is cached instead of providing the actual value. For example, we have the use-case when we access project.gradle.startParameter.isOffline. There's no way to mark it as configuration cache input neither to request the actual value on task execution.

@Vampire
Copy link
Contributor

Vampire commented Jun 7, 2022

What has that to do with the topic here?
This is about Gradle properties from start parameters. And that works perfectly fine, as any changes in those invalidate the configuration cache.

@ALikhachev
Copy link
Contributor

ALikhachev commented Jun 7, 2022

Yep, you're right. Previously (before Gradle 7.4) the topic was about pretty the same problem.

@mlopatkin mlopatkin added in:configuration-cache Configuration Caching 👋 team-triage Issues that need to be triaged by a specific team and removed to-triage labels Mar 20, 2023
@mlopatkin mlopatkin removed the 👋 team-triage Issues that need to be triaged by a specific team label Jun 1, 2023
@ov7a ov7a added the in:build-environment Gradle, project, system and environment properties, CLI flags label Jul 21, 2023
@ov7a ov7a added to-triage and removed to-triage labels Dec 21, 2023
@ov7a
Copy link
Member

ov7a commented Dec 21, 2023

Sorry for the late reply.

Thank you for your interest in Gradle!

This feature request is in the backlog of the relevant team, but this area of Gradle is currently not in focus. It might take a while before it gets implemented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:feature A new functionality @configuration-cache in:build-environment Gradle, project, system and environment properties, CLI flags in:configuration-cache Configuration Caching
Projects
None yet
Development

No branches or pull requests

6 participants