use of scala_maven_executions.LogProcessorUtils.LevelState in project scala-maven-plugin by davidB.
the class JavaMainCallerByFork method run.
@Override
public boolean run(boolean displayCmd, boolean throwFailure) throws Exception {
List<String> cmd = buildCommand();
displayCmd(displayCmd, cmd);
Executor exec = new DefaultExecutor();
// err and out are redirected to out
if (!_redirectToLog) {
exec.setStreamHandler(new PumpStreamHandler(System.out, System.err, System.in));
} else {
exec.setStreamHandler(new PumpStreamHandler(new LogOutputStream() {
private LevelState _previous = new LevelState();
@Override
protected void processLine(String line, int level) {
try {
_previous = LogProcessorUtils.levelStateOf(line, _previous);
switch(_previous.level) {
case ERROR:
requester.getLog().error(line);
break;
case WARNING:
requester.getLog().warn(line);
break;
default:
requester.getLog().info(line);
break;
}
} catch (Exception e) {
e.printStackTrace();
}
}
}));
}
CommandLine cl = new CommandLine(cmd.get(0));
for (int i = 1; i < cmd.size(); i++) {
cl.addArgument(cmd.get(i), false);
}
try {
int exitValue = exec.execute(cl);
if (exitValue != 0) {
if (throwFailure) {
throw new MojoFailureException("command line returned non-zero value:" + exitValue);
}
return false;
}
if (!displayCmd)
tryDeleteArgFile(cmd);
return true;
} catch (ExecuteException exc) {
if (throwFailure) {
throw exc;
}
return false;
}
}
use of scala_maven_executions.LogProcessorUtils.LevelState in project scala-maven-plugin by davidB.
the class LogProcessorUtilsTest method jdkSplit.
@Test
public void jdkSplit() throws Exception {
LevelState previous = new LevelState();
previous = assertLevelState("/home/hub/p/eee/src/main/scala:-1: info: compiling", previous, Level.INFO, null);
previous = assertLevelState("Compiling 128 source files to /home/hub/p/eee/target/classes at 1312794546514", previous, Level.INFO, null);
previous = assertLevelState("Recompiling 1 files", previous, Level.INFO, null);
previous = assertLevelState("/home/hub/p/eee/src/main/scala/Service.scala:72: error: type mismatch;", previous, Level.ERROR, "^");
previous = assertLevelState("found : Unit", previous, Level.ERROR, "^");
previous = assertLevelState("required: () => Any", previous, Level.ERROR, "^");
previous = assertLevelState("f()", previous, Level.ERROR, "^");
previous = assertLevelState(" ^", previous, Level.ERROR, null);
previous = assertLevelState("/home/hub/p/eee/src/main/scala/src/main/scala/Service.scala:79: error: type mismatch;", previous, Level.ERROR, "^");
previous = assertLevelState("found : Unit", previous, Level.ERROR, "^");
previous = assertLevelState("required: () => Any", previous, Level.ERROR, "^");
previous = assertLevelState("f()", previous, Level.ERROR, "^");
previous = assertLevelState("^", previous, Level.ERROR, null);
previous = assertLevelState("two errors found", previous, Level.ERROR, null);
previous = assertLevelState("------------------------------------------------------------------------", previous, Level.INFO, null);
previous = assertLevelState("BUILD ERROR", previous, Level.ERROR, null);
previous = assertLevelState("------------------------------------------------------------------------", previous, Level.INFO, null);
previous = assertLevelState("wrap: org.apache.commons.exec.ExecuteException: Process exited with an error: 1(Exit value: 1)", previous, Level.ERROR, null);
}
use of scala_maven_executions.LogProcessorUtils.LevelState in project scala-maven-plugin by davidB.
the class LogProcessorUtilsTest method assertLevelState.
private LevelState assertLevelState(String input, LevelState previous, Level expectedLevel, String expectedUntilContains) throws Exception {
LevelState back = LogProcessorUtils.levelStateOf(input, previous);
assertEquals(expectedLevel, back.level);
assertEquals(expectedUntilContains, back.untilContains);
return back;
}
Aggregations