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.offbynull.coroutines.mavenplugin.AbstractInstrumentMojo.java

License:Open Source License

/**
 * Creates an {@link Instrumenter} instance.
 * @param log maven logger//from  w ww . j av  a  2 s . c  o  m
 * @param classpath classpath for classes being instrumented
 * @return a new {@link Instrumenter}
 * @throws MojoExecutionException if any exception occurs
 */
protected final Instrumenter getInstrumenter(Log log, List<String> classpath) throws MojoExecutionException {
    List<File> classpathFiles;
    try {
        log.debug("Getting compile classpath");
        classpathFiles = classpath.stream().map(x -> new File(x)).collect(Collectors.toList());
        log.debug("Getting bootstrap classpath");
        classpathFiles.addAll(FileUtils.listFiles(new File(jdkLibsDirectory), new String[] { "jar" }, true));

        log.info("Classpath for instrumentation is as follows: " + classpathFiles);
    } catch (Exception ex) {
        throw new MojoExecutionException("Unable to get compile classpath elements", ex);
    }

    log.info("Creating instrumenter...");

    try {
        return new Instrumenter(classpathFiles);
    } catch (Exception ex) {
        throw new MojoExecutionException("Unable to create instrumenter", ex);
    }
}

From source file:com.offbynull.coroutines.mavenplugin.MainInstrumentMojo.java

License:Open Source License

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

    File mainOutputFolder = new File(getProject().getBuild().getOutputDirectory());
    if (!mainOutputFolder.isDirectory()) {
        log.warn("Test folder doesn't exist -- nothing to instrument");
        return;//from ww  w .  jav a2s.  c  om
    }

    List<String> classpath;
    try {
        classpath = getProject().getCompileClasspathElements();
    } catch (DependencyResolutionRequiredException ex) {
        throw new MojoExecutionException("Dependency resolution problem", ex);
    }

    Instrumenter instrumenter = getInstrumenter(log, classpath);
    log.info("Processing main output folder ... ");
    instrumentPath(log, instrumenter, mainOutputFolder);
}

From source file:com.opoopress.maven.plugins.plugin.AbstractDeployMojo.java

License:Apache License

private static void push(final File inputDirectory, final Repository repository, final WagonManager manager,
        final Wagon wagon, final ProxyInfo proxyInfo, final String relativeDir, final Log log)
        throws MojoExecutionException {
    AuthenticationInfo authenticationInfo = manager.getAuthenticationInfo(repository.getId());
    log.debug("authenticationInfo with id '" + repository.getId() + "': "
            + ((authenticationInfo == null) ? "-" : authenticationInfo.getUserName()));

    try {/*from  w ww.j  a v a 2  s.  c o  m*/
        Debug debug = new Debug();

        wagon.addSessionListener(debug);

        wagon.addTransferListener(debug);

        if (proxyInfo != null) {
            log.debug("connect with proxyInfo");
            wagon.connect(repository, authenticationInfo, proxyInfo);
        } else if (proxyInfo == null && authenticationInfo != null) {
            log.debug("connect with authenticationInfo and without proxyInfo");
            wagon.connect(repository, authenticationInfo);
        } else {
            log.debug("connect without authenticationInfo and without proxyInfo");
            wagon.connect(repository);
        }

        log.info("Pushing " + inputDirectory);

        // TODO: this also uploads the non-default locales,
        // is there a way to exclude directories in wagon?
        log.info("   >>> to " + repository.getUrl() + relativeDir);

        wagon.putDirectory(inputDirectory, relativeDir);
    } catch (ResourceDoesNotExistException e) {
        throw new MojoExecutionException("Error uploading site", e);
    } catch (TransferFailedException e) {
        throw new MojoExecutionException("Error uploading site", e);
    } catch (AuthorizationException e) {
        throw new MojoExecutionException("Error uploading site", e);
    } catch (ConnectionException e) {
        throw new MojoExecutionException("Error uploading site", e);
    } catch (AuthenticationException e) {
        throw new MojoExecutionException("Error uploading site", e);
    }
}

From source file:com.opoopress.maven.plugins.plugin.AbstractDeployMojo.java

License:Apache License

/**
 * @param wagon//w w  w .ja v  a 2 s  .  co  m
 * @param log
 */
private static void configureLog(Wagon wagon, Log log) {
    try {
        Method method = wagon.getClass().getMethod("setLog", Log.class);
        method.invoke(wagon, log);
        log.info("Set log for wagon: " + wagon);
    } catch (Exception e) {
        log.debug("Wagon does not supports setLog() method.");
    }
}

From source file:com.puresoltechnologies.maven.plugins.license.AbstractValidationMojo.java

/**
 * This method retrieves all artifacts of the current Maven module.
 * //  w  ww  . j av  a 2s . com
 * <b>Attention(!):</b> This method uses
 * {@link MavenProject#getDependencyArtifacts()} and
 * {@link MavenProject#getArtifacts()} which are lazily filled with the
 * artifacts.
 * 
 * @return A {@link Set} of {@link Artifact} is returned containing the
 *         artifacts found.
 */
protected Set<Artifact> getArtifacts(boolean recursive) {
    Log log = getLog();
    if (recursive) {
        log.info(
                "Recursive license validation is enabled. All direct and transitive dependency artifacts are going to be checked.");
        @SuppressWarnings("unchecked")
        Set<Artifact> set = mavenProject.getArtifacts();
        return set;
    } else {
        log.info(
                "Recursive license validation is disabled. All only direct dependency artifacts are going to be checked.");
        @SuppressWarnings("unchecked")
        Set<Artifact> set = mavenProject.getDependencyArtifacts();
        return set;
    }
}

From source file:com.qpark.maven.plugin.collectschemas.CondenseServiceSchemasMojo.java

License:Open Source License

private static void copyFile(final File baseDirectory, final File outputDirectory, final File file,
        final Log log) throws IOException {
    String outName = file.getAbsolutePath().replace(baseDirectory.getAbsolutePath(),
            outputDirectory.getAbsolutePath());
    Path out = Paths.get(new File(outName).toURI());
    if (!Files.isWritable(out.getParent())) {
        Files.createDirectories(out.getParent());
    }//from w ww.  ja va 2s .  c  o m
    try (FileInputStream fis = new FileInputStream(file)) {
        Files.copy(fis, out);
        log.info(String.format("Copy xsd %s",
                file.getAbsolutePath().replace(baseDirectory.getAbsolutePath(), "")));
    } catch (IOException e) {
        log.info(String.format("Could not copy file %s to ", file, out.toFile().getAbsolutePath()));
        throw e;
    }
}

From source file:com.qpark.maven.plugin.collectschemas.CondenseServiceSchemasMojo.java

License:Open Source License

protected static void condense(final XsdsUtil xsds, final String serviceId, final File baseDirectory,
        final File outputDirectory, final Log log) throws IOException {
    List<String> serviceIds = ServiceIdRegistry.splitServiceIds(serviceId);
    if (Objects.nonNull(serviceIds) && serviceIds.size() > 0) {
        xsds.getXsdContainerMap().values().stream().forEach(xc -> log
                .debug(String.format("Contains namespaces: %s %s", xc.getTargetNamespace(), xc.getFile())));
        TreeSet<String> importedNamespaces = new TreeSet<String>();
        xsds.getServiceIdRegistry().getAllServiceIds().stream().filter(si -> serviceIds.contains(si))
                .map(si -> xsds.getServiceIdRegistry().getServiceIdEntry(si))
                .map(sie -> sie.getTargetNamespace()).filter(tn -> Objects.nonNull(tn))
                .map(tn -> xsds.getXsdContainer(tn)).filter(xc -> Objects.nonNull(xc)).forEach(xc -> {
                    addImportedNamespaces(xsds, xc, importedNamespaces);
                });//from w  w  w  .  j a va  2s.  c  om
        if (Objects.nonNull(outputDirectory) && !baseDirectory.equals(outputDirectory)) {
            log.info(String.format("Copy namespaces: %s", importedNamespaces));
            xsds.getXsdContainerMap().values().stream()
                    .filter(xc -> importedNamespaces.contains(xc.getTargetNamespace())).forEach(xc -> {
                        try {
                            copyFile(baseDirectory, outputDirectory, xc.getFile(), log);
                        } catch (Exception e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
                    });
        } else {
            log.info(String.format("Keep namespaces: %s", importedNamespaces));
            xsds.getXsdContainerMap().values().stream()
                    .filter(xc -> !importedNamespaces.contains(xc.getTargetNamespace())).forEach(xc -> {
                        if (xc.getFile().delete()) {
                            log.info(String.format("Delete file %s", xc.getFile()));
                        } else {
                            log.info(String.format("Could not delete file %s", xc.getFile()));
                        }
                    });
        }
    }
}

From source file:com.qq.tars.maven.util.ArchiveEntryUtils.java

License:Open Source License

public static void chmod(final File file, final int mode, final Log logger, boolean useJvmChmod)
        throws ArchiverException {
    if (!Os.isFamily(Os.FAMILY_UNIX)) {
        return;//from   ww w  .  j  a va  2s.com
    }

    final String m = Integer.toOctalString(mode & 0xfff);

    if (useJvmChmod && !jvmFilePermAvailable) {
        logger.info("chmod it's not possible where your current jvm");
        useJvmChmod = false;
    }

    if (useJvmChmod && jvmFilePermAvailable) {
        applyPermissionsWithJvm(file, m, logger);
        return;
    }

    try {
        final Commandline commandline = new Commandline();

        commandline.setWorkingDirectory(file.getParentFile().getAbsolutePath());

        if (logger.isDebugEnabled()) {
            logger.debug(file + ": mode " + Integer.toOctalString(mode) + ", chmod " + m);
        }

        commandline.setExecutable("chmod");

        commandline.createArg().setValue(m);

        final String path = file.getAbsolutePath();

        commandline.createArg().setValue(path);

        final CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();

        final CommandLineUtils.StringStreamConsumer stdout = new CommandLineUtils.StringStreamConsumer();

        final int exitCode = CommandLineUtils.executeCommandLine(commandline, stderr, stdout);

        if (exitCode != 0) {
            logger.warn("-------------------------------");
            logger.warn("Standard error:");
            logger.warn("-------------------------------");
            logger.warn(stderr.getOutput());
            logger.warn("-------------------------------");
            logger.warn("Standard output:");
            logger.warn("-------------------------------");
            logger.warn(stdout.getOutput());
            logger.warn("-------------------------------");

            throw new ArchiverException("chmod exit code was: " + exitCode);
        }
    } catch (final CommandLineException e) {
        throw new ArchiverException("Error while executing chmod.", e);
    }

}

From source file:com.qwazr.mavenplugin.QwazrStartMojo.java

License:Apache License

public void execute() throws MojoExecutionException, MojoFailureException {
    final Log log = getLog();
    log.info("Starting QWAZR");
    final Launcher launcher = new Launcher();

    try {/*from w  w w  .ja va 2s . c  o m*/
        if (daemon == null || !daemon)
            launcher.startEmbedded(log);
        else
            launcher.startAsDaemon(log);
    } catch (Exception e) {
        throw new MojoFailureException("Cannot start QWAZR", e);
    }
}

From source file:com.qwazr.mavenplugin.QwazrStopMojo.java

License:Apache License

public void execute() throws MojoExecutionException, MojoFailureException {
    final Log log = getLog();
    log.info("Stopping QWAZR");

    public_addr = getProperty(public_addr, "PUBLIC_ADDR", "localhost");
    webservice_port = getProperty(webservice_port, "WEBSERVICE_PORT", 9091);
    wait_ms = getProperty(webservice_port, null, 5000);

    CloseableHttpResponse response = null;
    CloseableHttpClient httpClient = null;
    try {/*w  w  w.ja  v a  2s .  c o  m*/
        httpClient = HttpUtils.createHttpClient_AcceptsUntrustedCerts();
        URI uri = new URI("http", null, public_addr, webservice_port, "/shutdown", null, null);
        log.info("Post HTTP Delete on: " + uri);
        response = httpClient.execute(new HttpDelete(uri));
        log.info("HTTP Status Code: " + response.getStatusLine().getStatusCode());
    } catch (IOException | URISyntaxException | NoSuchAlgorithmException | KeyStoreException
            | KeyManagementException e) {
        if (fault_tolerant == null || fault_tolerant)
            log.warn(e);
        else
            throw new MojoExecutionException(e.getMessage(), e);
    } finally {
        IOUtils.close(httpClient, response);
    }
    try {
        Thread.sleep(wait_ms);
    } catch (InterruptedException e) {
        log.warn(e);
    }
}