List of usage examples for org.apache.maven.plugin.logging Log warn
void warn(Throwable error);
From source file:org.mule.devkit.maven.AbstractGitHubMojo.java
License:Open Source License
/** * Log given message at warn level/*from w w w. j a v a 2s .c o m*/ * * @param message */ protected void warn(String message) { Log log = getLog(); if (log != null) { log.warn(message); } }
From source file:org.mule.tools.jshint.JSHintMojo.java
License:Open Source License
@Override public void execute() throws MojoExecutionException, MojoFailureException { Log log = getLog(); sourceDirectory = sourceDirectory.getAbsoluteFile(); if (!(sourceDirectory.exists() && sourceDirectory.isDirectory())) { log.warn(String.format("Not executing jshint as the source directory [%s] does not exist.", sourceDirectory));// ww w . j a v a 2 s . co m return; } InputStream inputStream; boolean errors = false; for (String file : getIncludedFiles()) { log.info(String.format("Checking [%s]", file)); try { inputStream = new FileInputStream(file); } catch (FileNotFoundException e) { throw new MojoExecutionException(String.format("Error loading file [%s]", file), e); } if (!new JSHint(new WrappingConsoleFactory(MavenConsole.fromMavenLog(log)), getJavascriptFilesDirectory()).check(file, inputStream, config)) { errors = true; } } if (errors) { throw new MojoFailureException("Errors were found while performing jshint over Javascript code"); } log.info("No problems found in analyzed Javascript files."); }
From source file:org.onos.yangtools.yang2sources.plugin.Util.java
License:Open Source License
static Collection<File> listFiles(File root, File[] excludedFiles, Log log) throws FileNotFoundException { if (!root.exists()) { if (log != null) { log.warn(Util.message("YANG source directory %s not found. No code will be generated.", YangToSourcesProcessor.LOG_PREFIX, root.toString())); }/*from www . j a v a 2 s . c o m*/ return Collections.emptyList(); } Collection<File> result = new ArrayList<>(); Collection<File> yangFiles = FileUtils.listFiles(root, new String[] { YANG_SUFFIX }, true); for (File f : yangFiles) { boolean excluded = false; for (File ex : excludedFiles) { if (ex.equals(f)) { excluded = true; break; } } if (excluded) { if (log != null) { log.info(Util.message("%s file excluded %s", YangToSourcesProcessor.LOG_PREFIX, Util.YANG_SUFFIX.toUpperCase(), f)); } } else { result.add(f); } } return result; }
From source file:org.onos.yangtools.yang2sources.plugin.Util.java
License:Open Source License
/** * Read current project dependencies and check if it don't grab incorrect * artifacts versions which could be in conflict with plugin dependencies. * * @param project/*w w w . ja v a2s. c o m*/ * current project * @param repoSystem * repository system * @param localRepo * local repository * @param remoteRepos * remote repositories * @param log * logger */ static void checkClasspath(MavenProject project, RepositorySystem repoSystem, ArtifactRepository localRepo, List<ArtifactRepository> remoteRepos, Log log) { Plugin plugin = project.getPlugin(YangToSourcesMojo.PLUGIN_NAME); if (plugin == null) { log.warn(message("%s not found, dependencies version check skipped", YangToSourcesProcessor.LOG_PREFIX, YangToSourcesMojo.PLUGIN_NAME)); } else { Map<Artifact, Collection<Artifact>> pluginDependencies = new HashMap<>(); getPluginTransitiveDependencies(plugin, pluginDependencies, repoSystem, localRepo, remoteRepos, log); Set<Artifact> projectDependencies = project.getDependencyArtifacts(); for (Map.Entry<Artifact, Collection<Artifact>> entry : pluginDependencies.entrySet()) { checkArtifact(entry.getKey(), projectDependencies, log); for (Artifact dependency : entry.getValue()) { checkArtifact(dependency, projectDependencies, log); } } } }
From source file:org.onos.yangtools.yang2sources.plugin.Util.java
License:Open Source License
/** * Check artifact against collection of dependencies. If collection contains * artifact with same groupId and artifactId, but different version, logs a * warning.//from w w w . j a va 2 s . c o m * * @param artifact * artifact to check * @param dependencies * collection of dependencies * @param log * logger */ private static void checkArtifact(Artifact artifact, Collection<Artifact> dependencies, Log log) { for (org.apache.maven.artifact.Artifact d : dependencies) { if (artifact.getGroupId().equals(d.getGroupId()) && artifact.getArtifactId().equals(d.getArtifactId())) { if (!(artifact.getVersion().equals(d.getVersion()))) { log.warn(message("Dependency resolution conflict:", YangToSourcesProcessor.LOG_PREFIX)); log.warn(message( "'%s' dependency [%s] has different version than one " + "declared in current project [%s]. It is recommended to fix this problem " + "because it may cause compilation errors.", YangToSourcesProcessor.LOG_PREFIX, YangToSourcesMojo.PLUGIN_NAME, artifact, d)); } } } }
From source file:org.openengsb.openengsbplugin.tools.DefaultMavenExecutor.java
License:Apache License
private void logAndPassOnExceptionIfAny(MavenExecutionResult result, Log log) throws MojoExecutionException { if (result.hasExceptions()) { log.warn("###################"); log.warn("The following exceptions occured during execution:"); for (Throwable t : result.getExceptions()) { log.warn("--------"); log.warn(t);/* w w w. ja v a2 s.co m*/ } log.warn("###################"); Throwable ex = result.getExceptions().get(0); Throwable cause = ex.getCause(); String errmsg = cause != null ? cause.getMessage() : ex.getMessage(); throw new MojoExecutionException( String.format("%s\nFAIL - see log statements above for additional info", errmsg)); } }
From source file:org.phpmaven.core.ExecutionUtils.java
License:Apache License
/** * Executes a command.//from w ww .j av a2 s . com * @param log the logger * @param command command line * @param workDir working directory * @return result string. * @throws CommandLineException throw on execution errors. */ public static String executeCommand(Log log, String command, final File workDir) throws CommandLineException { final Commandline cli = new Commandline(command); if (log != null) { log.debug("Executing " + command); } if (workDir != null) { if (!workDir.exists()) { workDir.mkdirs(); } cli.setWorkingDirectory(workDir); } final StringBuilder stdout = new StringBuilder(); final StringBuilder stderr = new StringBuilder(); final StreamConsumer systemOut = new StreamConsumer() { @Override public void consumeLine(String line) { stdout.append(line); stdout.append("\n"); } }; final StreamConsumer systemErr = new StreamConsumer() { @Override public void consumeLine(String line) { stderr.append(line); stderr.append("\n"); } }; try { final int result = CommandLineUtils.executeCommandLine(cli, systemOut, systemErr); if (result != 0) { if (log != null) { log.warn("Error invoking command. Return code " + result + "\n\nstd-out:\n" + stdout + "\n\nstd-err:\n" + stderr); } throw new CommandLineException("Error invoking command. Return code " + result); } } catch (CommandLineException ex) { if (log != null) { log.warn("Error invoking command\n\nstd-out:\n" + stdout + "\n\nstd-err:\n" + stderr); } throw ex; } if (log != null) { log.debug("stdout: " + stdout.toString()); } return stdout.toString(); }
From source file:org.phpmaven.phpnar.CompileMojo.java
License:Apache License
/** * Executes a command.//from w ww. j a v a 2 s .c o m * @param log the logger * @param command command line * @param workDir working directory * @throws CommandLineException throw on execution errors. */ private static void executeCommand(final Log log, final String command, final File workDir) throws CommandLineException { final Commandline cli = new Commandline(command); if (log != null) { log.debug("Executing " + command); } if (workDir != null) { if (!workDir.exists()) { workDir.mkdirs(); } cli.setWorkingDirectory(workDir); } final StreamConsumer systemOut = new StreamConsumer() { @Override public void consumeLine(String line) { log.info(line); } }; final StreamConsumer systemErr = new StreamConsumer() { @Override public void consumeLine(String line) { log.warn(line); } }; try { final int result = CommandLineUtils.executeCommandLine(cli, systemOut, systemErr); if (result != 0) { if (log != null) { log.warn("Error invoking command. Return code " + result); } throw new CommandLineException("Error invoking command. Return code " + result); } } catch (CommandLineException ex) { if (log != null) { log.warn("Error invoking command"); } throw ex; } }
From source file:org.primefaces.extensions.optimizerplugin.AbstractOptimizer.java
License:Apache License
protected void deleteFilesIfNecessary(final ResourcesSetAdapter rsa, final Log log) { if (rsa.getAggregation().isRemoveIncluded() && rsa.getFiles().size() > 0) { for (File file : rsa.getFiles()) { if (file.exists() && !file.delete()) { log.warn("File " + file.getName() + " could not be deleted after aggregation."); }//w w w.ja v a 2s .co m } } }
From source file:org.primefaces.extensions.optimizerplugin.ClosureCompilerOptimizer.java
License:Apache License
protected void evalResult(final Result result, final Log log, final boolean failOnWarning) throws MojoExecutionException { if (result.warnings != null) { for (JSError warning : result.warnings) { log.warn(warning.toString()); }/*from www. j a v a 2 s . com*/ } if (result.warnings != null && result.warnings.length > 0 && failOnWarning) { throw new MojoExecutionException("Resources optimization failure. Please fix warnings and try again."); } if (result.errors != null) { for (JSError error : result.errors) { log.error(error.toString()); } } if (result.errors != null && result.errors.length > 0) { throw new MojoExecutionException("Resources optimization failure. Please fix errors and try again."); } if (!result.success) { throw new MojoExecutionException("Resources optimization failure. Please fix errors and try again."); } }