Answering my own question after hours of hacking ...
<script language="groovy" src="build.groovy" />
and this groovy script replaces any associated javascript or css file with the contents of the file itself.
f = new File("${targetDir}/index.cfm")
fContent = f.text
fContent = jsReplace(fContent)
fContent = cssReplace(fContent)
f.write(fContent)
def jsReplace(htmlFileText) {
println "Groovy: Replacing Javascript includes"
def jsRegex = /<script [^>]*src=\"([^\"]+)\"><\/script>/
def matcher = (htmlFileText =~ jsRegex)
for (i in matcher) {
def includeText = new File(matcher.group(1)).text
includeText = java.util.regex.Matcher.quoteReplacement(includeText)
includeText = includeText.replaceAll(/\/\/.*/, "")
includeText = includeText.replaceAll(/[\n\r\f\s]+/, " ")
htmlFileText = htmlFileText.replaceFirst('<script [^>]*src="'+ matcher.group(1) +'"[^>]*></script>', '<script type="text/javascript">'+ includeText+'</script>');
}
return htmlFileText;
}
def cssReplace(htmlFileText) {
println "Groovy: Replacing CSS includes"
def cssRegex = /<link [^>]*href=\"([^\"]+)\"[^>]*>(<\/link>)?/
def matcher = (htmlFileText =~ cssRegex)
for (i in matcher) {
def includeText = new File(matcher.group(1)).text
includeText = includeText.replaceAll(/[\n\r\t\f\s]+/, " ")
includeText = java.util.regex.Matcher.quoteReplacement(includeText)
htmlFileText = htmlFileText.replaceFirst('<link [^>]*href="'+ matcher.group(1) +'"[^>]*>(<\\/link>)?', '<style type=\"text/css\">'+ includeText+'</style>');
}
return htmlFileText;
}
, , . , . , groovy -, . , . , , javax.scripting engine, groovy -engine.jar groovy -all-1.5.6.jar