Gradle has a configuration phase and an execution phase. In the configuration phase, all tasks will get configured. In the execution phase, only a subset of tasks will get executed. Your ‘println’ statements are configuring the tasks. Everything that the task is supposed to do at execution time needs to be wrapped in ‘doFirst { … }’ or ‘doLast { … }’. (For the latter, there is a ‘<<’ shortcut syntax, but using ‘doLast { … }’ is less error prone.) The Gradle User Guide has more on this.
‘println’'s are logged on level ‘quiet’, hence they are even shown when running with ‘-q’. You can log using a lesser logging level with ‘log.debug’, ‘log.info’, or ‘log.lifecycle’.