Created
August 15, 2012 18:20
-
-
Save irof/3362135 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
RubyでJavaのpackage-info.javaを一括生成するスクリプト | |
http://d.hatena.ne.jp/tbpg/20120808/1344447924 | |
をGroovyにしてみた。 |
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_DIR = './src' | |
def detail = '// TODO パッケージ内容の詳細を記述してください' | |
def generate_package_info_code = { name -> | |
"""\ | |
/** | |
* ${name}パッケージ。 | |
* | |
* <pre> | |
* ${detail} | |
* </pre> | |
* | |
*/ | |
package ${name}; | |
""" | |
} | |
def root = new File(SOURCE_DIR) | |
root.eachDirRecurse { | |
if (it == root) return | |
def name = (it.toString() - SOURCE_DIR)[1..-1].tr('/', '.') | |
def code = generate_package_info_code(name) | |
new File(it, PACKAGE_INFO).write(code) | |
} | |
println "出力完了。出力結果" | |
root.eachFileRecurse { | |
if (it.name == PACKAGE_INFO) println it | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment