refactoring build files

http://stackoverflow.com/a/24103453/605582