Proper usage of project Exec method

I think you’re trying to call https://docs.gradle.org/current/javadoc/org/gradle/api/Project.html#exec-org.gradle.api.Action-, but your method is static def, so there’s no instance of project is available on that level of your build script.

Potential solutions:

  • inline your method so that the processMailTemplates configuration closure provides you with Task#project
  • make def non-static, so you get Project#project from the buildscript’s context
  • modify the signature to static def inlineCss(Project project, src, dest) and use project.exec ...;
    simply pass in project inside your each that will access Task#project from the configuration closure.

Note: to access Project#project or Task#project in the script you just say project there’s no need for qualification the Groovy compiler will figure out which closure can resolve it, but it’s helpful to know what you’re actually accessing, for example so you can look up the docs.

1 Like