fix null pointer exception when build directory doesn't exist
plugin: extract getMainSourceSet and getTestSourceSet methods