List of usage examples for org.apache.maven.plugin.logging Log info
void info(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 ww w . j a v a 2 s .c om*/ * @param message the message. * @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, final int msgLevel, @NotNull final Log log) { @NotNull final String t_strMessage = "[" + task.getTaskName() + "] " + message; switch (msgLevel) { case MSG_ERR: log.error(t_strMessage); break; case MSG_WARN: log.warn(t_strMessage); break; case MSG_VERBOSE: case MSG_DEBUG: log.debug(t_strMessage); break; default: log.info(t_strMessage); 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.// www. j a va2s . c om * @param message the message. * @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, final int msgLevel, @NotNull final Log log) { @NotNull final String t_strMessage = "[" + target.getName() + "] " + message; switch (msgLevel) { case MSG_ERR: log.error(t_strMessage); break; case MSG_WARN: log.warn(t_strMessage); break; case MSG_VERBOSE: case MSG_DEBUG: log.debug(t_strMessage); break; default: log.info(t_strMessage); break; } }
From source file:org.acmsl.queryj.tools.maven.CommonsLoggingMavenLogAdapter.java
License:Open Source License
/** * <p> Log a message with info log level. </p> * @param message log this message./*from w w w .j a va 2 s.co m*/ * @param mavenLog the actual {@link Log} used for logging. */ protected void info(@NotNull final Object message, @NotNull final Log mavenLog) { mavenLog.info(message.toString()); }
From source file:org.acmsl.queryj.tools.maven.CommonsLoggingMavenLogAdapter.java
License:Open Source License
/** * <p> Log a message with info log level. </p> * @param info the info to log.//w ww . j a va 2s . com * @param mavenLog the actual {@link Log} used for logging. */ protected void info(@NotNull final Throwable info, @NotNull final Log mavenLog) { mavenLog.info(info); }
From source file:org.acmsl.queryj.tools.maven.QueryJMojo.java
License:Open Source License
/** * Executes QueryJ via Maven2./*from www. ja v a2 s .com*/ * @param log the Maven log. * @param version the QueryJ version. * @throws MojoExecutionException if the process fails. */ protected void execute(@NotNull final Log log, final String version) throws MojoExecutionException { boolean running = false; @Nullable final File outputDirPath = getOutputDir(); @Nullable final QueryJTask task; if (outputDirPath != null) { //initialize directories @NotNull final File outputDir = outputDirPath.getAbsoluteFile(); if ((!outputDir.exists()) && (!outputDir.mkdirs())) { log.warn("Cannot create output folder: " + outputDir); } //execute task task = buildTask(version, log); log.info("Running QueryJ " + version); task.execute(); running = true; } else { log.error("outputDir is null"); } if (!running) { log.error("NOT running QueryJ " + version); throw new MojoExecutionException("QueryJ could not start"); } }
From source file:org.antlr.mojo.antlr4.Antlr4Mojo.java
License:BSD License
/** * The main entry point for this Mojo, it is responsible for converting * ANTLR 4.x grammars into the target language specified by the grammar. * * @exception MojoExecutionException if a configuration or grammar error causes * the code generation process to fail/* w w w .j av a2s . c o m*/ * @exception MojoFailureException if an instance of the ANTLR 4 {@link Tool} * cannot be created */ @Override public void execute() throws MojoExecutionException, MojoFailureException { Log log = getLog(); if (log.isDebugEnabled()) { for (String e : excludes) { log.debug("ANTLR: Exclude: " + e); } for (String e : includes) { log.debug("ANTLR: Include: " + e); } log.debug("ANTLR: Output: " + outputDirectory); log.debug("ANTLR: Library: " + libDirectory); } if (!sourceDirectory.isDirectory()) { log.info("No ANTLR 4 grammars to compile in " + sourceDirectory.getAbsolutePath()); return; } // Ensure that the output directory path is all in tact so that // ANTLR can just write into it. // File outputDir = getOutputDirectory(); if (!outputDir.exists()) { outputDir.mkdirs(); } // Now pick up all the files and process them with the Tool // List<List<String>> argumentSets; try { List<String> args = getCommandArguments(); argumentSets = processGrammarFiles(args, sourceDirectory); } catch (InclusionScanException ie) { log.error(ie); throw new MojoExecutionException( "Fatal error occured while evaluating the names of the grammar files to analyze", ie); } log.debug("Output directory base will be " + outputDirectory.getAbsolutePath()); log.info("ANTLR 4: Processing source directory " + sourceDirectory.getAbsolutePath()); for (List<String> args : argumentSets) { try { // Create an instance of the ANTLR 4 build tool tool = new CustomTool(args.toArray(new String[args.size()])); } catch (Exception e) { log.error("The attempt to create the ANTLR 4 build tool failed, see exception report for details", e); throw new MojoFailureException("Error creating an instanceof the ANTLR tool.", e); } // Set working directory for ANTLR to be the base source directory tool.inputDirectory = sourceDirectory; tool.processGrammarsOnCommandLine(); // If any of the grammar files caused errors but did nto throw exceptions // then we should have accumulated errors in the counts if (tool.getNumErrors() > 0) { throw new MojoExecutionException("ANTLR 4 caught " + tool.getNumErrors() + " build errors."); } } if (project != null) { // Tell Maven that there are some new source files underneath the output directory. addSourceRoot(this.getOutputDirectory()); } }
From source file:org.apache.axis2.maven2.repo.ArchiveDeployer.java
License:Apache License
public void deploy(Log log, Artifact artifact) throws MojoExecutionException { StringBuilder buffer = new StringBuilder(artifact.getArtifactId()); if (!stripVersion) { buffer.append("-"); buffer.append(artifact.getVersion()); }/*from ww w . j ava 2 s .c o m*/ buffer.append("."); buffer.append(artifact.getType()); String destFileName = buffer.toString(); log.info("Adding " + destFileName); try { FileUtils.copyFile(artifact.getFile(), new File(directory, destFileName)); } catch (IOException ex) { throw new MojoExecutionException("Error copying " + destFileName + ": " + ex.getMessage(), ex); } files.add(destFileName); }
From source file:org.apache.axis2.maven2.repo.ArchiveDeployer.java
License:Apache License
public void finish(Log log) throws MojoExecutionException { if (generateFileList && !files.isEmpty()) { log.info("Writing " + fileListName); try {/* w ww . ja va 2 s . c om*/ OutputStream out = new FileOutputStream(new File(directory, fileListName)); try { Writer writer = new OutputStreamWriter(out, "UTF-8"); for (String file : files) { writer.write(file); writer.write('\n'); } writer.flush(); } finally { out.close(); } } catch (IOException ex) { throw new MojoExecutionException("Error writing " + fileListName + ": " + ex.getMessage(), ex); } } }
From source file:org.apache.camel.guice.maven.DotMojo.java
License:Apache License
protected String convertFile(File file, String format) throws CommandLineException { Log log = getLog(); if (!useDot) { log.info("DOT generation disabled"); return null; }//w w w . j av a 2 s.com if (this.executable == null || this.executable.length() == 0) { log.warn("Parameter <executable/> was not set in the pom.xml. Skipping conversion."); return null; } String generatedFileName = removeFileExtension(file.getAbsolutePath()) + "." + format; Commandline cl = new Commandline(); cl.setExecutable(executable); cl.createArg().setValue("-T" + format); cl.createArg().setValue("-o"); cl.createArg().setValue(generatedFileName); cl.createArg().setValue(file.getAbsolutePath()); log.debug("executing: " + cl.toString()); CommandLineUtils.StringStreamConsumer stdout = new CommandLineUtils.StringStreamConsumer(); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); CommandLineUtils.executeCommandLine(cl, stdout, stderr); String output = stdout.getOutput(); if (output.length() > 0) { log.debug(output); } String errOutput = stderr.getOutput(); if (errOutput.length() > 0) { log.warn(errOutput); } return generatedFileName; }
From source file:org.apache.camel.maven.DotMojo.java
License:Apache License
protected String convertFile(File file, String format) throws CommandLineException { Log log = getLog(); if (!useDot) { log.info("DOT generation disabled."); return null; } else {/*from w w w . ja v a2 s .co m*/ if (dotHelpExitCode() != 0) { log.info("'dot -?' execution failed so DOT generation disabled."); return null; } } if (this.executable == null || this.executable.length() == 0) { log.warn("Parameter <executable/> was not set in the pom.xml. Skipping conversion."); return null; } String generatedFileName = removeFileExtension(file.getAbsolutePath()) + "." + format; Commandline cl = new Commandline(); cl.setExecutable(executable); cl.createArg().setValue("-T" + format); cl.createArg().setValue("-o"); cl.createArg().setValue(generatedFileName); cl.createArg().setValue(file.getAbsolutePath()); log.debug("executing: " + cl.toString()); CommandLineUtils.StringStreamConsumer stdout = new CommandLineUtils.StringStreamConsumer(); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); CommandLineUtils.executeCommandLine(cl, stdout, stderr); String output = stdout.getOutput(); if (output.length() > 0) { log.debug(output); } String errOutput = stderr.getOutput(); if (errOutput.length() > 0) { log.warn(errOutput); } return generatedFileName; }