Gradle.build path

Hi for everyone. I have next tree of my project:

messages/
build.gradle
settings.gradle
consumer/
build.gradle
producer/
build.gradle

In file “settings.gradle” i have next:
include ‘consumer’, ‘producer’

I want to perform certain actions when I call the “gradle build” command in the “consumer” directory and other specific actions if I call this command from the “producer” directory. How do I know which directory the “gradle build” command was called from? Or maybe you know another approach for resolve this problem. Thanks for the help.