2010年4月1日木曜日

grails scriptに日本語のコメントを入れると落ちる件

プラグイン作成に手を出してたりします。
あんな機能やこんな機能を分離できたりして楽しげ。後々他でも使えそうな機能はプラグイン化しとくと役に立つかも…などと思い、色々試してるところ。
そんな中で起きたトラブル。自作のコマンドを作るためにスクリプトをいじってたところ、何故かエラー。何もないのにエラー。
Error executing script CreateMail: No such property: name for class: CreateMail
gant.TargetMissingPropertyException: No such property: name for class: CreateMa
l
at gant.Gant$_dispatch_closure4.doCall(Gant.groovy:329)
at gant.Gant$_dispatch_closure6.doCall(Gant.groovy:334)
at gant.Gant$_dispatch_closure6.doCall(Gant.groovy)
at gant.Gant.withBuildListeners(Gant.groovy:344)
at gant.Gant.this$2$withBuildListeners(Gant.groovy)
at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source)
at gant.Gant.dispatch(Gant.groovy:334)
at gant.Gant.this$2$dispatch(Gant.groovy)
at gant.Gant.invokeMethod(Gant.groovy)
at gant.Gant.processTargets(Gant.groovy:495)
at gant.Gant.processTargets(Gant.groovy:480)
Caused by: groovy.lang.MissingPropertyException: No such property: name for cla
s: CreateMail
at CreateMail$_run_closure1.doCall(CreateMail:15)
at gant.Gant$_dispatch_closure4.doCall(Gant.groovy:324)
... 10 more
Error executing script CreateMail: No such property: name for class: CreateMail

一体全体何が起きてるんだ? と、試行錯誤すること1時間強。出た結論としては、どうやらスクリプト中に入力していたコメントが問題だったらしい。
//コメでコメント末尾が全角だとエラーになるらしい。バグなのかな、これ…。
※/* */でも再現。どうやらコメント末尾が全角だとスクリプトの翻訳でコケてるくさい。

こんな感じ。
×:// そんなに日本語が嫌いか!!
※末尾に半角スペースくっつけてやると通るっぽい?
○:// そんなに日本語が嫌いか!!a
×:/*そんなに日本語が嫌いか!!*/

3 件のコメント:

はじめ さんのコメント...

UTF-8でBOMがついていたりすると、こういう不可思議な事が起きたりしますね。

RaTTiE さんのコメント...

あれ? ホントですね、確かにBOMが付いてます。
どこで混じったんだろう…テンプレートに含んでるという訳でもないので、何かの拍子でこっそり混じっていたとか。
ともあれ、情報ありがとうございました。

RaTTiE さんのコメント...

前言撤回。
やはり、BOMが付いてなくても現象が再現する模様。
再現するのはスクリプトだけ…のはず。