* @param out the writer where the data must be written
* @throws IOException
*/
public static void compressJS(Reader in, Writer out) throws IOException{
try {
JavaScriptCompressor compressor = new JavaScriptCompressor(in, new ErrorReporter() {
public void warning(String message, String sourceName,
int line, String lineSource, int lineOffset) {
LOG.warn("[JAVASCRIPT COMPRESSOR WARN] in file : "+sourceName+"\n"+message+"\n"+line+":"+lineOffset);
}
public void error(String message, String sourceName,
int line, String lineSource, int lineOffset) {
LOG.error("[JAVASCRIPT COMPRESSOR ERROR] in file : "+sourceName+"\nLine : "+lineSource+"\n"+message+"\n"+line+":"+lineOffset);
}
public EvaluatorException runtimeError(String message, String sourceName,
int line, String lineSource, int lineOffset) {
error(message, sourceName, line, lineSource, lineOffset);
return new EvaluatorException(message);
}
});
compressor.compress(out, LINE_BREAK_POS, true, true,
true, true);
} catch (EvaluatorException e) {
LOG.error("YUICompressorAdaptor.compressJS Failed!", e);
}