Gradle Build - "catch task"?

when i run the gradle build task
what can i add to the build.gradle file so it will
go through a “function” or something like that?