Uploaded image for project: 'Gradle'
  1. Gradle
  2. GRADLE-2863

Private method calls of DSL enhanced objects may not work correctly

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Resolution: Fixed
    • Affects Version/s: 1.7
    • Fix Version/s: 1.8-rc-1
    • Known Issue Of:
      1.7

      Description

      In certain circumstances, calling private methods inside DSL enhanced objects (typically either Task implementations or extensions) will produce strange results. This only affects classes implemented in Groovy.

      There are two known issues:

      1. Method arguments are not type coerced according to normal Groovy rules (e.g. GStrings automatically converted to strings)
      2. Checked exceptions thrown by the called method will be wrapped in a GradleException (a runtime exception)

      The workaround for this is to:

      1. Factor the private method out of the decorated class
      2. Ensure that the method is called with accurately typed parameters (i.e. all arguments are strongly typed and are assignment compatible with their associated parameter type)

      #2 Can be said another way as: the method call should succeed according to Java semantics, not Groovy semantics.

        Attachments

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            ldaley Luke Daley
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: