List of usage examples for org.apache.maven.plugin.logging Log warn
void warn(CharSequence content, Throwable error);
From source file:com.alibaba.citrus.maven.eclipse.base.eclipse.reader.ReadWorkspaceLocations.java
License:Apache License
/** * Scan the eclipse workspace and create a array with {@link IdeDependency} for all found artifacts. * * @param workspaceLocation the location of the eclipse workspace. * @param logger the logger to report errors and debug info. *//*from ww w. ja v a 2s. c om*/ private void readWorkspace(WorkspaceConfiguration workspaceConfiguration, Log logger) { ArrayList dependencies = new ArrayList(); if (workspaceConfiguration.getWorkspaceDirectory() != null) { File workspace = new File(workspaceConfiguration.getWorkspaceDirectory(), ReadWorkspaceLocations.METADATA_PLUGINS_ORG_ECLIPSE_CORE_RESOURCES_PROJECTS); File[] directories = workspace.listFiles(); for (int index = 0; directories != null && index < directories.length; index++) { File project = directories[index]; if (project.isDirectory()) { try { File projectLocation = getProjectLocation(workspaceConfiguration.getWorkspaceDirectory(), project); if (projectLocation != null) { logger.debug("read workpsace project " + projectLocation); IdeDependency ideDependency = readArtefact(projectLocation, logger); if (ideDependency != null) { dependencies.add(ideDependency); } } } catch (Exception e) { logger.warn("could not read workspace project:" + project, e); } } } } logger.debug(dependencies.size() + " from workspace " + workspaceConfiguration.getWorkspaceDirectory()); workspaceConfiguration.setWorkspaceArtefacts( (IdeDependency[]) dependencies.toArray(new IdeDependency[dependencies.size()])); }
From source file:com.carrotgarden.maven.aws.util.Util.java
License:BSD License
public static void overrideInstanceProps(final Log log, final Object instance, final String prefix, final Map<String, String> props) { final Set<Map.Entry<String, String>> entrySet = // new HashSet<Entry<String, String>>(props.entrySet()); final Class<?> klaz = instance.getClass(); for (final Map.Entry<String, String> entry : entrySet) { final String key = entry.getKey(); final String value = entry.getValue(); if (!key.startsWith(prefix)) { continue; }//from ww w. j a va2s .c o m props.remove(key); try { final Field field = findField(klaz, key); field.set(instance, value); log.info("override : " + key + "=" + value); } catch (final Exception e) { log.warn("override : invalid stack param=" + key, e); } } }
From source file:com.github.greengerong.NgProtractor.java
License:Apache License
private void executeCommand(final String cmd, final String logAction) { final Log log = getLog(); try {/* w ww . j a v a 2s . c om*/ log.info(String.format("execute %s running: %s", logAction, cmd)); final ProcessBuilder processBuilder = new ProcessBuilder(getCommandAccordingToOS(cmd)); final Process process = processBuilder.start(); final String runningInfo = IOUtil.toString(process.getInputStream()); log.info(runningInfo); } catch (IOException e) { log.warn(String.format("execute %s running script error", logAction), e); } }
From source file:com.puresoltechnologies.maven.plugins.license.AbstractValidationMojo.java
/** * Loads the artifact recursively./* w w w . j ava 2 s .c o m*/ * * @param artifact * @param recursive * specified whether all dependencies should be loaded * recursively. * @param skipTestScope * specified whether to skip test scoped artifacts or not. * @return A {@link DependencyTree} object is returned. * @throws MojoExecutionException * is thrown if anything unexpected goes wrong. */ private DependencyTree loadArtifacts(int depth, DependencyTree parentDependencyTree, Artifact artifact, boolean recursive, boolean skipTestScope, boolean skipProvidedScope, boolean skipOptionals) throws MojoExecutionException { Log log = getLog(); MavenProject parentArtifactProject; try { parentArtifactProject = mavenProjectBuilder.buildFromRepository(artifact, remoteArtifactRepositories, localRepository); } catch (ProjectBuildingException e) { log.warn("Could not load artifacts recursively. For artifact '" + ArtifactUtilities.toString(artifact) + "' the project creation failed.", e); return null; } @SuppressWarnings("unchecked") List<Dependency> dependencies = parentArtifactProject.getDependencies(); @SuppressWarnings("unchecked") List<License> licenses = parentArtifactProject.getLicenses(); DependencyTree dependencyTree = new DependencyTree(artifact, licenses); if (parentDependencyTree != null) { parentDependencyTree.addDependency(dependencyTree); } if ((dependencies != null) && ((recursive) || (artifact == mavenProject.getArtifact()))) { for (Dependency dependency : dependencies) { StringBuffer buffer = new StringBuffer(); if (log.isDebugEnabled()) { for (int i = 0; i < depth; i++) { buffer.append(" "); } buffer.append("\\-> "); log.debug(buffer.toString() + ArtifactUtilities.toString(dependency)); } if (skipTestScope && Artifact.SCOPE_TEST.equals(dependency.getScope())) { if (log.isDebugEnabled()) { log.debug(buffer.toString() + " >> test scope is skipped"); } continue; } if (skipProvidedScope && Artifact.SCOPE_PROVIDED.equals(dependency.getScope())) { if (log.isDebugEnabled()) { log.debug(buffer.toString() + " >> provided scope is skipped"); } continue; } if (skipOptionals && dependency.isOptional()) { if (log.isDebugEnabled()) { log.debug(buffer.toString() + " >> optional is skipped"); } continue; } if (hasCycle(dependencyTree, dependency)) { if (log.isDebugEnabled()) { log.debug(buffer.toString() + " >> cylce found and needs to be skipped"); } continue; } Artifact dependencyArtifact = DependencyUtilities.buildArtifact(artifact, dependency); loadArtifacts(depth + 1, dependencyTree, dependencyArtifact, recursive, skipTestScope, skipProvidedScope, skipOptionals); } } return dependencyTree; }
From source file:com.redhat.rcm.maven.plugin.buildmetadata.common.MojoUtils.java
License:Apache License
/** * Logs and creates the given exception. * * @param log the logger to use.//from ww w . j a v a 2 s. com * @param e the original exception to throw. * @param message the message to log and add to the mojo exception. * @return the exception that wraps the given exception. */ public static MojoExecutionException createException(final Log log, final Throwable e, final String message) { if (log.isWarnEnabled()) { log.warn(message, e); } return new MojoExecutionException(message, e); }
From source file:com.sixsq.slipstream.SlipStreamMojo.java
License:Apache License
private void closeReliably(Closeable closeable, Log log) { if (closeable != null) { try {//from ww w . j a v a2s .co m closeable.close(); } catch (IOException e) { log.warn("error closing HTTP client", e); } } }
From source file:de.mmichaelis.maven.mojo.mail.MailBulk.java
License:Apache License
/** * Adds the header information to the given message. * * @param message message to add the header to * @param log the log to report possible problems or debug statements to *///from w ww . j av a2 s . co m @Override public void addHeader(final MimeMessage message, final Log log) { try { message.addHeader("Precedence", "bulk"); message.addHeader("X-Auto-Response-Suppress", "OOF"); } catch (MessagingException e) { log.warn("Could not add headers for bulk emails.", e); } }
From source file:de.mmichaelis.maven.mojo.mail.MailExpiration.java
License:Apache License
/** * Adds the header information to the given message. * * @param message message to add the header to * @param log the log to report possible problems or debug statements to *//* w w w . j a v a2 s. co m*/ @Override public void addHeader(final MimeMessage message, final Log log) { if (date != null) { final String headerValue = MAIL_TIMESTAMP_FORMAT.format(date); try { message.addHeader(RFC1036_HEADER, headerValue); message.addHeader(RFC1327_HEADER, headerValue); } catch (MessagingException e) { log.warn("Could not add expiration headers.", e); } } }
From source file:de.mmichaelis.maven.mojo.mail.MailPriority.java
License:Apache License
/** * Adds the priority headers to the given email. * * @param message the message to modify/*from w w w . jav a2 s . c o m*/ * @param log the log to report possible problems or debug statements to */ public void addHeader(final MimeMessage message, final Log log) { try { message.addHeader("Importance", importance); message.addHeader("Priority", priority); message.addHeader("X-Priority", xpriority); } catch (MessagingException e) { log.warn("Could not add priority headers.", e); } }
From source file:de.smartics.maven.plugin.buildmetadata.common.MojoUtils.java
License:Apache License
/** * Logs and creates the given exception. * * @param log the logger to use./*w ww . j av a 2 s .co m*/ * @param exception the original exception to throw. * @param message the message to log and add to the mojo exception. * @return the exception that wraps the given exception. */ public static MojoExecutionException createException(final Log log, final Throwable exception, final String message) { if (log.isWarnEnabled()) { log.warn(message, exception); } return new MojoExecutionException(message, exception); }