List of usage examples for org.apache.maven.plugin.logging Log isInfoEnabled
boolean isInfoEnabled();
From source file:apparat.embedding.maven.MavenLogAdapter.java
License:Open Source License
/** * Maps the level of a given Maven log to a corresponding * Apparat log level./*from ww w . ja va 2s.c o m*/ * * @param log The current Maven log. * @return The corresponding Apparat log level. */ public static LogLevel mapLevelOf(final org.apache.maven.plugin.logging.Log log) { // // We return an instance of a Scala case object here. // if (log.isDebugEnabled()) { return Debug$.MODULE$; } else if (log.isInfoEnabled()) { return Info$.MODULE$; } else if (log.isWarnEnabled()) { return Warning$.MODULE$; } else if (log.isErrorEnabled()) { return Error$.MODULE$; } else { return Off$.MODULE$; } }
From source file:ch.sourcepond.maven.plugin.jenkins.config.download.DownloaderImpl.java
License:Apache License
/** * @param pLog/* w w w.j av a2 s . c om*/ * @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);/* ww w .jav a2s.com*/ 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: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 v a 2s .c om @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 a v a2 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.github.jrh3k5.flume.mojo.plugin.plexus.MojoLogger.java
License:Apache License
/** * Determine a {@link Logger} level based on the configuration of the given * {@link Log}./*from w w w .j av a 2s. c o m*/ * * @param log * The {@link Log} to determine the logger level. * @return A {@link Logger} level corresponding to the log level in the * given {@link Log}. */ private static int determineThreshold(Log log) { if (log.isDebugEnabled()) { return Logger.LEVEL_DEBUG; } else if (log.isInfoEnabled()) { return Logger.LEVEL_INFO; } else if (log.isWarnEnabled()) { return Logger.LEVEL_WARN; } else if (log.isErrorEnabled()) { return Logger.LEVEL_ERROR; } else { return Logger.LEVEL_DISABLED; } }
From source file:com.github.maven.plugins.core.GitHubProjectMojo.java
License:Open Source License
/** * Is info logging enabled?/* w w w . j av a 2 s.c o m*/ * * @return true if enabled, false otherwise */ protected boolean isInfo() { final Log log = getLog(); return log != null ? log.isInfoEnabled() : false; }
From source file:com.github.maven_nar.NarUtil.java
License:Apache License
public static int runCommand(final String cmd, final String[] args, final File workingDirectory, final String[] env, final Log log) throws MojoExecutionException, MojoFailureException { if (log.isInfoEnabled()) { final StringBuilder argLine = new StringBuilder(); if (args != null) { for (final String arg : args) { argLine.append(" " + arg); }/* www . j ava 2 s. c o m*/ } if (workingDirectory != null) { log.info("+ cd " + workingDirectory.getAbsolutePath()); } log.info("+ " + cmd + argLine); } return runCommand(cmd, args, workingDirectory, env, new TextStream() { @Override public void println(final String text) { log.info(text); } }, new TextStream() { @Override public void println(final String text) { log.error(text); } }, new TextStream() { @Override public void println(final String text) { log.debug(text); } }, log); }
From source file:com.google.dart.util.UnpackUtil.java
License:Apache License
private static void logUnpack(final File file, final File location, final Log logger) { if (!logger.isInfoEnabled()) { return;//from w w w.j av a 2s.co m } final StringBuffer msg = new StringBuffer(); msg.append("Unpacking "); msg.append(file); msg.append(" to "); msg.append(location); logger.info(msg.toString()); }
From source file:com.google.dart.util.UnpackUtil.java
License:Apache License
private static void logUnpackDone(final File file, final File location, final Log logger) { if (!logger.isInfoEnabled()) { return;// ww w . ja va 2s . c o m } final StringBuffer msg = new StringBuffer(); msg.append("Unpacked "); msg.append(file); msg.append(" to "); msg.append(location); logger.info(msg.toString()); }