refactor to support 'gradle run'