Example usage for org.apache.maven.cli.logging Slf4jStdoutLogger Slf4jStdoutLogger

List of usage examples for org.apache.maven.cli.logging Slf4jStdoutLogger Slf4jStdoutLogger

Introduction

In this page you can find the example usage for org.apache.maven.cli.logging Slf4jStdoutLogger Slf4jStdoutLogger.

Prototype

Slf4jStdoutLogger

Source Link

Usage

From source file:org.kie.workbench.common.services.backend.compiler.external339.AFMavenCli.java

License:Apache License

protected void cli(AFCliRequest cliRequest) throws Exception {
    ///*from  w w  w.  j ava 2s.c  om*/
    // Parsing errors can happen during the processing of the arguments and we prefer not having to check if
    // the logger is null and construct this so we can use an SLF4J logger everywhere.
    //

    slf4jLogger = new Slf4jStdoutLogger();

    CLIManager cliManager = new CLIManager();

    List<String> args = new ArrayList<String>();

    try {
        Path configFile = Paths.get(cliRequest.getMultiModuleProjectDirectory(), ".mvn/maven.config");

        if (java.nio.file.Files.isRegularFile(configFile)) {
            for (String arg : Files.toString(configFile.toFile(), Charsets.UTF_8).split("\\s+")) {
                args.add(arg);
            }

            CommandLine config = cliManager.parse(args.toArray(new String[args.size()]));
            List<?> unrecongized = config.getArgList();
            if (!unrecongized.isEmpty()) {
                throw new ParseException("Unrecognized maven.config entries: " + unrecongized);
            }
        }
    } catch (ParseException e) {
        System.err.println("Unable to parse maven.config: " + e.getMessage());
        cliManager.displayHelp(output);
        throw e;
    }

    try {
        args.addAll(0, Arrays.asList(cliRequest.getArgs()));
        cliRequest.setCommandLine(cliManager.parse(args.toArray(new String[args.size()])));
    } catch (ParseException e) {
        System.err.println("Unable to parse command line options: " + e.getMessage());
        cliManager.displayHelp(output);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        PrintStream ps = new PrintStream(baos);
        cliManager.displayHelp(ps);
        throw e;
    }

    if (cliRequest.getCommandLine().hasOption(CLIManager.HELP)) {
        cliManager.displayHelp(output);

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        PrintStream ps = new PrintStream(baos);
        cliManager.displayHelp(ps);
        throw new ExitException(0);
    }

    if (cliRequest.getCommandLine().hasOption(CLIManager.VERSION)) {
        System.out.println(AFCLIReportingUtils.showVersion());
        throw new ExitException(0);
    }
}

From source file:org.kie.workbench.common.services.backend.compiler.impl.external339.AFMavenCli.java

License:Apache License

protected void cli(AFCliRequest cliRequest) throws Exception {
    ///*from   w ww.j a v a  2 s.  c om*/
    // Parsing errors can happen during the processing of the arguments and we prefer not having to check if
    // the logger is null and construct this so we can use an SLF4J logger everywhere.
    //
    slf4jLogger = new Slf4jStdoutLogger();

    /** promoted as a class variable and single instance because with multiple instances
     * on moderate/heavy load the parse of the argumentsub produce mistakes */
    //CLIManager cliManager = new CLIManager();

    List<String> args = new ArrayList<String>();

    try {
        Path configFile = Paths.get(cliRequest.getMultiModuleProjectDirectory(), ".mvn/maven.config");

        if (java.nio.file.Files.isRegularFile(configFile)) {
            for (String arg : Files.toString(configFile.toFile(), Charsets.UTF_8).split("\\s+")) {
                args.add(arg);
            }

            CommandLine config = cliManager.parse(args.toArray(new String[args.size()]));
            List<?> unrecongized = config.getArgList();
            if (!unrecongized.isEmpty()) {
                throw new ParseException("Unrecognized maven.config entries: " + unrecongized);
            }
        }
    } catch (ParseException e) {
        System.err.println("Unable to parse maven.config: " + e.getMessage());
        cliManager.displayHelp(output);
        throw e;
    }

    try {
        args.addAll(0, Arrays.asList(cliRequest.getArgs()));
        cliRequest.setCommandLine(cliManager.parse(args.toArray(new String[args.size()])));
    } catch (ParseException e) {
        System.err.println("Unable to parse command line options: " + e.getMessage());
        cliManager.displayHelp(output);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        PrintStream ps = new PrintStream(baos);
        cliManager.displayHelp(ps);
        throw e;
    }

    if (cliRequest.getCommandLine().hasOption(CLIManager.HELP)) {
        cliManager.displayHelp(output);

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        PrintStream ps = new PrintStream(baos);
        cliManager.displayHelp(ps);
        throw new ExitException(0);
    }

    if (cliRequest.getCommandLine().hasOption(CLIManager.VERSION)) {
        System.out.println(AFCLIReportingUtils.showVersion());
        throw new ExitException(0);
    }
}

From source file:org.kie.workbench.common.services.backend.compiler.impl.external339.ReusableAFMavenCli.java

License:Apache License

protected void cli(AFCliRequest cliRequest) throws Exception {
    ///* www  .  j  a  va2s.c om*/
    // Parsing errors can happen during the processing of the arguments and we prefer not having to check if
    // the logger is null and construct this so we can use an SLF4J logger everywhere.
    //
    reusableSlf4jLogger = new Slf4jStdoutLogger();

    /** promoted as a class variable and single instance because with multiple instances
     * on moderate/heavy load the parse of the argumentsub produce mistakes */
    //CLIManager cliManager = new CLIManager();

    List<String> args = new ArrayList<String>();

    try {
        Path configFile = Paths.get(cliRequest.getMultiModuleProjectDirectory(), ".mvn/maven.config");

        if (java.nio.file.Files.isRegularFile(configFile)) {
            for (String arg : Files.toString(configFile.toFile(), Charsets.UTF_8).split("\\s+")) {
                args.add(arg);
            }

            CommandLine config = cliManager.parse(args.toArray(new String[args.size()]));
            List<?> unrecongized = config.getArgList();
            if (!unrecongized.isEmpty()) {
                throw new ParseException("Unrecognized maven.config entries: " + unrecongized);
            }
        }
    } catch (ParseException e) {
        System.err.println("Unable to parse maven.config: " + e.getMessage());
        cliManager.displayHelp(output);
        throw e;
    }

    try {
        args.addAll(0, Arrays.asList(cliRequest.getArgs()));
        cliRequest.setCommandLine(cliManager.parse(args.toArray(new String[args.size()])));
    } catch (ParseException e) {
        System.err.println("Unable to parse command line options: " + e.getMessage());
        cliManager.displayHelp(output);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        PrintStream ps = new PrintStream(baos);
        cliManager.displayHelp(ps);
        throw e;
    }

    if (cliRequest.getCommandLine().hasOption(CLIManager.HELP)) {
        cliManager.displayHelp(output);

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        PrintStream ps = new PrintStream(baos);
        cliManager.displayHelp(ps);
        throw new ExitException(0);
    }

    if (cliRequest.getCommandLine().hasOption(CLIManager.VERSION)) {
        System.out.println(AFCLIReportingUtils.showVersion());
        throw new ExitException(0);
    }
}