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

Support Kotlin trailing lambda syntax for custom output formatters #690

Merged
merged 4 commits into from Sep 11, 2022

Commits on Sep 11, 2022

  1. Support Kotlin trailing lambda syntax for custom output formatters

    * This is done by offering a new API in which an output formatter can be specified as org.gradle.api.Action<Result>. Gradle automatically maps Groovy closures and Kotlin lambdas to arguments of that type (https://docs.gradle.org/current/userguide/kotlin_dsl.html#groovy_closures_from_kotlin).
    
    * Internally, there have been some changes done to support this:
      - The type of the property that is used to set an output formatter is `Any`, and this isn't the nicer because tooling can't really hint users of the API with the correct types, and we also have to deal manually with the types of input.
      - The new type we wanted to support (Action<Result>) would run into type erasure problems if we used this existing property and we would need to have code casting the types in an unsafe way (as we can't know if a provided argument is Action<Result> or Action of something else).
      - To sort this out, we have kept the existing property for compatibility reasons (it can still be used to set String, Reporter or Closure output formatters) but we have added a new function to set Action<Result> output formatters. With this we achieve maintaining public API compatibility whilst adding support for the new Action<Result> output formatters with improved type support (internally, safe use of types, and externally, type hinting in tooling and clear public API signature).
    vjgarciag96 committed Sep 11, 2022
    Configuration menu
    Copy the full SHA
    08237b0 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    79a9736 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    5b30afc View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    3724f78 View commit details
    Browse the repository at this point in the history