Improved algorithm to determine goal invocation. Goals can be only
invoked by cli or build