I'm building Gradle script that runs Tomcat (sadly I cannot use Gretty or Cargo plugin). After launching Tomcat ($TOMCAT_HOME/bin/startup.sh
) I want to open file in Gradle/Groovy and then print all lines that comes in, another words: open file, track if smt new has came, print it.
Now my task looks like that:
task startTomcat(dependsOn: ...) << {
def catalinaOut = "${project.TOMCAT_HOME}/logs/catalina.out"
delete { catalinaOut }
exec {
workingDir '.'
executable "${project.TOMCAT_HOME}/bin/${tomcatStartScript()}"
environment CATALINA_OPTS: tomcatArgs.join(' ')
}
new File(catalinaOut).eachLine { line -> println(line) }
}
Of course it won't work because new File
opens and immediately closes file.