"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const childProcess = require('child_process');
const fs = require('fs');
const path = require('path');
function gradle(callback) {
    if (fs.existsSync('liferay/build.gradle')) {
        const gradlePath = process.env.GRADLE_HOME ? process.env.GRADLE_HOME + path.sep + 'bin'
            + path.sep + 'gradle' : 'gradle';
        const codegen = childProcess.spawn(gradlePath + ' --no-daemon compileJava', { cwd: process.cwd() + '/liferay', shell: true });
        codegen.stdout.on('data', (data) => {
            console.log(data.toString());
        });
        codegen.stderr.on('data', (data) => {
            console.error(data.toString());
        });
        codegen.on('close', (code) => {
            if (callback) {
                if (code && code === 0) {
                    return callback();
                }
                return callback(code);
            }
        });
    }
    else {
        if (callback) {
            return callback();
        }
    }
}
exports.gradle = gradle;
function watch(callback) {
    if (fs.existsSync('liferay/build.gradle')) {
        fs.watch('liferay/src/main/java', { recursive: true }, () => {
            return gradle(callback);
        });
    }
}
exports.watch = watch;
//# sourceMappingURL=/home/ddavis/Projects/xtivia/speedray/speedray-cli/lib/speedray/gradle.js.map