Skip to content

Instantly share code, notes, and snippets.

@fumokmm
Created August 16, 2012 16:03
Show Gist options
  • Save fumokmm/3371341 to your computer and use it in GitHub Desktop.
Save fumokmm/3371341 to your computer and use it in GitHub Desktop.
GroovyでJavaのpackage-info.javaを一括生成するスクリプト
def PACKAGE_INFO = 'package-info.java'
def SOURCE_ROOT_DIR = './src'
def template = { pkg -> """\
/**
* ${pkg}パッケージ。
*
* <pre>
* // TODO パッケージ内容の詳細を記述してください
* </pre>
*
*/
package ${pkg};
""" }
def root = new File(SOURCE_ROOT_DIR)
root.eachDirRecurse{ dir ->
def pkg = dir.canonicalPath.substring(root.canonicalPath.size()+1).tr(File.separator, '.')
new File(dir, PACKAGE_INFO).write(template(pkg))
}
println '出力完了。出力結果'
root.eachFileRecurse(groovy.io.FileType.FILES) { file ->
if (file.name == PACKAGE_INFO) println file.path
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment