Skip to content

Commit 1c85bea

Browse files
ctruedengselzer
authored andcommitted
generate.groovy: add a simple debug mode
1 parent 1625d0b commit 1c85bea

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

bin/generate.groovy

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@
2929
* #L%
3030
*/
3131

32+
debug = System.getenv('DEBUG')
33+
def debug(msg) {
34+
if (debug) System.err.println("[DEBUG] $msg")
35+
}
36+
3237
@Grab('org.apache.velocity:velocity:1.7')
3338
import org.apache.velocity.app.VelocityEngine
3439

@@ -48,6 +53,8 @@ def timestamp(dir, file) {
4853

4954
/* Processes a template using Apache Velocity. */
5055
def processTemplate(engine, context, templateFile, outFilename) {
56+
debug("processTemplate('$engine', '$context', '$templateFile', '$outFilename')")
57+
5158
if (outFilename == null) return; // nothing to do
5259

5360
// create output directory if it does not already exist
@@ -89,6 +96,8 @@ def parseValue(sh, translationsFile, key, expression) {
8996
* ...
9097
*/
9198
def translate(templateSubdirectory, templateFile, translationsFile) {
99+
debug("translate('$templateSubdirectory', '$templateFile', '$translationsFile')")
100+
92101
// initialize the Velocity engine
93102
engine = new org.apache.velocity.app.VelocityEngine();
94103
p = new java.util.Properties();
@@ -181,6 +190,8 @@ def translate(templateSubdirectory, templateFile, translationsFile) {
181190

182191
/* Recursively translates all templates in the given directory. */
183192
def translateDirectory(templateSubdirectory) {
193+
debug("translateDirectory('$templateSubdirectory')")
194+
184195
for (file in new java.io.File(templateSubdirectory).listFiles()) {
185196
if (file.isDirectory()) {
186197
// process subdirectories recursively

0 commit comments

Comments
 (0)