しかし、かなり古い質問ですが、問題http://jira.codehaus.org/browse/GROOVY-2505はまだ解決されていません... Apache StrSubstitutor クラスを使用して、GString 置換のように動作する優れた回避策があります。私にとっては、テンプレートを作成するよりも快適です。XML ファイルで GStrings を使用できます。
import org.apache.commons.lang.text.StrSubstitutor
strResTpl = new File(filePath + "example.xml").text
def extraText = "MY EXTRA TEXT"
map = new HashMap();
map.put("text_to_substitute", "example text - ${extraText}")
def result = new StrSubstitutor(map).replace(strResTpl);
XML ファイル:
<?xml version="1.0" encoding="UTF-8"?>
<eample>
<text_to_substitute>${text_to_substitute}</text_to_substitute>
</example>
結果:
<?xml version="1.0" encoding="UTF-8"?>
<eample>
<text_to_substitute>example text - MY EXTRA TEXT</text_to_substitute>
</example>