DefaultPropertyStateTest.groovy

Clone Tools
  • last updated a few seconds ago
Constraints
Constraints: committers
 
Constraints: files
Constraints: dates
Move file collection APIs out of core (#6525)

This change breaks out code that directly relates to handling `FileCollection`s and their build dependencies (called `TaskDependency` at this time) into a separate subproject (`:files`). This is so that other modules can build on just this module instead of having to depend on the oversized `:core`.

As part of the change `Provider`s have been moved to `:base-services`. In a possible followup step `:base-services` could be split into a module that captures the very basic concepts of Gradle's data model: it's all about `DomainObjectCollection`s that can be configured via `Action`s, transformed via `Transformer`s, lazyness can be provided via `Provider`s and rich mutable data types can be created via `Property` objects.

Another addition to `:base-serivces` is the directed graph traversal algorithms used in many parts of Gradle.

    • -230
    • +0
    ./DefaultPropertyStateTest.groovy
  1. … 443 more files in changeset.
Remove deprecated `ProperyVar`, `DirectoryVar` and `PropertyState` interfaces and related methods.

  1. … 18 more files in changeset.
Address review items

- Fix two other providers that were not presenting a useful toString()

- Clarify comment that toString() should not realize a Provider's value

  1. … 6 more files in changeset.
Refine toString() on Provider types

- For each type of provider, show useful information that doesn't require realizing anything

- For Lockable properties, we show lock/unlock and the value (if available)

- For Collection properties, we show undefined/empty/defined, List/Set and element type

- For buildable providers, we show the producing task

- For mapped/combined providers, we show the relationships in a function-like way

This causes chains of providers to look something like:

buildable(:installTest, property(interface org.gradle.api.file.Directory, defined))

which reads as "a buildable property (built by :installTest) has type Directory and has been defined"

  1. … 13 more files in changeset.
Allow `ListProperty<T>` and `SetProperty<T>` properties to be set using any `Iterable<T>` or `Provider<Iterable<T>`, including through the Groovy DSL.

`ListProperty` and `SetProperty` no longer extend `Property`, as this type requires the same type to be used to set and query the property value.

Also added an (internal for now) lockable `SetProperty` implementation.

  1. … 25 more files in changeset.
Added conveniences to the Groovy DSL for setting a property of type `PropertyState<Directory>` or `PropertyState<RegularFile>` using a `File` instance.

  1. … 9 more files in changeset.
Added `ProviderFactory.listProperty()` method to allow a property of `List<T>` to be created.

    • -111
    • +29
    ./DefaultPropertyStateTest.groovy
  1. … 8 more files in changeset.
Added `Provider.getOrElse(T)` that returns the value of the provider or a default value, and `Provider.map(Transformer)` that returns a provider that maps the value of the provider using the given transformer function. This allows a new value to be derived lazily from some calculated value.

Changed the signature of `ProviderFactory.provider(Callable<T>)` to `provider(Callable<? extends T>)`.

    • -42
    • +127
    ./DefaultPropertyStateTest.groovy
  1. … 16 more files in changeset.
Added some validation to `PropertyState.set(Provider)` to fail when the given provider produces values that are not assignable to the property type.

    • -29
    • +87
    ./DefaultPropertyStateTest.groovy
  1. … 12 more files in changeset.
Tweaked error message when setting `PropertyState` to some incompatible value.

  1. … 2 more files in changeset.
Added some validation to `PropertyState.set()` to fail when a value is provided that is not compatible with the property's type.

  1. … 5 more files in changeset.
Only call a Provider's get or getOrNull once for a PropertyState

+review REVIEW-6532

  1. … 1 more file in changeset.
First-class support for mapping between extension and task properties (#1452)

First-class support for mapping between extension and task properties

    • -0
    • +119
    ./DefaultPropertyStateTest.groovy
  1. … 42 more files in changeset.