List of usage examples for org.apache.maven.plugin.logging Log info
void info(Throwable error);
From source file:com.rabbitstewdio.build.maven.tomcat.ClasspathServlet.java
License:Apache License
public ClasspathServlet(ClassLoader projectClassLoader, Log log) { super(log);// w ww . j ava2 s .co m this.projectClassLoader = projectClassLoader; if (log.isDebugEnabled()) { log.debug("Begin Logging Classloader for " + projectClassLoader); ClassLoader cl = projectClassLoader; while (cl.getParent() != null && cl.getParent() != cl) { if (cl instanceof URLClassLoader) { URLClassLoader ucl = (URLClassLoader) cl; for (URL url : ucl.getURLs()) { log.info(" => " + url); } } log.debug("-> " + cl); cl = cl.getParent(); } log.debug("Finished Logging Classloader for " + projectClassLoader); } }
From source file:com.redhat.rcm.maven.plugin.buildmetadata.AbstractReportMojo.java
License:Apache License
/** * Runs the report generation.// w w w . jav a 2 s. c o m * * @throws MojoExecutionException on any problem encountered. */ @Override public void execute() throws MojoExecutionException // CHECKSTYLE:ON { final Log log = getLog(); if (!canGenerateReport()) { if (log.isInfoEnabled()) { log.info("Report '" + getName(Locale.getDefault()) + "' skipped due to offline mode."); } return; } getLog(); provideSink(); }
From source file:com.redhat.rcm.maven.plugin.buildmetadata.AbstractReportMojo.java
License:Apache License
/** * {@inheritDoc}//from w w w . java2 s .c o m * <p> * Configures the plugin logger. * </p> * * @see org.apache.maven.reporting.AbstractMavenReport#executeReport(java.util.Locale) */ @Override protected void executeReport(final Locale locale) throws MavenReportException // CHECKSTYLE:ON { final Log log = getLog(); if (!canGenerateReport()) { if (log.isInfoEnabled()) { log.info("Report '" + getName(Locale.getDefault()) + "' skipped due to offline mode."); } return; } }
From source file:com.redhat.victims.Settings.java
License:Open Source License
/** * Use the supplied log to display the current settings. * @param log Log to send output to./*from ww w. j a v a2 s. c o m*/ */ public void show(Log log) { StringBuilder info = new StringBuilder(); info.append(TextUI.box(TextUI.fmt(Resources.INFO_SETTINGS_HEADING))); for (Entry<String, String> kv : settings.entrySet()) { info.append(String.format("%-12s = %s\n", kv.getKey(), kv.getValue())); } log.info(info.toString()); }
From source file:com.redhat.victims.VictimsRule.java
License:Open Source License
/** * Updates the database according to the given configuration * @param ctx/*w w w. j av a 2s .c o m*/ * @throws VictimsException */ public void updateDatabase(ExecutionContext ctx) throws VictimsException { Log log = ctx.getLog(); // Disable updates via command line -Dvictims.skip.update=true String override = System.getProperty(Settings.UPDATES_OVERRIDE); if (override != null && override.equalsIgnoreCase("true")) { log.warn("[victims-enforcer] Updates disabled via system property."); return; } VictimsDBInterface db = ctx.getDatabase(); Date updated = db.lastUpdated(); // update automatically every time if (ctx.updateAlways()) { log.info(TextUI.fmt(Resources.INFO_UPDATES, updated.toString(), VictimsConfig.uri())); db.synchronize(); // update once per day } else if (ctx.updateDaily()) { Date today = new Date(); SimpleDateFormat cmp = new SimpleDateFormat("yyyyMMdd"); boolean updatedToday = cmp.format(today).equals(cmp.format(updated)); if (!updatedToday) { log.info(TextUI.fmt(Resources.INFO_UPDATES, updated.toString(), VictimsConfig.uri())); db.synchronize(); } else { log.debug("[victims-enforcer] database last synchronized: " + updated.toString()); } } else if (ctx.updateWeekly()) { Date today = new Date(); SimpleDateFormat cmp = new SimpleDateFormat("yyyyw"); if (cmp.format(today).equals(cmp.format(updated))) { log.info(TextUI.fmt(Resources.INFO_UPDATES, updated.toString(), VictimsConfig.uri())); db.synchronize(); } else { log.debug("[victims-enforcer] database last synchronized: " + updated.toString()); } // updates disabled } else { log.debug("[victims-enforcer] database synchronization disabled."); } }
From source file:com.redhat.victims.VictimsRule.java
License:Open Source License
/** * This is a helper method that processes a single result that * has been executed. /* ww w . j a v a2 s.c om*/ * * If any exceptions were thrown during execution they are inspected * to see if they indicate a vulnerable artifact. The result is also * added to the cache for the current execution context. * * * @param ctx - The execution context the result was generated under * @param result - The result to examine * @throws VictimsException * @throws VulnerableArtifactException * @throws EnforcerRuleException */ private void processResult(ExecutionContext ctx, Future<ArtifactStub> result) throws VictimsException, VulnerableArtifactException, EnforcerRuleException { VictimsResultCache cache = ctx.getCache(); Log log = ctx.getLog(); try { ArtifactStub checked = result.get(); if (checked != null) { log.debug("[victims-enforcer] done: " + checked.getId()); cache.add(checked.getId(), null); } } catch (InterruptedException e) { log.info(e.getMessage()); } catch (ExecutionException e) { log.debug(e); Throwable cause = e.getCause(); if (cause instanceof VulnerableArtifactException) { VulnerableArtifactException ve = (VulnerableArtifactException) cause; // cache vulnerable artifact cache.add(ve.getId(), ve.getVulnerabilites()); // Log the error and rethrow in case a fatal error log.warn(ve.getLogMessage()); throw ve; } else { throw new EnforcerRuleException(e.getCause().getMessage()); } } }
From source file:com.retroduction.carma.mavenplugin.MutationTestMojo.java
License:Open Source License
public void execute() throws MojoExecutionException, MojoFailureException { Log log = this.getLog(); log.info("Creating MutationTest report: " + this.reportFile); try {/*from w ww . j a va 2 s. c om*/ CarmaTestExecuter executer = new CarmaTestExecuter(); executer.setClassesDir(this.classesDir); executer.setTestClassesDir(this.testClassesDir); executer.setDependencyClassPathUrls(this.getDependencyClassPathUrls()); executer.setReportFile(this.reportFile); executer.setConfigFile(this.carmaConfigFile); Summary sum = executer.executeTests(); NumberFormat format = NumberFormat.getInstance(); format.setMaximumFractionDigits(2); format.setMinimumFractionDigits(2); log.info("# --------------------------------------------------------------------------------"); log.info("# CARMA TEST RESULTS SUMMARY "); log.info("# Total time : " + format.format(sum.timeSeconds) + " sec."); log.info("# Classes/Tests : " + sum.numClassesUnderTest + "/" + sum.numTests); log.info("# Tests Per Class : " + format.format(sum.testsPerClass)); log.info("# Mutants/Class : " + format.format(sum.mutantsPerClass)); log.info("# Mutants/Survivors : " + sum.numMutants + "/" + sum.numSurvivors); log.info("# MutationCoverageRatio : " + format.format(sum.coverageRatioPercentage) + " %"); log.info("# --------------------------------------------------------------------------------"); } catch (MalformedURLException e) { throw new MojoExecutionException("Could not handle dependency URLs", e); } }
From source file:com.retroduction.carma.mavenplugin.ReportMojo.java
License:Open Source License
public void execute() throws MojoExecutionException, MojoFailureException { Log log = this.getLog(); ReportModelLoader loader = new ReportModelLoader(); MutationRun mutationRun;//from w w w. j a va 2 s .c o m try { mutationRun = loader.loadReportModel(this.reportFile); ReportGenerator reportGenerator = new ReportGenerator(); List<File> sourceDirectories = new ArrayList<File>(); sourceDirectories.add(this.sourceDir); reportGenerator.perform(mutationRun, this.outputDirectory, sourceDirectories); log.info("# --------------------------------------------------------------------------------"); log.info("# Mutation Site report generated. Output directory: " + this.outputDirectory); log.info("# --------------------------------------------------------------------------------"); } catch (Exception e) { log.error(e); throw new MojoFailureException("Error during report generation"); } }
From source file:com.ricston.SearchReplaceMojo.java
License:Apache License
public void execute() throws MojoExecutionException { final Log log = getLog(); log.info("======================="); log.info(String.format("${sr.replaceString}: %s", replaceString)); log.info(String.format("${sr.searchRegex}: %s", searchRegex)); log.info(String.format("${sr.targetPackage}: %s", targetPackage)); log.info(String.format("${sr.sourceDirectory}: %s", sourceDirectory)); log.info(String.format("${sr.targetDirectoryPath}: %s", targetDirectoryPath)); log.info("======================="); final String targetPackageWithOsSeparator = targetPackage.replaceAll("\\.", File.separator); final File directoryToProcess = new File(sourceDirectory.getAbsolutePath(), targetPackageWithOsSeparator); log.info(String.format("directory to process: %s", directoryToProcess)); List<File> files = getFilesInFolder(directoryToProcess, new ArrayList<File>(100)); log.info(String.format("files to process: %s", files)); for (final File file : files) { try {//from ww w .j a va 2 s. c o m String content = new String(Files.readAllBytes(file.toPath()), StandardCharsets.UTF_8); content = content.replaceAll(searchRegex, replaceString); if (SAME_TARGET_PATH_AS_SOURCE.equals(targetDirectoryPath)) { Path targetPath = file.toPath(); log.info(String.format("By default, writing [%s] to [%s]", file.getName(), targetPath)); Files.write(targetPath, content.getBytes(StandardCharsets.UTF_8)); } else { Path targetPath = new File(targetDirectoryPath, file.getName()).toPath(); log.info(String.format("Writing [%s] to [%s]", file.getName(), targetPath)); Files.write(targetPath, content.getBytes(StandardCharsets.UTF_8)); } } catch (IOException e) { log.info(String.format("could not process %s", file.getName())); e.printStackTrace(); } } }
From source file:com.ritchey.sample.plugin.BrowseXMLMojo.java
License:Apache License
public static void loadAgent(Log log, File javaagent, String parameters) { RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean(); String nameOfRunningVM = runtime.getName(); log.info("dynamically loading javaagent name: " + runtime.getName() + " vm version = " + runtime.getVmVersion());// www. ja v a 2 s .c om int p = nameOfRunningVM.indexOf('@'); String pid = nameOfRunningVM.substring(0, p); try { VirtualMachine vm = VirtualMachine.attach(pid); vm.loadAgent(javaagent.getAbsolutePath(), parameters); vm.detach(); } catch (Exception e) { throw new RuntimeException(e); } }