Search in sources :

Example 1 with PrintStreamLogger

use of org.apache.maven.shared.invoker.PrintStreamLogger in project syncope by apache.

the class MavenUtils method invoke.

private InvocationResult invoke(final InvocationRequest request, final String path) {
    InvocationResult result = null;
    final Invoker invoker = new DefaultInvoker();
    try {
        invoker.setLogger(new PrintStreamLogger(new PrintStream(InstallLog.getInstance().getFileAbsolutePath()), 1000));
        invoker.setOutputHandler(new PrintStreamHandler(new PrintStream(InstallLog.getInstance().getFileAbsolutePath()), true));
        invoker.setWorkingDirectory(new File(path));
        result = invoker.execute(request);
    } catch (MavenInvocationException | FileNotFoundException ex) {
        final String messageError = "Maven exception: " + ex.getMessage();
        handler.emitError(messageError, messageError);
        InstallLog.getInstance().info(messageError);
    }
    return result;
}
Also used : PrintStream(java.io.PrintStream) Invoker(org.apache.maven.shared.invoker.Invoker) DefaultInvoker(org.apache.maven.shared.invoker.DefaultInvoker) PrintStreamLogger(org.apache.maven.shared.invoker.PrintStreamLogger) MavenInvocationException(org.apache.maven.shared.invoker.MavenInvocationException) DefaultInvoker(org.apache.maven.shared.invoker.DefaultInvoker) FileNotFoundException(java.io.FileNotFoundException) InvocationResult(org.apache.maven.shared.invoker.InvocationResult) File(java.io.File) PrintStreamHandler(org.apache.maven.shared.invoker.PrintStreamHandler)

Aggregations

File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 PrintStream (java.io.PrintStream)1 DefaultInvoker (org.apache.maven.shared.invoker.DefaultInvoker)1 InvocationResult (org.apache.maven.shared.invoker.InvocationResult)1 Invoker (org.apache.maven.shared.invoker.Invoker)1 MavenInvocationException (org.apache.maven.shared.invoker.MavenInvocationException)1 PrintStreamHandler (org.apache.maven.shared.invoker.PrintStreamHandler)1 PrintStreamLogger (org.apache.maven.shared.invoker.PrintStreamLogger)1