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.codecrate.webstart.AntToMavenLogger.java

License:Apache License

private void log(BuildEvent event) {
    int priority = event.getPriority();
    Log log = mojo.getLog();
    switch (priority) {
    case Project.MSG_ERR:
        log.error(event.getMessage());//from w  w w.  j  a  v a2 s  .  c o m
        break;

    case Project.MSG_WARN:
        log.warn(event.getMessage());
        break;

    case Project.MSG_INFO:
        log.info(event.getMessage());
        break;

    case Project.MSG_VERBOSE:
        log.debug(event.getMessage());
        break;

    case Project.MSG_DEBUG:
        log.debug(event.getMessage());
        break;

    default:
        log.info(event.getMessage());
        break;
    }
}

From source file:com.codetroopers.maven.mergeprops.MergeProperty.java

License:Apache License

@VisibleForTesting
static void processProperties(final Map<String, Properties> propertiesMap, final Merge merge, final Log log)
        throws MojoFailureException {
    Map<String, Integer> localeSizeMap = Maps.newHashMap();
    for (Map.Entry<String, Properties> entry : propertiesMap.entrySet()) {
        List<String> emptyProperties = Lists.newArrayList();
        for (String key : entry.getValue().stringPropertyNames()) {
            final String property = entry.getValue().getProperty(key);
            if (Strings.isNullOrEmpty(property)) {
                emptyProperties.add(key);
            }//from   w  w  w.  j av  a  2 s .  c o m
            entry.getValue().setProperty(key, property.replaceAll("([^'])'([^'])", "$1''$2"));
        }
        localeSizeMap.put(entry.getKey(), entry.getValue().size());
        if (log != null) {
            if (!emptyProperties.isEmpty()) {
                log.info("Found empty properties for final file " + merge.getTarget() + " [" + entry.getKey()
                        + "] : \n" + Joiner.on("\n").join(emptyProperties));
            }
            log.info("=> Final file " + merge.getTarget() + " [" + entry.getKey() + "] contains "
                    + entry.getValue().size() + " entries");
        }
    }
    checkCountMismatch(propertiesMap, merge, localeSizeMap);
}

From source file:com.codetroopers.maven.mergeprops.MergeProperty.java

License:Apache License

static boolean checkKeys(final String propertyFileName, final String[] excludeKeyCheck, final String fileName,
        final Log log) throws MojoExecutionException, MojoFailureException {
    if (propertyFileName == null) {
        throw new NullPointerException("PropertyFileName can not be null ! ");
    }//from  w ww . j a  va2s .  c om
    // Do not reuse the existing inputstream as the load method forwards it and there is no reset() in FIS
    String prefixToConsider = extractFilePrefix(propertyFileName);
    if (log.isDebugEnabled()) {
        log.debug("Prefix to consider : " + prefixToConsider);
    }
    if (excludeKeyCheck != null) {
        for (String s : excludeKeyCheck) {
            if (prefixToConsider.matches(s)) {
                log.info("Found propertyFileName without prefix checking, including... [" + propertyFileName
                        + "]");
                return true;
            }
        }
    }
    Properties props = new Properties();
    InputStream input = null;
    try {
        input = new FileInputStream(fileName);
        props.load(input);
        return !containsInvalidPrefix(prefixToConsider, props);
    } catch (IOException e) {
        throw new MojoExecutionException("Could not read from file: " + propertyFileName, e);
    } finally {
        if (input != null) {
            try {
                input.close();
            } catch (IOException ioe) {
                //do nothing
            }
        }
    }
}

From source file:com.codspire.mojo.artifactlookup.ArtifactLookupMojo.java

License:Apache License

/**
 * Searches the local artifacts specified through "artifactLocation" in
 * "remoteArtifactRepositories" or "repositoryUrl" and generates the search
 * results.//from w  w w  . jav  a  2 s. co m
 * 
 */
protected void lookupArtifacts() {
    Log log = getLog();

    validateRemoteArtifactRepositories();
    validateArtifactLocation();

    List<String> remoteArtifactRepositoriesURL = getRemoteArtifactRepositoriesURL();

    log.info(artifactLocation.getAbsolutePath() + " is file = " + artifactLocation.isFile());

    if (log.isDebugEnabled()) {
        log.debug("Remote Artifact Repositories");
        log.debug((remoteArtifactRepositories != null) ? remoteArtifactRepositories.toString()
                : "remoteArtifactRepositories is null");
    }

    LookupForDependency lookupForDependency = new LookupForDependency(artifactLocation, recursive,
            remoteArtifactRepositoriesURL, outputDirectory, log);
    lookupForDependency.process();
}

From source file:com.collaborne.jsonschema.validator.plugin.ValidateMojo.java

License:Apache License

@VisibleForTesting
protected void log(String filename, ProcessingMessage message) {
    // FIXME: #getMessage() is ok, but ideally we also need the other key/value pairs.
    //        Doing that would require knowing that "message" is the one holding the message
    //        itself.
    StringBuilder logMessageBuilder = new StringBuilder();
    logMessageBuilder.append(filename);//from   www .  j  a  v a 2 s .  c om
    logMessageBuilder.append(": ");
    logMessageBuilder.append(message.getMessage());
    String logMessage = logMessageBuilder.toString();

    Log log = getLog();

    switch (message.getLogLevel()) {
    case NONE:
        // XXX: Do nothing?
        break;
    case DEBUG:
        log.debug(logMessage);
        break;
    case INFO:
        log.info(logMessage);
        break;
    case WARNING:
        log.warn(logMessage);
        break;
    case ERROR:
    case FATAL:
        log.error(logMessage);
        break;
    }
}

From source file:com.cybernostics.jsp2thymeleaf.maven.JSPConvertMojo.java

License:Apache License

public void execute() throws MojoExecutionException

{
    final Log log = getLog();
    log.info("includes:" + Arrays.toString(getIncludes()));
    log.info("outputDirectory = " + outputDirectory.getAbsolutePath());
    log.info("srcDirectory = " + srcDirectory.getAbsolutePath());
    log.info("updateLinks = " + updateLinks);
    log.info("taglib scripts folder " + converterScriptDirectory.toString());
    JSP2ThymeleafConfiguration config = JSP2ThymeleafConfiguration.getBuilder().withIncludes(includes)
            .withExcludes(excludes).withSrcFolder(srcDirectory.toString())
            .withDestFolder(outputDirectory.toString())
            .withConverterScripts(scriptsInFolder(converterScriptDirectory)).build();
    JSP2Thymeleaf jSP2Thymeleaf = new JSP2Thymeleaf(config);
    try {/*from  w ww.  ja v  a2s  .  c o m*/
        final List<JSP2ThymeLeafException> exceptions = jSP2Thymeleaf.run();
        if (exceptions.isEmpty()) {
            log.info("JSP2Thymeleaf converted all files successfully.");
        } else {
            log.error("JSP2Thymeleaf had errors:");
            for (JSP2ThymeLeafException exception : exceptions) {
                log.error(exception.getMessage());
            }
            throw new MojoExecutionException("Failed to convert all files");
        }
    } catch (MojoExecutionException exception) {
        throw exception;
    } catch (Throwable t) {
        log.error(t);
        throw t;
    }
}

From source file:com.dev9.mvnwatcher.WatcherMojo.java

License:Apache License

public void execute() throws MojoExecutionException {

    Log log = getLog();

    if (!basedir.exists()) {
        throw new MojoExecutionException("Can't find project directory " + basedir);
    }//w ww  . j  a va  2 s .  c om

    if (!sourceDirectory.exists()) {
        throw new MojoExecutionException("Can't find source directory " + sourceDirectory);
    } else {
        log.info("Found: " + sourceDirectory.getAbsolutePath());
    }

    if (resourcesDirectory != null) {
        if (!resourcesDirectory.exists()) {
            log.warn("Can't find resources directory " + resourcesDirectory);
        } else {
            log.info("Found: " + resourcesDirectory.getAbsolutePath());
        }
    } else {
        log.warn("No resources directory specified.");
    }

    createTargetDirectoryIfNotExists();

    MvnWatcher runner = null;

    try {

        if (tasks == null)
            tasks = getDefaultTasks(basedir.toPath());

        List<Path> directoriesToWatch = new ArrayList<>();
        directoriesToWatch.add(sourceDirectory.toPath());
        directoriesToWatch.add(resourcesDirectory.toPath());

        runner = new MvnWatcher(directoriesToWatch, basedir.toPath(), directory.toPath(), tasks);
        runner.startUpWatcher();
        runner.terminate = terminate;
    } catch (IOException e) {
        e.printStackTrace();
    }

    if (runner != null)
        runner.waitForCancel();

}

From source file:com.edugility.h2.maven.plugin.SpawnH2Mojo.java

License:Open Source License

/**
 * Spawns a new H2 TCP server by invoking the {@link
 * AbstractH2Mojo#spawnServer()} method.
 *
 * @exception MojoExecutionException if there was any kind of error
 *//*from w  w w.  j  a  va  2s. c o m*/
@Override
public void execute() throws MojoExecutionException {
    final Log log = this.getLog();
    try {
        this.spawnServer();
    } catch (final RuntimeException throwMe) {
        throw throwMe;
    } catch (final Exception kaboom) {
        throw new MojoExecutionException("Could not spawn H2 server.", kaboom);
    }
    if (log != null && log.isInfoEnabled()) {
        log.info(String.format("H2 server spawned at tcp://localhost:%d", this.getPort()));
    }
}

From source file:com.edugility.h2.maven.plugin.StopH2Mojo.java

License:Open Source License

/**
 * Stops a running H2 TCP server by invoking the {@link
 * AbstractH2Mojo#shutdownServer()} method.
 *
 * @exception MojoExecutionException if an error occurs
 *///from   w w  w.j  ava  2  s . c  om
@Override
public void execute() throws MojoExecutionException {
    try {
        this.shutdownServer();
    } catch (final SQLException kaboom) {
        throw new MojoExecutionException(
                "Could not shutdown TCP server. Please check to see if the process is still running.", kaboom);
    }
    final Log log = this.getLog();
    if (log != null && log.isInfoEnabled()) {
        log.info("H2 server stopped");
    }
}

From source file:com.ericsson.tools.cpp.tester.execution.AbstractTestExecutor.java

License:Apache License

public AbstractTestExecutor(final Log log) {
    cli = new CliExecutor(log);

    cli.setStdOutConsumer(new StreamConsumer() {
        @Override/*from   w w w .j a  va2s  .  co  m*/
        public void consumeLine(String line) {
            log.info(line);
        }
    });

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

}