lib/plugins/aws/invokeLocal/index.js/AwsInvokeLocal/invokeLocalJava
class AwsInvokeLocal:  invokeLocalJava(runtime, className, handlerName, artifactPath, event, customContext) {
    const timeout = Number(this.options.functionObj.timeout)
      || Number(this.serverless.service.provider.timeout)
      || 6;
    const context = {
      name: this.options.functionObj.name,
      version: 'LATEST',
      logGroupName: this.provider.naming.getLogGroupName(this.options.functionObj.name),
      timeout,
    };
    const input = JSON.stringify({
      event: event || {},
      context: customContext || context,
    });

    const javaBridgePath = path.join(__dirname, 'java');
    const executablePath = path.join(javaBridgePath, 'target');

    return new BbPromise(resolve => fs.statAsync(executablePath)
      .then(() => this.callJavaBridge(artifactPath, className, handlerName, input))
      .then(resolve)
      .catch(() => {
        const mvn = spawn('mvn', [
          'package',
          '-f',
          path.join(javaBridgePath, 'pom.xml'),
        ], { shell: true });

        this.serverless.cli
          .log('Building Java bridge, first invocation might take a bit longer.');

        mvn.stderr.on('data', (buf) => this.serverless.cli.consoleLog(`mvn - ${buf.toString()}`));
        mvn.stdin.end();

        mvn.on('close', () => this.callJavaBridge(artifactPath, className, handlerName, input)
          .then(resolve));
      }));
  }