List of usage examples for org.apache.maven.plugin.logging Log error
void error(Throwable error);
From source file:org.yuanheng.cookcc.maven.JavacTask.java
License:Apache License
public void execute(Log log, Compiler compiler, CompilerConfiguration config, String javaSrcDir, String cookccPath) throws MojoExecutionException { File file = new File(m_src); if (!file.isFile()) { throw new MojoExecutionException("File " + m_src + " does not exist."); }/* w ww . j av a 2 s . c o m*/ try { for (Option option : m_options) { if (option.arg == null) config.addCompilerCustomArgument("-A" + option.opt, null); else config.addCompilerCustomArgument("-A" + option.opt + "=" + option.arg, null); } HashSet<File> set = new HashSet<File>(); m_src.replace('/', File.separatorChar); log.info("CookCC is processing " + m_src); set.add(new File(m_src)); config.setSourceFiles(set); String[] args = compiler.createCommandLine(config); String msg = "javac"; for (String arg : args) msg += " " + arg; log.debug(msg); log.debug("Using compiler: " + compiler.getClass()); CompilerResult result = compiler.performCompile(config); log.debug("Success: " + result.isSuccess()); boolean hasError = false; StringBuilder errorMessages = new StringBuilder(); errorMessages.append( "CookCC reported an error. Please use mvn -X clean cookcc:run to display the full javac command to execute cookcc and reproduce the error message.\n"); log.debug("CompilerMessages: " + result.getCompilerMessages().size()); for (CompilerMessage message : result.getCompilerMessages()) { CompilerMessage.Kind kind = message.getKind(); switch (kind) { case WARNING: log.warn(message.toString()); break; case ERROR: log.error(message.toString()); errorMessages.append(message.getMessage()).append('\n'); hasError = true; break; default: log.info(kind + ": " + message.toString()); break; } } if (hasError || !result.isSuccess()) throw new MojoExecutionException(errorMessages.toString()); } catch (CompilerException ex) { throw new MojoExecutionException("Error compiling code", ex); } }
From source file:tv.bodil.testlol.JSLintRunner.java
License:MIT License
public int lint(Log log) throws IOException { int errors = 0; String pathPrefix = basePath.getCanonicalPath(); for (File file : sources) { String path = file.getCanonicalPath(); if (path.startsWith(pathPrefix)) { path = path.substring(pathPrefix.length() + 1); }// w w w.ja v a 2s .co m FileReader in = new FileReader(file); List<Issue> issues = jsLint.lint(path, in); if (issues.size() > 0) { errors += issues.size(); log.error("In file " + path + ":"); for (Issue issue : issues) { log.error(" " + issue.toString()); } } } return errors; }
From source file:uk.org.raje.maven.plugin.msbuild.MojoHelper.java
License:Apache License
/** * Validates the path to a command-line tool. * @param toolPath the configured tool path from the POM * @param toolName the name of the tool, used for logging messages * @param logger a Log to write messages to * @throws FileNotFoundException if the tool cannot be found *///from www. j ava 2 s . c o m public static void validateToolPath(File toolPath, String toolName, Log logger) throws FileNotFoundException { logger.debug("Validating path for " + toolName); if (toolPath == null) { logger.error("Missing " + toolName + " path"); throw new FileNotFoundException(); } if (!toolPath.exists() || !toolPath.isFile()) { logger.error("Could not find " + toolName + " at " + toolPath); throw new FileNotFoundException(toolPath.getAbsolutePath()); } logger.debug("Found " + toolName + " at " + toolPath); }
From source file:uk.org.raje.maven.plugin.msbuild.MSBuildCleanMojo.java
License:Apache License
private void cleanReports(File projectFile, String reportDirectory, String toolName, Log log) throws MojoFailureException { final DirectoryScanner directoryScanner = new DirectoryScanner(); directoryScanner.setIncludes(new String[] { "**\\" + reportDirectory }); directoryScanner.setBasedir(projectFile.getParentFile()); directoryScanner.scan();/* w ww .j a va 2s . com*/ log.info("Cleaning up " + toolName + " reports"); for (String directoryName : directoryScanner.getIncludedDirectories()) { final File directory = new File(projectFile.getParentFile(), directoryName); log.debug("Deleting directory " + directory); try { FileUtils.deleteDirectory(directory); } catch (IOException ioe) { log.error("Failed to delete directory " + directory); throw new MojoFailureException(ioe.getMessage(), ioe); } } log.info(toolName + " report clean-up complete"); }