List of usage examples for org.apache.maven.plugin.logging Log debug
void debug(CharSequence content, Throwable error);
From source file:com.github.maven.plugins.core.GitHubProjectMojo.java
License:Open Source License
/** * Log given message and throwable at debug level * //w w w . j a va 2s.com * @param message * @param throwable */ protected void debug(String message, Throwable throwable) { final Log log = getLog(); if (log != null) log.debug(message, throwable); }
From source file:org.acmsl.queryj.tools.maven.AntProjectAdapter.java
License:Open Source License
/** * See {@link Project#log(String, Throwable, int)}. * @param message the message./*from www . ja v a2s .c om*/ * @param throwable the error. * @param msgLevel either {@link Project#MSG_ERR}, {@link Project#MSG_WARN}, * {@link Project#MSG_INFO}, {@link Project#MSG_VERBOSE}, or {@link Project#MSG_DEBUG}. * @param log the {@link Log} instance. */ protected void log(@NotNull final String message, @NotNull final Throwable throwable, final int msgLevel, @NotNull final Log log) { switch (msgLevel) { case MSG_ERR: log.error(message, throwable); break; case MSG_WARN: log.warn(message, throwable); break; case MSG_VERBOSE: case MSG_DEBUG: log.debug(message, throwable); break; default: log.info(message, throwable); break; } }
From source file:org.acmsl.queryj.tools.maven.AntProjectAdapter.java
License:Open Source License
/** * See {@link Project#log(Task, String, int)}. * @param task the task.//from w w w . j a v a 2 s. c o m * @param message the message. * @param throwable the error. * @param msgLevel either {@link Project#MSG_ERR}, {@link Project#MSG_WARN}, * {@link Project#MSG_INFO}, {@link Project#MSG_VERBOSE}, or {@link Project#MSG_DEBUG}. * @param log the {@link Log} instance. */ protected void log(@NotNull final Task task, @NotNull final String message, @NotNull final Throwable throwable, final int msgLevel, @NotNull final Log log) { @NotNull final String t_strMessage = "[" + task.getTaskName() + "] " + message; switch (msgLevel) { case MSG_ERR: log.error(t_strMessage, throwable); break; case MSG_WARN: log.warn(t_strMessage, throwable); break; case MSG_VERBOSE: case MSG_DEBUG: log.debug(t_strMessage, throwable); break; default: log.info(t_strMessage, throwable); break; } }
From source file:org.acmsl.queryj.tools.maven.AntProjectAdapter.java
License:Open Source License
/** * See {@link Project#log(Target, String, int)}. * @param target the target.// w w w .j a va 2 s .com * @param message the message. * @param throwable the error. * @param msgLevel either {@link Project#MSG_ERR}, {@link Project#MSG_WARN}, * {@link Project#MSG_INFO}, {@link Project#MSG_VERBOSE}, or {@link Project#MSG_DEBUG}. * @param log the {@link Log} instance. */ protected void log(@NotNull final Target target, @NotNull final String message, @NotNull final Throwable throwable, final int msgLevel, @NotNull final Log log) { @NotNull final String t_strMessage = "[" + target.getName() + "] " + message; switch (msgLevel) { case MSG_ERR: log.error(t_strMessage, throwable); break; case MSG_WARN: log.warn(t_strMessage, throwable); break; case MSG_VERBOSE: log.debug(t_strMessage, throwable); log.debug(t_strMessage, throwable); break; default: log.info(t_strMessage, throwable); break; } }
From source file:org.acmsl.queryj.tools.maven.CommonsLoggingMavenLogAdapter.java
License:Open Source License
/** * <p> Log a message with trace log level. </p> * @param message log this message./*w w w . jav a2 s . c o m*/ * @param error the error to log. * @param mavenLog the actual {@link Log} used for logging. */ protected void trace(@NotNull final Object message, @NotNull final Throwable error, @NotNull final Log mavenLog) { mavenLog.debug(message.toString(), error); }
From source file:org.acmsl.queryj.tools.maven.CommonsLoggingMavenLogAdapter.java
License:Open Source License
/** * <p> Log a message with debug log level. </p> * @param message log this message.// w w w. ja v a 2 s. co m * @param error the error to log. * @param mavenLog the actual {@link Log} used for logging. */ protected void debug(@NotNull final Object message, @NotNull final Throwable error, @NotNull final Log mavenLog) { mavenLog.debug(message.toString(), error); }
From source file:org.codehaus.mojo.cassandra.Utils.java
License:Apache License
/** * Stops the Cassandra service./*from w ww.j av a2 s . c o m*/ * * @param rpcAddress The rpcAddress to connect to in order to see if Cassandra has stopped. * @param rpcPort The rpcPort to connect on to check if Cassandra has stopped. * @param stopPort The port to stop on. * @param stopKey The key to stop with, * @param log The log to write to. */ static void stopCassandraServer(String rpcAddress, int rpcPort, String stopAddress, int stopPort, String stopKey, Log log) { try { Socket s = new Socket(InetAddress.getByName(stopAddress), stopPort); s.setSoLinger(false, 0); OutputStream out = s.getOutputStream(); out.write((stopKey + "\r\nstop\r\n").getBytes()); out.flush(); s.close(); } catch (ConnectException e) { log.info("Cassandra not running!"); return; } catch (Exception e) { log.error(e); return; } log.info("Waiting for Cassandra to stop..."); long maxWaiting = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(30); boolean stopped = false; while (!stopped && System.currentTimeMillis() < maxWaiting) { TTransport tr = new TFramedTransport(new TSocket(rpcAddress, rpcPort)); try { TProtocol proto = new TBinaryProtocol(tr); Cassandra.Client client = new Cassandra.Client(proto); try { tr.open(); } catch (TTransportException e) { if (e.getCause() instanceof ConnectException) { stopped = true; continue; } log.debug(e.getLocalizedMessage(), e); try { Thread.sleep(500); } catch (InterruptedException e1) { // ignore } } } finally { if (tr.isOpen()) { tr.close(); } } } if (stopped) { log.info("Cassandra has stopped."); } else { log.warn("Gave up waiting for Cassandra to stop."); } }
From source file:org.codehaus.mojo.cassandra.Utils.java
License:Apache License
/** * Waits until the Cassandra server at the specified RPC address and port has started accepting connections. * * @param rpcAddress The RPC address to connect to. * @param rpcPort The RPC port to connect on. * @param startWaitSeconds The maximum number of seconds to wait. * @param log the {@link Log} to log to. * @return {@code true} if Cassandra is started. * @throws MojoExecutionException if something went wrong. */// www.j ava 2 s . c o m static boolean waitUntilStarted(String rpcAddress, int rpcPort, int startWaitSeconds, Log log) throws MojoExecutionException { long maxWaiting = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(startWaitSeconds); while (startWaitSeconds == 0 || System.currentTimeMillis() < maxWaiting) { TTransport tr = new TFramedTransport(new TSocket(rpcAddress, rpcPort)); try { TProtocol proto = new TBinaryProtocol(tr); Cassandra.Client client = new Cassandra.Client(proto); try { tr.open(); } catch (TTransportException e) { if (!(e.getCause() instanceof ConnectException)) { log.debug(e.getLocalizedMessage(), e); } try { Thread.sleep(500); } catch (InterruptedException e1) { // ignore } continue; } try { log.info("Cassandra cluster \"" + client.describe_cluster_name() + "\" started."); return true; } catch (TException e) { throw new MojoExecutionException(e.getLocalizedMessage(), e); } } finally { if (tr.isOpen()) { tr.close(); } } } return false; }
From source file:org.codehaus.mojo.versions.api.PomHelper.java
License:Apache License
/** * Builds a sub-map of raw models keyed by module path. * * @param path The relative path to base the sub-map on. * @param model The model at the relative path. * @param project The project to build from. * @param logger The logger for logging. * @return A map of raw models keyed by path relative to the project's basedir. * @throws IOException if things go wrong. *///from ww w.j ava2 s. co m private static Map<String, Model> getReactorModels(String path, Model model, MavenProject project, Log logger) throws IOException { if (path.length() > 0 && !path.endsWith("/")) { path += '/'; } Map<String, Model> result = new LinkedHashMap<String, Model>(); Map<String, Model> childResults = new LinkedHashMap<String, Model>(); File baseDir = path.length() > 0 ? new File(project.getBasedir(), path) : project.getBasedir(); Set<String> childModules = getAllChildModules(model, logger); removeMissingChildModules(logger, baseDir, childModules); for (String moduleName : childModules) { String modulePath = path + moduleName; File moduleDir = new File(baseDir, moduleName); File moduleProjectFile; if (moduleDir.isDirectory()) { moduleProjectFile = new File(moduleDir, "pom.xml"); } else { // i don't think this should ever happen... but just in case // the module references the file-name moduleProjectFile = moduleDir; } try { // the aim of this goal is to fix problems when the project cannot be parsed by Maven // so we have to work with the raw model and not the interpolated parsed model from maven Model moduleModel = getRawModel(moduleProjectFile); result.put(modulePath, moduleModel); childResults.putAll(getReactorModels(modulePath, moduleModel, project, logger)); } catch (IOException e) { logger.debug("Could not parse " + moduleProjectFile.getPath(), e); } } result.putAll(childResults); // more efficient update order if all children are added after siblings return result; }
From source file:org.codehaus.mojo.versions.branch.BranchMojo.java
License:Apache License
private static Map<String, ModelFileTuple> loadModels(String path, Model model, MavenProject project, Log logger) throws IOException { if (path.length() > 0 && !path.endsWith("/")) { path += '/'; }//from w w w .j av a 2 s.c o m Map<String, ModelFileTuple> result = new LinkedHashMap<>(); Map<String, ModelFileTuple> childResults = new LinkedHashMap<>(); File baseDir = path.length() > 0 ? new File(project.getBasedir(), path) : project.getBasedir(); Set<String> childModules = PomHelper.getAllChildModules(model, logger); PomHelper.removeMissingChildModules(logger, baseDir, childModules); for (String childModuleName : childModules) { String childModulePath = path + childModuleName; File childModuleDir = new File(baseDir, childModuleName); File childModuleProjectFile; if (childModuleDir.isDirectory()) { childModuleProjectFile = new File(childModuleDir, "pom.xml"); } else { // i don't think this should ever happen... but just in case // the module references the file-name childModuleProjectFile = childModuleDir; } try { // the aim of this goal is to fix problems when the project cannot be parsed by Maven // so we have to work with the raw model and not the interpolated parsed model from maven Model childModuleModel = getRawModel(childModuleProjectFile); result.put(moduleId(childModuleModel), new ModelFileTuple(childModuleModel, childModuleProjectFile)); childResults.putAll(loadModels(childModulePath, childModuleModel, project, logger)); } catch (IOException e) { logger.debug("Could not parse " + childModuleProjectFile.getPath(), e); } } result.putAll(childResults); // more efficient update order if all children are added after siblings return result; }