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:aQute.bnd.maven.export.plugin.CreateLauncherMavenPlugin.java

License:Apache License

private Collection<File> getDependecyFiles() throws MojoFailureException, MojoExecutionException {
    Log log = getLog();

    Collection<File> resultList = new HashSet<>();
    Set<org.apache.maven.artifact.Artifact> artifacts = project.getArtifacts();
    for (org.apache.maven.artifact.Artifact artifact : artifacts) {
        if (!includeScopes.contains(artifact.getScope())) {
            log.info("skipping (wrong scope): " + artifact);
            continue;
        }/*ww w . jav a  2s  .c o  m*/
        if (!"jar".equals(artifact.getType())) {
            log.info("skipping (not a jar): " + artifact);
            continue;
        }
        resultList.add(artifact.getFile());
    }
    return resultList;
}

From source file:br.com.gumga.maven.plugins.gumgag.Util.java

public static void geraGumga(Log log) {
    log.info("\n" + "\n" + "   _____ _    _ __  __  _____          \n"
            + "  / ____| |  | |  \\/  |/ ____|   /\\    \n" + " | |  __| |  | | \\  / | |  __   /  \\   \n"
            + " | | |_ | |  | | |\\/| | | |_ | / /\\ \\  \n" + " | |__| | |__| | |  | | |__| |/ ____ \\ \n"
            + "  \\_____|\\____/|_|  |_|\\_____/_/    \\_\\\n" + "                                       \n"
            + "                                       \n" + "");
}

From source file:ch.sourcepond.maven.plugin.jenkins.config.download.DownloaderImpl.java

License:Apache License

/**
 * @param pLog//from   w  ww .j a va 2 s .  co  m
 * @param pConfig
 * @return
 * @throws IOException
 * @throws ClientProtocolException
 * @throws MojoExecutionException
 */
private String determineJenkinsVersion(final Log pLog, final CloseableHttpClient pClient, final Config pConfig)
        throws ClientProtocolException, IOException, MojoExecutionException {
    final HttpUriRequest versionRequest = clientFacade.newGet(pConfig.getBaseUri());
    try (final CloseableHttpResponse response = pClient.execute(versionRequest)) {
        if (response.containsHeader(VERSION_HEADER_NAME)) {
            final Header[] header = response.getHeaders(VERSION_HEADER_NAME);
            isTrue(header.length == 1,
                    "Jenkins API changed; received multiple version headers. Please report this as bug (https://github.com/SourcePond/jenkins-maven-plugin/issues)");
            final String version = header[0].getValue();

            if (pLog.isInfoEnabled()) {
                pLog.info(messages.getMessage(DOWNLOADER_INFO_VERSION_FOUND, version));
            }

            return version;
        } else {
            throw new MojoExecutionException(messages.getMessage(DOWNLOADER_ERROR_NO_VERSION_HEADER,
                    pConfig.getBaseUri(), VERSION_HEADER_NAME));
        }
    }
}

From source file:ch.sourcepond.maven.plugin.jenkins.config.download.DownloaderImpl.java

License:Apache License

@Override
public String downloadCliJar(final Log pLog, final Config pValidatedConfig) throws MojoExecutionException {
    try (final CloseableHttpClient client = clientFacade.newClient(pValidatedConfig)) {
        final String jenkinsVersion = determineJenkinsVersion(pLog, client, pValidatedConfig);

        final Path downloadedCliJar = getDownloadedCliJar(pValidatedConfig.getJenkinscliDirectory(),
                jenkinsVersion);//w w w .  jav  a  2  s .  c o m

        if (!isRegularFile(downloadedCliJar)) {
            final HttpUriRequest request = clientFacade.newGet(pValidatedConfig.getCliJarUri());
            try {

                try (final CloseableHttpResponse response = client.execute(request)) {
                    final StatusLine statusLine = response.getStatusLine();

                    if (statusLine.getStatusCode() != SC_OK) {
                        throw new MojoExecutionException(messages.getMessage(DOWNLOADER_ERROR_WRONG_STATUS_CODE,
                                statusLine, pValidatedConfig.getCliJarUri()));
                    }

                    final HttpEntity entity = response.getEntity();

                    if (entity != null) {
                        try (final InputStream in = entity.getContent()) {
                            copy(in, downloadedCliJar);
                        }
                    } else {
                        throw new MojoExecutionException(messages.getMessage(DOWNLOADER_ERROR_ENTITY_IS_NULL,
                                pValidatedConfig.getCliJarUri()));
                    }
                }
            } finally {
                request.abort();
            }
        }

        final String absoluteDownloadedCliPath = downloadedCliJar.toAbsolutePath().toString();

        if (pLog.isInfoEnabled()) {
            pLog.info(messages.getMessage(DOWNLOADER_INFO_USED_CLI_JAR, absoluteDownloadedCliPath));
        }

        return absoluteDownloadedCliPath;
    } catch (final IOException | KeyManagementException | NoSuchAlgorithmException | KeyStoreException
            | CertificateException e) {
        throw new MojoExecutionException(e.getMessage(), e);
    }
}

From source file:cn.org.once.cstack.maven.plugin.utils.RestUtils.java

License:Open Source License

/**
 * @param url/*  www  . j  a  v  a  2 s  . c  o m*/
 * @param parameters
 * @param log
 * @return
 * @throws MojoExecutionException
 */
public Map<String, String> connect(String url, Map<String, Object> parameters, Log log)
        throws MojoExecutionException {

    Map<String, String> response = new HashMap<String, String>();
    CloseableHttpClient httpclient = HttpClients.createDefault();
    List<NameValuePair> nvps = new ArrayList<>();
    nvps.add(new BasicNameValuePair("j_username", (String) parameters.get("login")));
    nvps.add(new BasicNameValuePair("j_password", (String) parameters.get("password")));
    localContext = HttpClientContext.create();
    localContext.setCookieStore(new BasicCookieStore());
    HttpPost httpPost = new HttpPost(url);

    try {
        httpPost.setEntity(new UrlEncodedFormEntity(nvps));
        CloseableHttpResponse httpResponse = httpclient.execute(httpPost, localContext);
        ResponseHandler<String> handler = new ResponseErrorHandler();
        String body = handler.handleResponse(httpResponse);
        response.put("body", body);
        httpResponse.close();
        isConnected = true;
        log.info("Connection successful");
    } catch (Exception e) {
        log.error("Connection failed!  : " + e.getMessage());
        isConnected = false;
        throw new MojoExecutionException(
                "Connection failed, please check your manager location or your credentials");
    }

    return response;
}

From source file:com.actility.maven.plugin.cocoon.AbstractDependencyMojo.java

License:Apache License

/**
 * Does the actual copy of the file and logging.
 *
 * @param artifact represents the file to copy.
 * @param destFile file name of destination file.
 * @throws MojoExecutionException with a message if an error occurs.
 *///ww w . java  2 s . co  m
protected void copyFile(File artifact, File destFile) throws MojoExecutionException {
    Log theLog = this.getLog();
    try {
        theLog.info("Copying "
                + (this.outputAbsoluteArtifactFilename ? artifact.getAbsolutePath() : artifact.getName())
                + " to " + destFile);

        if (artifact.isDirectory()) {
            // usual case is a future jar packaging, but there are special cases: classifier and other packaging
            throw new MojoExecutionException(
                    "Artifact has not been packaged yet. When used on reactor artifact, "
                            + "copy should be executed after packaging: see MDEP-187.");
        }

        FileUtils.copyFile(artifact, destFile);
    } catch (IOException e) {
        throw new MojoExecutionException("Error copying artifact from " + artifact + " to " + destFile, e);
    }
}

From source file:com.actility.maven.plugin.cocoon.DependencyUtil.java

License:Apache License

/**
 * Writes the specified string to the log at info level.
 *
 * @param string the string to write//from  w w w.j a v  a  2 s .  c om
 * @throws IOException if an I/O error occurs
 */
public static synchronized void log(String string, Log log) throws IOException {
    BufferedReader reader = new BufferedReader(new StringReader(string));

    String line;

    while ((line = reader.readLine()) != null) {
        log.info(line);
    }

    reader.close();
}

From source file:com.akathist.maven.plugins.launch4j.Launch4jMojo.java

License:Open Source License

/**
 * Just prints out how we were configured.
 *//*from w w  w .  java2 s.  co m*/
private void printState() {
    Log log = getLog();

    log.debug("headerType = " + headerType);
    log.debug("outfile = " + outfile);
    log.debug("jar = " + jar);
    log.debug("dontWrapJar = " + dontWrapJar);
    log.debug("errTitle = " + errTitle);
    log.debug("downloadUrl = " + downloadUrl);
    log.debug("supportUrl = " + supportUrl);
    log.debug("cmdLine = " + cmdLine);
    log.debug("chdir = " + chdir);
    log.debug("priority = " + priority);
    log.debug("stayAlive = " + stayAlive);
    log.debug("icon = " + icon);
    log.debug("objs = " + objs);
    log.debug("libs = " + libs);
    log.debug("vars = " + vars);
    if (singleInstance != null) {
        log.debug("singleInstance.mutexName = " + singleInstance.mutexName);
        log.debug("singleInstance.windowTitle = " + singleInstance.windowTitle);
    } else {
        log.debug("singleInstance = null");
    }
    if (jre != null) {
        log.debug("jre.path = " + jre.path);
        log.debug("jre.minVersion = " + jre.minVersion);
        log.debug("jre.maxVersion = " + jre.maxVersion);
        log.debug("jre.jdkPreference = " + jre.jdkPreference);
        log.debug("jre.initialHeapSize = " + jre.initialHeapSize);
        log.debug("jre.initialHeapPercent = " + jre.initialHeapPercent);
        log.debug("jre.maxHeapSize = " + jre.maxHeapSize);
        log.debug("jre.maxHeapPercent = " + jre.maxHeapPercent);
        log.debug("jre.opts = " + jre.opts);
    } else {
        log.debug("jre = null");
    }
    if (classPath != null) {
        log.debug("classPath.mainClass = " + classPath.mainClass);
        log.debug("classPath.addDependencies = " + classPath.addDependencies);
        log.debug("classPath.jarLocation = " + classPath.jarLocation);
        log.debug("classPath.preCp = " + classPath.preCp);
        log.debug("classPath.postCp = " + classPath.postCp);
    } else {
        log.info("classpath = null");
    }
    if (splash != null) {
        log.debug("splash.file = " + splash.file);
        log.debug("splash.waitForWindow = " + splash.waitForWindow);
        log.debug("splash.timeout = " + splash.timeout);
        log.debug("splash.timoutErr = " + splash.timeoutErr);
    } else {
        log.debug("splash = null");
    }
    if (versionInfo != null) {
        log.debug("versionInfo.fileVersion = " + versionInfo.fileVersion);
        log.debug("versionInfo.txtFileVersion = " + versionInfo.txtFileVersion);
        log.debug("versionInfo.fileDescription = " + versionInfo.fileDescription);
        log.debug("versionInfo.copyright = " + versionInfo.copyright);
        log.debug("versionInfo.productVersion = " + versionInfo.productVersion);
        log.debug("versionInfo.txtProductVersion = " + versionInfo.txtProductVersion);
        log.debug("versionInfo.productName = " + versionInfo.productName);
        log.debug("versionInfo.companyName = " + versionInfo.companyName);
        log.debug("versionInfo.internalName = " + versionInfo.internalName);
        log.debug("versionInfo.originalFilename = " + versionInfo.originalFilename);
    } else {
        log.debug("versionInfo = null");
    }
    if (messages != null) {
        log.debug("messages.startupErr = " + messages.startupErr);
        log.debug("messages.bundledJreErr = " + messages.bundledJreErr);
        log.debug("messages.jreVersionErr = " + messages.jreVersionErr);
        log.debug("messages.launcherErr = " + messages.launcherErr);
        log.debug("messages.instanceAlreadyExistsMsg = " + messages.instanceAlreadyExistsMsg);
    } else {
        log.debug("messages = null");
    }
}

From source file:com.alexnederlof.jasperreport.JasperReporter.java

License:Apache License

private void logConfiguration(Log log) {
    log.info("Generating Jasper reports");
    log.info("Outputdir=" + outputDirectory.getAbsolutePath());
    log.info("Sourcedir=" + sourceDirectory.getAbsolutePath());
    log.info("Output ext=" + outputFileExt);
    log.info("Source ext=" + sourceFileExt);
    log.info("XML Validation=" + xmlValidation);
    log.info("JasperReports Compiler=" + compiler);
    log.info("Number of threads:" + numberOfThreads);
}

From source file:com.alibaba.citrus.maven.eclipse.base.eclipse.reader.ReadWorkspaceLocations.java

License:Apache License

/**
 * Detect WTP Default Server. Do nothing if tehre are no defined servers in the settings.
 *
 * @param workspaceConfiguration/*w  w w.  j a  v  a 2 s . co m*/
 * @param wtpDefaultServer
 * @param log
 */
private void detectWTPDefaultServer(WorkspaceConfiguration workspaceConfiguration, String wtpDefaultServer,
        Log log) {
    HashMap servers = readDefinedServers(workspaceConfiguration, log);
    if (servers == null || servers.isEmpty()) {
        return;
    }
    if (wtpDefaultServer != null) {
        Set ids = servers.keySet();
        // first we try the exact match
        Iterator idIterator = ids.iterator();
        while (workspaceConfiguration.getDefaultDeployServerId() == null && idIterator.hasNext()) {
            String id = (String) idIterator.next();
            String name = (String) servers.get(id);
            if (wtpDefaultServer.equals(id) || wtpDefaultServer.equals(name)) {
                workspaceConfiguration.setDefaultDeployServerId(id);
                workspaceConfiguration.setDefaultDeployServerName(name);
            }
        }
        if (workspaceConfiguration.getDefaultDeployServerId() == null) {
            log.info("no exact wtp server match.");
            // now we will try the substring match
            idIterator = ids.iterator();
            while (workspaceConfiguration.getDefaultDeployServerId() == null && idIterator.hasNext()) {
                String id = (String) idIterator.next();
                String name = (String) servers.get(id);
                if (id.indexOf(wtpDefaultServer) >= 0 || name.indexOf(wtpDefaultServer) >= 0) {
                    workspaceConfiguration.setDefaultDeployServerId(id);
                    workspaceConfiguration.setDefaultDeployServerName(name);
                }
            }
        }
    }
    if (workspaceConfiguration.getDefaultDeployServerId() == null && servers.size() > 0) {
        // now take the default server
        log.info("no substring wtp server match.");
        workspaceConfiguration.setDefaultDeployServerId((String) servers.get(""));
        workspaceConfiguration.setDefaultDeployServerName(
                (String) servers.get(workspaceConfiguration.getDefaultDeployServerId()));
    }
    log.info("Using as WTP server : " + workspaceConfiguration.getDefaultDeployServerName());
}