Allow generation of source code to a specified directory. If cached classes are being used and source directory is specified, source is generated to that directory. If cached classes are used and the source directory is not specified, source is not generated. Also cleaned up some state that wasn't getting reset between tests, causing the gradle build to fail.