Example usage for org.apache.maven.plugin.logging Log info

List of usage examples for org.apache.maven.plugin.logging Log info

Introduction

In this page you can find the example usage for org.apache.maven.plugin.logging Log info.

Prototype

void info(Throwable error);

Source Link

Document

Send an exception to the user in the info error level.
The stack trace for this exception will be output when this error level is enabled.

Usage

From source file:com.ericsson.tools.cpp.tools.LoggingCliExecutor.java

License:Apache License

public LoggingCliExecutor(final Log log) {
    super(log);//from  w w  w.j a  v a  2  s  .com

    setStdOutConsumer(new StreamConsumer() {
        @Override
        public void consumeLine(String line) {
            log.info(line);
        }
    });

    setStdErrConsumer(new StreamConsumer() {
        @Override
        public void consumeLine(String line) {
            log.warn(line);
        }
    });
}

From source file:com.expedia.tesla.tools.mojo.CompileMojo.java

License:Apache License

@Override
public void execute() throws MojoExecutionException {
    Log log = getLog();

    log.info("Generating source code from Tesla schemas.");
    log.debug(String.format("language: %s", language));
    log.debug(String.format("outputDir: %s", outputDir));
    log.debug(String.format("classTemplate: %s", classTemplate));
    log.debug(String.format("enumTemplate: %s", enumTemplate));
    log.debug(String.format("serializerTemplate: %s", serializerTemplate));
    log.debug(String.format("generateTypes: %s", generateTypes ? "yes" : "no"));
    PrintStream os = new PrintStream(new ByteArrayOutputStream());
    MapUtils.debugPrint(os, null, extension);
    log.debug(String.format("extension: %s", os.toString()));
    try {/*from  ww  w  . ja v  a  2s  . c  o m*/
        Compiler compiler = new Compiler();
        compiler.setLanguage(language);
        compiler.setOutputDir(outputDir);
        compiler.setAppSchemaClassName(serializerClassName);
        if (serializerTemplate != null) {
            compiler.setAppSchemaTemplatePath(serializerTemplate.getAbsolutePath());
        }
        compiler.setNotGenerateUserTypes(!generateTypes);
        if (classTemplate != null) {
            compiler.setClassTemplatePath(classTemplate.getAbsolutePath());
        }
        if (enumTemplate != null) {
            compiler.setEnumTemplatePath(enumTemplate.getAbsolutePath());
        }
        compiler.setExtension(extension);
        compiler.setSchemaFiles(getTmlFiles());
        compiler.compile();
    } catch (Exception e) {
        throw new MojoExecutionException("Failed to generate Tesla schema from Java.", e);
    }
    log.info("Generated source code from Tesla schemas successfully.");
}

From source file:com.expedia.tesla.tools.mojo.GenerateSchemaMojo.java

License:Apache License

public void execute() throws MojoExecutionException {
    Log log = getLog();
    try {/*from   www  .j  ava 2 s. c om*/
        classpath += StringUtils.join(project.getCompileClasspathElements(),
                System.getProperty("path.separator"));
    } catch (DependencyResolutionRequiredException e) {
        throw new MojoExecutionException("Failed to resolve project dependencies: " + e.getMessage(), e);
    }

    if (outputTml == null) {
        log.warn("Output is not set, using default value 'output.tml'.");
        outputTml = new File("output.tml");
    }

    log.info("Generating Tesla schema.");
    log.debug(String.format("classpath: %s", classpath));
    log.debug(String.format("Classes: %s", Arrays.toString(this.classes.toArray())));
    log.debug(String.format("Schema version name: %s", schemaVersion.getName()));
    log.debug(String.format("Schema version number: %s", schemaVersion.getVersionNumber()));
    log.debug(String.format("Output: %s", outputTml));
    OutputStream os = null;
    try {
        Util.forceMkdirParent(outputTml);
        os = new FileOutputStream(outputTml);
        SchemaGenerator.genTml(classes,
                new SchemaVersion(0L, schemaVersion.getVersionNumber(), schemaVersion.getName(), null), os,
                classpath);
    } catch (Exception e) {
        throw new MojoExecutionException("Failed to generate Tesla schema from Java.", e);
    } finally {
        if (os != null) {
            try {
                os.close();
            } catch (IOException e) {
                // ignore
            }
        }
    }
    log.info("Generated Tesla schema successfully.");
}

From source file:com.flexdms.htmltemplate.HtmlTemplateMojo.java

License:Apache License

public void execute() throws MojoExecutionException {

    Log log = getLog();

    try {//www  . ja  va2s .  c  o m
        String template = null;
        if (templateFile != null) {
            log.info("reading template file" + templateFile.getAbsolutePath());
            template = FileUtils.readFileToString(templateFile);
        } else {
            template = IOUtils.toString(HtmlTemplateMojo.class.getClassLoader()
                    .getResourceAsStream("com/flexdms/htmltemplate/tpl.js"));
            log.info("Using default template ");

            log.info(template);
        }

        log.info("srcDirectory is " + srcDirectory.getAbsolutePath());
        if (!srcDirectory.exists()) {
            log.info("SrcDirectory does not exist");
        }
        Scanner scanner = buildContext.newScanner(srcDirectory, true);
        scanner.scan();
        //scanner.setIncludes(new String[] { "**/*.html" });
        String files[] = scanner.getIncludedFiles();
        ;
        if (files == null) {
            log.info("no file is changed. Do not renerate template file");
            return;
        }
        java.util.Arrays.sort(files);
        Writer writer = new OutputStreamWriter(buildContext.newFileOutputStream(finalFile));
        List<String> modules = new ArrayList<String>(20);

        String templateNamePrefix = template.substring(template.indexOf('"') + 1,
                template.indexOf("@@@@name@@@@"));
        if (fileHeader != null) {
            writer.write(fileHeader);
        }
        for (String childFile : files) {
            transformFile(childFile, srcDirectory, writer, template, modules);
        }
        if (fileFooter != null) {
            writer.write(fileFooter);
        }
        //handleDirectory(srcDirectory, FilenameUtils.normalizeNoEndSeparator(srcDirectory.getAbsolutePath(), true), writer, template, modules);
        if (generateModule) {
            writer.write("angular.module(\"ui." + srcDirectory.getName() + ".tpls\", [");
            for (String module : modules) {
                writer.write("\"" + templateNamePrefix + module + "\",\n");
            }
            writer.write("]);\n");
        }
        writer.close();
        log.info("Finish writing file " + finalFile.getAbsolutePath());
    } catch (IOException e) {
        throw new MojoExecutionException(e.getMessage());
    }

}

From source file:com.github.formatter.JSBeautifier.java

License:Apache License

@Override
public void execute() throws MojoExecutionException, MojoFailureException {

    if (skipFormatting) {
        getLog().info("Formatting is skipped");
        return;//from   w w w  . j  a v  a 2  s  . c  om
    }

    long startClock = System.currentTimeMillis();

    createResourceCollection();

    List files = new ArrayList();
    try {

        if (directories != null) {
            for (File directory : directories) {
                if (directory.exists() && directory.isDirectory()) {
                    collection.setBaseDir(directory);
                    addCollectionFiles(files);
                }
            }
        }
    } catch (Exception e) {
        throw new MojoExecutionException(
                "Unable to find files using includes/excludes. Please set correct property value for `project.build.jsSourceDirectory`",
                e);
    }

    int numberOfFiles = files.size();
    Log log = getLog();
    log.info("Number of javascript files to be formatted: " + numberOfFiles);

    if (numberOfFiles > 0) {
        try {
            initContext();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        ResultCollector rc = new ResultCollector();
        Properties hashCache = readFileHashCacheFile();

        String basedirPath = getBasedirPath();
        for (int i = 0, n = files.size(); i < n; i++) {
            File file = (File) files.get(i);
            formatFile(file, rc, hashCache, basedirPath);
        }

        storeFileHashCache(hashCache);

        long endClock = System.currentTimeMillis();

        log.info("Successfully formatted: " + rc.successCount + " file(s)");
        log.info("Fail to format        : " + rc.failCount + " file(s)");
        log.info("Skipped               : " + rc.skippedCount + " file(s)");
        log.info("Approximate time taken: " + ((endClock - startClock) / 1000) + "s");
    }

}

From source file:com.github.greengerong.NgProtractor.java

License:Apache License

public void execute() throws MojoExecutionException {
    final Log log = getLog();

    log.info(String.format("protractor:%s", protractor));
    log.info(String.format("configFile:%s", configFile));

    if (skipProtractor || skipTests) {
        log.info("Skipping protractor test.");
        return;/*from   www  . jav  a 2 s  . c  o  m*/
    }

    if (StringUtils.isNotBlank(beforeRunning)) {
        execBeforeRunning();
    }

    try {
        checkNotNull(protractor, "Protractor should not be empty.");
        checkFileExists(configFile, "Protractor should be exists.");

        new ProtractorService(ignoreFailed, log)
                .exec(new Command(protractor, configFile, debug, debugBrk, arguments));
    } catch (Exception e) {
        throw new MojoExecutionException("There were exceptions when run protractor test.", e);
    } finally {
        execAfterRunning();
    }
}

From source file:com.github.greengerong.NgProtractor.java

License:Apache License

private void executeCommand(final String cmd, final String logAction) {
    final Log log = getLog();

    try {/* w  w w  .  j a  v  a2s.com*/
        log.info(String.format("execute %s running: %s", logAction, cmd));
        final ProcessBuilder processBuilder = new ProcessBuilder(getCommandAccordingToOS(cmd));
        final Process process = processBuilder.start();
        final String runningInfo = IOUtil.toString(process.getInputStream());
        log.info(runningInfo);
    } catch (IOException e) {
        log.warn(String.format("execute %s running script error", logAction), e);
    }
}

From source file:com.github.harti2006.neo4j.StartNeo4jServerMojo.java

License:Apache License

private void startNeo4jServer() throws MojoExecutionException {
    final Log log = getLog();
    try {/*  w  ww  . ja va2  s. c  o  m*/
        final Path serverLocation = getServerLocation();
        final String[] neo4jCommand = new String[] {
                serverLocation.resolve(Paths.get("bin", "neo4j")).toString(), "start" };
        final File workingDir = serverLocation.toFile();

        final Process neo4jStartProcess = Runtime.getRuntime().exec(neo4jCommand, null, workingDir);
        try (BufferedReader br = new BufferedReader(
                new InputStreamReader(neo4jStartProcess.getInputStream()))) {
            String line;
            while ((line = br.readLine()) != null) {
                log.info("NEO4J SERVER > " + line);
            }
        }

        if (neo4jStartProcess.waitFor(5, SECONDS) && neo4jStartProcess.exitValue() == 0) {
            log.info("Started Neo4j server");
        } else {
            throw new MojoExecutionException("Neo4j server did not start up properly");
        }
    } catch (IOException | InterruptedException e) {
        throw new MojoExecutionException("Could not start neo4j server", e);
    }
}

From source file:com.github.harti2006.neo4j.StopNeo4jServerMojo.java

License:Apache License

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    final Log log = getLog();
    final Path serverLocation = getServerLocation();
    final String[] stopServerCmd = { serverLocation.resolve(Paths.get("bin", "neo4j")).toString(), "stop" };
    final File workingDir = serverLocation.toFile();

    try {/*from  w  ww .  j av a 2s  . c om*/
        final Process neo4jServerStopProcess = Runtime.getRuntime().exec(stopServerCmd, null, workingDir);
        try (final BufferedReader br = new BufferedReader(
                new InputStreamReader(neo4jServerStopProcess.getInputStream()))) {
            String line;
            while ((line = br.readLine()) != null) {
                log.info("NEO4J-SERVER > " + line);
            }

            if (neo4jServerStopProcess.waitFor(5, SECONDS) && neo4jServerStopProcess.exitValue() == 0) {
                log.info("Stopped Neo4j server");
            } else {
                throw new MojoExecutionException("Neo4j server did not stop properly");
            }
        }
    } catch (IOException | InterruptedException e) {
        throw new MojoExecutionException("Could not stop Neo4j server", e);
    }
}

From source file:com.github.lucapino.confluence.AbstractConfluenceMojo.java

License:Apache License

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    Log log = getLog();
    // Run only at the execution root
    if (runOnlyAtExecutionRoot && !isThisTheExecutionRoot()) {
        log.info("Skipping the announcement mail in this project because it's not the Execution Root");
    } else {/*  w w w. j  a v  a  2 s .co m*/
        if (isSkip()) {
            log.info("Skipping Plugin execution.");
            return;
        }
        try {
            loadUserCredentials();
            doExecute();
        } catch (Exception e) {
            log.error("Error when executing mojo", e);
        }
    }
}