Those few lines are following various bad practices anyway.
But to focus on the question, the project(...)
call is done on project
which is what the warning complains about.
You could for example move the calculation of the argument for from
to configuration time by moving it outside the doLast
and storing the result in a local variable.