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

hasProperty() returns null inside pluginManagement (in settings.gradle) #16701

Open
szpak opened this issue Apr 2, 2021 · 2 comments
Open

hasProperty() returns null inside pluginManagement (in settings.gradle) #16701

szpak opened this issue Apr 2, 2021 · 2 comments

Comments

@szpak
Copy link
Contributor

szpak commented Apr 2, 2021

Expected Behavior

hasProperty() (also in pluginManagement {}) returns true or false based on a property defined or not.

Current Behavior

null is always returned.

Context

I keep organization-specific internal Gradle plugins in a private GitLab repository which has to be configured in different way for local and CI-based access. For example:

pluginManagement {
    repositories {
        gradlePluginPortal()
        maven {
            name "My private GitLab package repository"
            url "https://gitlab.com/..."
            credentials(HttpHeaderCredentials) {
                name = hasProperty("gitLabPrivateToken") ? 'Private-Token' : 'Job-Token'
                value = hasProperty("gitLabPrivateToken") ? getProperty("gitLabPrivateToken") : System.getenv("CI_JOB_TOKEN")
            }
            authentication {
                header(HttpHeaderAuthentication)
            }
        }
    }
}

As hasProperty() returns null and I have to fallback to checking system environments instead, but in some cases (e.g. two different properties) it might be problematic.

On a contrary getProperty() works fine in both inside and outside pluginManagement {} in settings.gradle.

Steps to Reproduce

In settings.gradle:

pluginManagement {
    assert hasProperty("someExistingOrNotProperty") != null
}

Your Environment

Gradle 6.8.3, OpenJDK 15, Linux.

@stale
Copy link

stale bot commented Apr 16, 2022

This issue has been automatically marked as stale because it has not had recent activity. Given the limited bandwidth of the team, it will be automatically closed if no further activity occurs. If you're interested in how we try to keep the backlog in a healthy state, please read our blog post on how we refine our backlog. If you feel this is something you could contribute, please have a look at our Contributor Guide. Thank you for your contribution.

@stale stale bot added the stale label Apr 16, 2022
@szpak
Copy link
Contributor Author

szpak commented Apr 19, 2022

Still a problem with 7.4.2.

@stale stale bot removed the stale label Apr 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants