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

Initialized ListProperty for nested POJO should not fail build with Gradle 5.0-rc-1 #7583

Closed
bmuschko opened this issue Oct 31, 2018 · 1 comment
Assignees
Labels
in:configuration-model lazy api, domain object container in:core DO NOT USE

Comments

@bmuschko
Copy link
Contributor

Expected Behavior

An initialized ListProperty does not fail the build indicating that it has not been initialized.

Current Behavior

An initialized ListProperty for a POJO annotated with @Nested fails the build indicating that no value has been assigned which is not the case.

@Nested
final ListProperty<Instruction> instructions = project.objects.listProperty(Instruction)

interface Instruction {
    @Internal String getKeyword()
    @Input String getBuild()
}

The error message you receive:

> No value has been specified for property 'instructions'.

Context

Using a ListProperty<POJO> annotated with @Nested used to work properly with 4.10.2. It behaves differently in 5.0-rc-1.

Steps to Reproduce (for bugs)

Run ./gradlew build for the repository https://github.com/bmuschko/docker-incremental-nested-list.

Your Environment

  • Gradle 5.0-rc-1
  • JDK 1.8.0_181
@lacasseio
Copy link
Contributor

This was a change we did in order to make all Provider behave the same initially. Starting with 5.0, no provider has an initial value set. The ListProperty and SetProperty used to be set as an empty collection. Now you can use the builder-like method empty() or value(...) to provide a value upon creation. We are unlikely to change this behavior back to what it was previously. As a workaround when targetting older Gradle version, you can set the property to an empty list (i.e. set([])) after creation. Given that, there still a behavior that causes friction detailed here: #7485. You are welcome to comment on that one.

For your docker plugin, users can work around when upgrading to the latest Gradle version by doing instructions.empty() at the top of the configuration action. They have to be careful to avoid calling any instruction creating method as a set, empty or value remove any element added prior to the value change (this is the friction we are sorting out).

I will close this issue as we won't be changing the behavior anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in:configuration-model lazy api, domain object container in:core DO NOT USE
Projects
None yet
Development

No branches or pull requests

2 participants