Does Gradle, similar to Ruby's Rake, allow the build configuration for a single project to be organized in multiple files?

Basically, as mentioned in Rake’s docs:

Multiple Rake Files

Not all tasks need to be included in a single Rakefile. Additional rake files (with the file extension “.rake”) may be placed in rakelib directory located at the top level of a project (i.e. the same directory that contains the main Rakefile).

Also, rails projects may include additional rake files in the lib/tasks directory.

I want to define helped methods outside of my build.gradle file. Similarly, if supported by Gradle, I want various task groups to be in their own specific file. For example:

  • build.gradle
  • tasks/build
  • tasks/distribution
  • tasks/publish
  • etc.

Thanks in advance.

Yes! Just use apply from: ‘otherfile.gradle’.

Here’s a good example of a project that does just that https://github.com/eriwen/gradle-digest-plugin?files=1

Cheers,
Eric

1 Like