psiroky commented on code in PR #58: URL: https://github.com/apache/maven-invoker/pull/58#discussion_r1044522392
########## src/main/java/org/apache/maven/shared/invoker/DefaultInvoker.java: ########## @@ -63,99 +58,78 @@ private InvocationOutputHandler errorHandler = DEFAULT_OUTPUT_HANDLER; /** {@inheritDoc} */ - public InvocationResult execute( InvocationRequest request ) - throws MavenInvocationException - { + public InvocationResult execute(InvocationRequest request) throws MavenInvocationException { MavenCommandLineBuilder cliBuilder = new MavenCommandLineBuilder(); - if ( logger != null ) - { - cliBuilder.setLogger( logger ); + if (logger != null) { + cliBuilder.setLogger(logger); } - if ( localRepositoryDirectory != null ) - { - cliBuilder.setLocalRepositoryDirectory( localRepositoryDirectory ); + if (localRepositoryDirectory != null) { + cliBuilder.setLocalRepositoryDirectory(localRepositoryDirectory); } - if ( mavenHome != null ) - { - cliBuilder.setMavenHome( mavenHome ); + if (mavenHome != null) { + cliBuilder.setMavenHome(mavenHome); } - if ( mavenExecutable != null ) - { - cliBuilder.setMavenExecutable( mavenExecutable ); + if (mavenExecutable != null) { + cliBuilder.setMavenExecutable(mavenExecutable); } - if ( workingDirectory != null ) - { - cliBuilder.setBaseDirectory( workingDirectory ); + if (workingDirectory != null) { + cliBuilder.setBaseDirectory(workingDirectory); } Commandline cli; - try - { - cli = cliBuilder.build( request ); - } - catch ( CommandLineConfigurationException e ) - { - throw new MavenInvocationException( "Error configuring command line", e ); + try { + cli = cliBuilder.build(request); + } catch (CommandLineConfigurationException e) { + throw new MavenInvocationException("Error configuring command line", e); } DefaultInvocationResult result = new DefaultInvocationResult(); - try - { - int exitCode = executeCommandLine( cli, request, request.getTimeoutInSeconds() ); + try { + int exitCode = executeCommandLine(cli, request, request.getTimeoutInSeconds()); - result.setExitCode( exitCode ); - } - catch ( CommandLineException e ) - { - result.setExecutionException( e ); + result.setExitCode(exitCode); + } catch (CommandLineException e) { + result.setExecutionException(e); } return result; } - private int executeCommandLine( Commandline cli, InvocationRequest request, int timeoutInSeconds ) - throws CommandLineException - { + private int executeCommandLine(Commandline cli, InvocationRequest request, int timeoutInSeconds) + throws CommandLineException { int result; - InputStream inputStream = request.getInputStream( this.inputStream ); - InvocationOutputHandler outputHandler = request.getOutputHandler( this.outputHandler ); - InvocationOutputHandler errorHandler = request.getErrorHandler( this.errorHandler ); + InputStream inputStream = request.getInputStream(this.inputStream); + InvocationOutputHandler outputHandler = request.getOutputHandler(this.outputHandler); + InvocationOutputHandler errorHandler = request.getErrorHandler(this.errorHandler); - if ( getLogger().isDebugEnabled() ) - { - getLogger().debug( "Executing: " + cli ); + if (getLogger().isDebugEnabled()) { + getLogger().debug("Executing: " + cli); } - if ( request.isBatchMode() ) - { - if ( inputStream != null ) - { - getLogger().info( "Executing in batch mode. The configured input stream will be ignored." ); + if (request.isBatchMode()) { + if (inputStream != null) { + getLogger().info("Executing in batch mode. The configured input stream will be ignored."); } - result = CommandLineUtils.executeCommandLine( cli, outputHandler, errorHandler, timeoutInSeconds ); - } - else - { - if ( inputStream == null ) - { - getLogger().warn( "Maven will be executed in interactive mode" - + ", but no input stream has been configured for this MavenInvoker instance." ); - - result = CommandLineUtils.executeCommandLine( cli, outputHandler, errorHandler, timeoutInSeconds ); - } - else - { - result = CommandLineUtils.executeCommandLine( cli, inputStream, outputHandler, errorHandler, - timeoutInSeconds ); + result = CommandLineUtils.executeCommandLine(cli, outputHandler, errorHandler, timeoutInSeconds); + } else { + if (inputStream == null) { + getLogger() + .warn("Maven will be executed in interactive mode" + + ", but no input stream has been configured for this MavenInvoker instance."); + + result = CommandLineUtils.executeCommandLine(cli, outputHandler, errorHandler, timeoutInSeconds); + } else { + result = CommandLineUtils.executeCommandLine( + cli, inputStream, outputHandler, errorHandler, timeoutInSeconds); Review Comment: Hmm, this is not exactly pretty, but maybe that's just my view. Spotless thinks this the way to go I guess. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org