This does not apply to Rake, it is simply a consequence of the lexical scope and how Ruby handles local variables, declaring them the first time they are used.
First you assign a value path:
path = "/home/tomcat/tomcat"
stage :
path = "/home/tomcat/stage-tomcat"
, , - .
java_deploy, . path, , .
, production . , :
path = "/home/tomcat/production-tomcat"
, path, , /home/tomcat/production-tomcat.
path, . , path ( ) .