Created
August 16, 2012 16:03
-
-
Save fumokmm/3371341 to your computer and use it in GitHub Desktop.
GroovyでJavaのpackage-info.javaを一括生成するスクリプト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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