List of usage examples for org.apache.maven.plugin.logging Log error
void error(CharSequence content, Throwable error);
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 ww . j av a2s. co 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./*from www . ja v a 2s . 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 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 error log level. </p> * @param message log this message.//from w w w . j a va2 s. c o m * @param error the error to log. * @param mavenLog the actual {@link Log} used for logging. */ protected void error(@NotNull final Object message, @NotNull final Throwable error, @NotNull final Log mavenLog) { mavenLog.error(message.toString(), error); }
From source file:org.acmsl.queryj.tools.maven.CommonsLoggingMavenLogAdapter.java
License:Open Source License
/** * <p> Log a message with fatal log level. </p> * @param message log this message./*from w w w . j a v a 2s .c o m*/ * @param fatal the fatal to log. * @param mavenLog the actual {@link Log} used for logging. */ protected void fatal(@NotNull final Object message, @NotNull final Throwable fatal, @NotNull final Log mavenLog) { mavenLog.error(message.toString(), fatal); }
From source file:org.apache.hyracks.maven.license.SupplementalModelHelper.java
License:Apache License
static Map<String, Model> loadSupplements(Log log, String[] models) throws MojoExecutionException { if (models == null) { log.debug("Supplemental data models won't be loaded. " + "No models specified."); return Collections.emptyMap(); }//w w w.j a v a2 s . co m List<Supplement> supplements = new ArrayList<>(); for (String set : models) { log.debug("Preparing ruleset: " + set); try { File f = new File(set); if (!f.exists()) { throw new MojoExecutionException("Cold not resolve " + set); } if (!f.canRead()) { throw new MojoExecutionException("Supplemental data models won't be loaded. " + "File " + f.getAbsolutePath() + " cannot be read, check permissions on the file."); } log.debug("Loading supplemental models from " + f.getAbsolutePath()); SupplementalDataModelXpp3Reader reader = new SupplementalDataModelXpp3Reader(); try (FileInputStream fis = new FileInputStream(f); Reader fileReader = new InputStreamReader(fis)) { SupplementalDataModel supplementalModel = reader.read(fileReader); supplements.addAll(supplementalModel.getSupplement()); } } catch (Exception e) { String msg = "Error loading supplemental data models: " + e.getMessage(); log.error(msg, e); throw new MojoExecutionException(msg, e); } } log.debug("Loading supplements complete."); Map<String, Model> supplementMap = new HashMap<>(); for (Supplement sd : supplements) { Xpp3Dom dom = (Xpp3Dom) sd.getProject(); Model m = getSupplement(log, dom); supplementMap.put(generateSupplementMapKey(m.getGroupId(), m.getArtifactId()), m); } return supplementMap; }
From source file:org.apache.james.mailet.DefaultDescriptorsExtractor.java
License:Apache License
private URLClassLoader classLoader(MavenProject project, Log log) { URLClassLoader classLoader = null; try {/*from w ww.j ava 2 s . com*/ @SuppressWarnings("unchecked") final List<String> cpes = project.getCompileClasspathElements(); final int size = cpes.size(); final URL[] urls = new URL[size]; for (int k = 0; k < size; k++) { if (log.isDebugEnabled()) { log.debug("CPE: " + cpes.get(k)); } urls[k] = new File(cpes.get(k)).toURI().toURL(); } classLoader = new URLClassLoader(urls); } catch (DependencyResolutionRequiredException e) { log.error("Failed to load project dependencies.", e); } catch (MalformedURLException e) { log.error("Cannot build classloader from project URLs.", e); } return classLoader; }
From source file:org.apache.pluto.maven.AssembleMojo.java
License:Apache License
protected void doExecute() throws MojoExecutionException { // Log parameter values. Log log = getLog(); if (log.isInfoEnabled()) { if (archives == null || archives.isEmpty()) { log.info("Reading web.xml from :" + webXml.getAbsolutePath()); log.info("Reading portlet.xml from: " + portletXml.getAbsolutePath()); log.info("Writing web.xml to: " + webXmlDestination.getAbsolutePath()); }/*from w ww .j a va2s. c om*/ } try { // Assemble portlet app by updating web.xml. if (archives == null || archives.isEmpty()) { AssemblerConfig config = createAssemblerConfig(); Assembler assembler = AssemblerFactory.getFactory().createAssembler(config); assembler.assemble(config); } else { for (Iterator i = archives.iterator(); i.hasNext();) { File archive = new File(i.next().toString()); if (log.isInfoEnabled()) { log.info("Assembling archive file " + archive.getAbsolutePath() + " to directory " + assemblyOutputDirectory.getAbsolutePath()); } AssemblerConfig config = createArchiveAssemblerConfig(archive, assemblyOutputDirectory); Assembler assembler = AssemblerFactory.getFactory().createAssembler(config); assembler.assemble(config); } } } catch (UtilityException e) { log.error("Assembly failed: " + e.getMessage(), e); } }
From source file:org.apache.tomcat.maven.common.run.DefaultClassLoaderEntriesCalculator.java
License:Apache License
private void deleteDirectory(File directory, Log log) throws TomcatRunException { try {//w w w. j a va 2 s . co m FileUtils.deleteDirectory(directory); } catch (IOException e) { log.error("fail to delete directory file " + directory + ", reason:" + e.getMessage(), e); throw new TomcatRunException(e.getMessage(), e); } }
From source file:org.apache.tomcat.maven.common.run.EmbeddedRegistry.java
License:Apache License
/** * Reports the exception. If a log is given (typically when called from within a Mojo) the * message will be printed to the log. Otherwise it will be printed to StdErr. * * @param log the log to write the message to; null to write to stderr * @param e exception which shall be reported * @param message message which shall be reported *//* w w w.j av a 2s. c om*/ private void error(final Log log, final Exception e, final String message) { if (log == null) { System.err.println("ERROR: " + message); e.printStackTrace(); } else { log.error(message, e); } }
From source file:org.boretti.drools.integration.drools5.DroolsClassProcessor.java
License:Open Source License
public static void ClassProcessor(Log logger, File src, DroolsGoalExecutionLogs dgel) throws MojoExecutionException { if (src == null) return;//from w ww . j av a2 s . co m try { DroolsGoalExecutionLog del = new DroolsGoalExecutionLog(src.getAbsolutePath(), "postprocessor", "Class defined by file " + src.getAbsolutePath() + " has been rewritten by the plugin"); FileInputStream fis = new FileInputStream(src); ClassReader cr = new ClassReader(fis); ClassWriter cw = new ClassWriter(cr, 0); DroolsClassVisitor dcv = new DroolsClassVisitor(logger, cw, del); cr.accept(dcv, ClassReader.EXPAND_FRAMES); byte clazz[] = cw.toByteArray(); fis.close(); if (dcv.isNeedChange()) { logger.info("File " + src + " must be rewritten."); fis.close(); FileOutputStream fos = new FileOutputStream(src); fos.write(clazz); dgel.getLogs().add(del); } } catch (FileNotFoundException e) { logger.error("" + e.getMessage(), e); throw new MojoExecutionException("" + e.getMessage(), e); } catch (IOException e) { logger.error("" + e.getMessage(), e); throw new MojoExecutionException("" + e.getMessage(), e); } }