List of usage examples for org.apache.maven.plugin.logging Log warn
void warn(Throwable error);
From source file:com.edugility.jpa.maven.plugin.ListEntityClassnamesMojo.java
License:Open Source License
/** * Returns the appropriate property name given a {@linkplain Class#getName() class name}. * * <p>If the supplied {@code className} is {@code null} or consists * solely of {@linkplain Character#isWhitespace(char) whitespace}, * then the {@linkplain #getDefaultPropertyName() default property * name} is returned.<p>// w w w .java 2s . co m * * <p>Otherwise, a property name is */ public String determinePropertyName(String className) { String propertyName = this.getDefaultPropertyName(); if (className != null) { className = className.trim(); if (!className.isEmpty()) { final Log log = this.getLog(); assert log != null; // Find the class' package name. Extract "com.foobar" from // "com.foobar.Foo". final int index = Math.max(0, className.lastIndexOf('.')); String packageName = className.substring(0, index); assert packageName != null; if (log.isDebugEnabled()) { log.debug("Package: " + packageName); } final Map<String, String> propertyNames = this.getPropertyNames(); if (propertyNames == null) { if (log.isWarnEnabled()) { log.warn(String.format( "Property names were never initialized; assigning default property name (%s) to class name %s.", propertyName, className)); } } else if (propertyNames.isEmpty()) { if (log.isWarnEnabled()) { log.warn(String.format( "Property names were initialized to the empty set; assigning default property name (%s) to class name %s.", propertyName, className)); } } else { propertyName = propertyNames.get(packageName); while (propertyName == null && packageName != null && !packageName.isEmpty()) { final int dotIndex = Math.max(0, packageName.lastIndexOf('.')); packageName = packageName.substring(0, dotIndex); if (log.isDebugEnabled()) { log.debug("Package: " + packageName); } propertyName = propertyNames.get(packageName); } } if (log.isDebugEnabled()) { log.debug("propertyName: " + propertyName); } } } if (propertyName == null) { propertyName = DEFAULT_DEFAULT_PROPERTY_NAME; } return propertyName; }
From source file:com.ericsson.tools.cpp.compiler.linking.executables.Executable.java
License:Apache License
private Collection<NativeCodeFile> translateRawFilesToCompiledFiles(final Log log, final Collection<File> rawFiles, final Collection<NativeCodeFile> compiledFiles) { final Collection<NativeCodeFile> matchingCompiledFiles = new ArrayList<NativeCodeFile>(); for (File rawFile : rawFiles) { boolean matchFound = false; for (NativeCodeFile compiledFile : compiledFiles) { if (compiledFile.getSourceFile().equals(rawFile)) { matchingCompiledFiles.add(compiledFile); matchFound = true;// w w w. j av a 2s .co m break; } } if (!matchFound) log.warn("Could not find " + rawFile + " among the list of compiled files."); } return matchingCompiledFiles; }
From source file:com.ericsson.tools.cpp.tools.LoggingCliExecutor.java
License:Apache License
public LoggingCliExecutor(final Log log) { super(log);//from w w w . j av a 2 s . co m setStdOutConsumer(new StreamConsumer() { @Override public void consumeLine(String line) { log.info(line); } }); setStdErrConsumer(new StreamConsumer() { @Override public void consumeLine(String line) { log.warn(line); } }); }
From source file:com.expedia.tesla.tools.mojo.GenerateSchemaMojo.java
License:Apache License
public void execute() throws MojoExecutionException { Log log = getLog(); try {//from w ww.j a va 2 s. c o m classpath += StringUtils.join(project.getCompileClasspathElements(), System.getProperty("path.separator")); } catch (DependencyResolutionRequiredException e) { throw new MojoExecutionException("Failed to resolve project dependencies: " + e.getMessage(), e); } if (outputTml == null) { log.warn("Output is not set, using default value 'output.tml'."); outputTml = new File("output.tml"); } log.info("Generating Tesla schema."); log.debug(String.format("classpath: %s", classpath)); log.debug(String.format("Classes: %s", Arrays.toString(this.classes.toArray()))); log.debug(String.format("Schema version name: %s", schemaVersion.getName())); log.debug(String.format("Schema version number: %s", schemaVersion.getVersionNumber())); log.debug(String.format("Output: %s", outputTml)); OutputStream os = null; try { Util.forceMkdirParent(outputTml); os = new FileOutputStream(outputTml); SchemaGenerator.genTml(classes, new SchemaVersion(0L, schemaVersion.getVersionNumber(), schemaVersion.getName(), null), os, classpath); } catch (Exception e) { throw new MojoExecutionException("Failed to generate Tesla schema from Java.", e); } finally { if (os != null) { try { os.close(); } catch (IOException e) { // ignore } } } log.info("Generated Tesla schema successfully."); }
From source file:com.github.bmaggi.conditional.validation.ValidationMojo.java
License:Apache License
public void execute() throws MojoExecutionException, MojoFailureException { Log log = getLog(); log.debug("There are " + conditions.size() + "conditions"); for (Condition condition : conditions) { log.debug("Evaluate (Condition type): " + condition.toString() + " (" + condition.getClass() + ")"); if (!(condition).evaluate()) { String message = condition.getMessage(); if (LEVEL.ERROR == condition.getLevel()) { log.error(" Condition failed" + message); throw new MojoExecutionException("A condition with a level ERROR failed"); } else { log.warn("Condition failed" + message); }/* w w w . j a va2s. c o m*/ } } }
From source file:com.github.formatter.JSBeautifier.java
License:Apache License
private Properties readFileHashCacheFile() { Properties props = new Properties(); Log log = getLog(); if (!targetDirectory.exists()) { targetDirectory.mkdirs();/*ww w . j a v a 2 s.co m*/ } else if (!targetDirectory.isDirectory()) { log.warn("Something strange here as the " + "supposedly target directory is not a directory."); return props; } File cacheFile = new File(targetDirectory, CACHE_PROPERTIES_FILENAME); if (!cacheFile.exists()) { return props; } try { props.load(new BufferedInputStream(new FileInputStream(cacheFile))); } catch (FileNotFoundException e) { log.warn("Cannot load file hash cache properties file", e); } catch (IOException e) { log.warn("Cannot load file hash cache properties file", e); } return props; }
From source file:com.github.jrh3k5.mojo.flume.AbstractFlumeAgentsMojo.java
License:Apache License
/** * Remove any libraries from the {@code lib/} directory in the given Flume installation directory. * /*from w w w . j a va 2 s.c om*/ * @param agent * The {@link Agent} whose installation's {@code lib/} directory is to be modified. * @param flumeDirectory * A {@link File} representing the directory in which a Flume agent - for which the configured libraries are to be removed - is installed. * @throws IOException * If any errors occur during the removal. */ void removeLibs(Agent agent, File flumeDirectory) throws IOException { final File libDir = new File(flumeDirectory, "lib"); final Log log = getLog(); final boolean isDebugEnabled = log.isDebugEnabled(); for (String removal : agent.getLibs().getRemovals()) { final File lib = new File(libDir, removal); if (lib.exists()) { if (isDebugEnabled) { log.debug(String.format("The file %s exists and will be removed.", lib.getAbsolutePath())); } FileUtils.forceDelete(lib); } else { log.warn(String.format("The file %s was specified for deletion, but could not be found in %s", removal, libDir.getAbsolutePath())); } } }
From source file:com.github.lucapino.confluence.UpdatePageConfluenceMojo.java
License:Apache License
@Override public void doExecute() throws Exception { Log log = getLog(); // Run only at the execution root if (runOnlyAtExecutionRoot && !isThisTheExecutionRoot()) { log.info("Skipping the announcement mail in this project because it's not the Execution Root"); } else {/* w ww . j a v a 2 s .c om*/ if (!inputFile.exists()) { log.warn("No template file found. Mojo skipping."); return; } // configure page Content updatedPage = getClient().getContentBySpaceKeyAndTitle(parent.getSpace(), pageTitle) .getContents()[0]; // always in storage format String oldContent = updatedPage.getBody().getStorage().getValue(); String content = processContent(inputFile); Storage newStorage; if (wikiFormat) { Storage contentStorage = new Storage(content, Storage.Representation.WIKI.toString()); newStorage = getClient().convertContent(contentStorage, Storage.Representation.STORAGE); } else { newStorage = new Storage(content, Storage.Representation.STORAGE.toString()); } // now append or prepend if (prepend) { content = newStorage.getValue() + oldContent; } else if (append) { content = oldContent + newStorage.getValue(); } newStorage.setValue(content); updatedPage.setBody(new Body(newStorage)); getClient().postContent(updatedPage); } }
From source file:com.github.lucapino.jira.CreateNewVersionMojo.java
License:Apache License
@Override public void doExecute() throws Exception { Log log = getLog(); Project jiraProject = jiraClient.getRestClient().getProjectClient().getProject(jiraProjectKey).claim(); Iterable<Version> versions = jiraProject.getVersions(); String newDevVersion;/*from w w w.j a v a2 s .co m*/ if (finalNameUsedForVersion) { newDevVersion = finalName; } else { newDevVersion = developmentVersion; } // Removing -SNAPSHOT suffix for safety and sensible formatting newDevVersion = WordUtils.capitalize(newDevVersion.replace("-SNAPSHOT", "").replace("-", " ")); boolean versionExists = isVersionAlreadyPresent(versions, newDevVersion); if (!versionExists) { VersionInput newVersion = new VersionInput(jiraProjectKey, newDevVersion, null, null, false, false); log.debug("New Development version in JIRA is: " + newDevVersion); jiraClient.getRestClient().getVersionRestClient().createVersion(newVersion).claim(); log.info("Version created in JIRA for project key " + jiraProjectKey + " : " + newDevVersion); } else { log.warn(String.format("Version %s is already created in JIRA. Nothing to do.", newDevVersion)); } }
From source file:com.github.lucapino.jira.GenerateReleaseNotesMojo.java
License:Apache License
/** * Writes issues to output// w w w .j av a 2 s.c om * * @param issues */ void output(List<JiraIssue> issues) throws IOException, MojoFailureException { Log log = getLog(); if (targetFile == null) { log.warn("No targetFile specified. Ignoring"); return; } if (issues == null) { log.warn("No issues found. File will not be generated."); return; } HashMap<Object, Object> parameters = new HashMap<>(); HashMap<String, List<JiraIssue>> jiraIssues = processIssues(issues); List<JiraIssue> jiraIssuesList = new ArrayList<>(); for (List<JiraIssue> list : jiraIssues.values()) { jiraIssuesList.addAll(list); } parameters.put("issues", jiraIssuesList); parameters.put("issuesMap", jiraIssues); parameters.put("jiraURL", jiraURL); parameters.put("jiraProjectKey", jiraProjectKey); parameters.put("releaseVersion", releaseVersion); if (announceParameters == null) { // empty Map to prevent NPE in velocity execution parameters.put("announceParameters", java.util.Collections.EMPTY_MAP); } else { parameters.put("announceParameters", announceParameters); } boolean useDefault = false; if (templateFile == null || !templateFile.exists()) { useDefault = true; // let's use the default one // it/peng/maven/jira/releaseNotes.vm InputStream defaultTemplate = this.getClass().getClassLoader().getResourceAsStream("releaseNotes.vm"); templateFile = File.createTempFile("releaseNotes.vm", null); FileOutputStream fos = new FileOutputStream(templateFile); IOUtils.copy(defaultTemplate, fos); IOUtils.closeQuietly(defaultTemplate); IOUtils.closeQuietly(fos); } String content = getEvaluator().evaluate(templateFile, parameters); if (useDefault) { // remove the temp file templateFile.delete(); } // this creates the parent folder and the file if they doesn't exist OutputStreamWriter writer = new OutputStreamWriter(FileUtils.openOutputStream(targetFile), "UTF-8"); PrintWriter ps = new PrintWriter(writer); try { if (beforeText != null) { ps.println(beforeText); } ps.println(content); if (afterText != null) { ps.println(afterText); } } finally { ps.flush(); IOUtils.closeQuietly(ps); } }