Fix excluding tasks using -x command line option that are a dependency of multiple tasks .

Fixes GRADLE-2974 and GRADLE-3031.
Merge pull request #250 from erdi/exclude-task-fix

Fix for GRADLE-2974 and GRADLE-3031