List of usage examples for org.apache.maven.plugin.logging Log error
void error(Throwable error);
From source file:ch.sourcepond.maven.release.commons.PluginException.java
License:Apache License
private void printCause(final Log log) { if (getCause() != null) { log.error(format("Caused by %s", getCause().getClass())); log.error(getCause().getMessage()); }//w ww .jav a 2s . c om if (getCause() instanceof PluginException) { final PluginException plex = (PluginException) getCause(); for (final String line : plex.messages) { log.error(line); } log.error(""); plex.printCause(log); } }
From source file:ch.sourcepond.maven.release.commons.PluginException.java
License:Apache License
public void printBigErrorMessageAndThrow(final Log log) throws MojoExecutionException { log.error(""); log.error(""); log.error(""); log.error("************************************"); log.error("Could not execute the release plugin"); log.error("************************************"); log.error(""); log.error(""); log.error(getMessage());/*www. j a va 2 s . c o m*/ for (final String line : messages) { log.error(line); } log.error(""); log.error(""); printCause(log); throw new MojoExecutionException(getMessage()); }
From source file:cn.org.once.cstack.maven.plugin.utils.RestUtils.java
License:Open Source License
/** * @param url//from ww w . j av a 2 s .c om * @param parameters * @param log * @return * @throws MojoExecutionException */ public Map<String, String> connect(String url, Map<String, Object> parameters, Log log) throws MojoExecutionException { Map<String, String> response = new HashMap<String, String>(); CloseableHttpClient httpclient = HttpClients.createDefault(); List<NameValuePair> nvps = new ArrayList<>(); nvps.add(new BasicNameValuePair("j_username", (String) parameters.get("login"))); nvps.add(new BasicNameValuePair("j_password", (String) parameters.get("password"))); localContext = HttpClientContext.create(); localContext.setCookieStore(new BasicCookieStore()); HttpPost httpPost = new HttpPost(url); try { httpPost.setEntity(new UrlEncodedFormEntity(nvps)); CloseableHttpResponse httpResponse = httpclient.execute(httpPost, localContext); ResponseHandler<String> handler = new ResponseErrorHandler(); String body = handler.handleResponse(httpResponse); response.put("body", body); httpResponse.close(); isConnected = true; log.info("Connection successful"); } catch (Exception e) { log.error("Connection failed! : " + e.getMessage()); isConnected = false; throw new MojoExecutionException( "Connection failed, please check your manager location or your credentials"); } return response; }
From source file:com.alibaba.citrus.maven.eclipse.base.eclipse.reader.ReadWorkspaceLocations.java
License:Apache License
HashMap readDefinedServers(WorkspaceConfiguration workspaceConfiguration, Log logger) { HashMap detectedRuntimes = new HashMap(); if (workspaceConfiguration.getWorkspaceDirectory() != null) { Xpp3Dom runtimesElement = null;/* w w w . j a va2 s .co m*/ try { File prefs = new File(workspaceConfiguration.getWorkspaceDirectory(), ReadWorkspaceLocations.METADATA_PLUGINS_ORG_ECLIPSE_CORE_RUNTIME_SERVER_PREFS); if (prefs.exists()) { Properties properties = new Properties(); properties.load(new FileInputStream(prefs)); String runtimes = properties.getProperty( ReadWorkspaceLocations.METADATA_PLUGINS_ORG_ECLIPSE_CORE_RUNTIME_PREFS_RUNTIMES_KEY); if (runtimes != null) { runtimesElement = Xpp3DomBuilder.build(new StringReader(runtimes)); } } } catch (Exception e) { logger.error("Could not read workspace wtp server runtimes preferences : " + e.getMessage()); } if (runtimesElement != null) { Xpp3Dom[] runtimeArray = runtimesElement.getChildren("runtime"); for (int index = 0; runtimeArray != null && index < runtimeArray.length; index++) { String id = runtimeArray[index].getAttribute("id"); String name = runtimeArray[index].getAttribute("name"); if (detectedRuntimes.isEmpty()) { logger.debug("Using WTP runtime with id: \"" + id + "\" as default runtime"); detectedRuntimes.put("", id); } detectedRuntimes.put(id, name); logger.debug("Detected WTP runtime with id: \"" + id + "\" and name: \"" + name + "\""); } } } return detectedRuntimes; }
From source file:com.alibaba.citrus.maven.eclipse.base.eclipse.writers.EclipseManifestWriter.java
License:Apache License
/** * make room for a Manifest file. use a generated resource for JARS and for WARS use the manifest in the * webapp/META-INF directory./* ww w . jav a 2 s . co m*/ * * @throws MojoExecutionException */ public static void addManifestResource(Log log, EclipseWriterConfig config) throws MojoExecutionException { AbstractEclipseManifestWriter manifestWriter = new EclipseManifestWriter(); manifestWriter.init(log, config); String packaging = config.getProject().getPackaging(); String manifestDirectory = manifestWriter.getMetaInfBaseDirectory(config.getProject()); if (!Constants.PROJECT_PACKAGING_EAR.equals(packaging) && !Constants.PROJECT_PACKAGING_WAR.equals(packaging) && manifestDirectory == null) { String generatedResourceDir = config.getProject().getBasedir().getAbsolutePath() + File.separatorChar + EclipseManifestWriter.GENERATED_RESOURCE_DIRNAME; manifestDirectory = generatedResourceDir + File.separatorChar + "META-INF"; try { new File(manifestDirectory).mkdirs(); File manifestFile = new File(manifestDirectory + File.separatorChar + "MANIFEST.MF"); if (manifestFile.exists()) { manifestFile.delete(); } manifestFile.createNewFile(); } catch (IOException e) { log.error(Messages.getString("EclipsePlugin.cantwritetofile", new Object[] { manifestDirectory + File.separatorChar + "META-INF" + File.separatorChar + "MANIFEST.MF" })); } log.debug("Adding " + EclipseManifestWriter.GENERATED_RESOURCE_DIRNAME + " to eclipse sources "); EclipseSourceDir[] sourceDirs = config.getSourceDirs(); EclipseSourceDir[] newSourceDirs = new EclipseSourceDir[sourceDirs.length + 1]; System.arraycopy(sourceDirs, 0, newSourceDirs, 0, sourceDirs.length); newSourceDirs[sourceDirs.length] = new EclipseSourceDir( EclipseManifestWriter.GENERATED_RESOURCE_DIRNAME, null, true, false, null, null, false); config.setSourceDirs(newSourceDirs); } if (Constants.PROJECT_PACKAGING_WAR.equals(packaging)) { new File(getWebContentBaseDirectory(config) + File.separatorChar + "META-INF").mkdirs(); } // special case must be done first because it can add stuff to the // classpath that will be // written by the superclass manifestWriter.write(); }
From source file:com.anuta.internal.YangHelperMojo.java
License:Open Source License
public void executeGoal(OperationType operationType) throws MojoExecutionException, MojoFailureException { Log log = getLog(); if (null != excludes && excludes.length > 0) { for (String excl : excludes) { log.info("Excluding file " + excl); }//from w ww. j a v a 2 s.co m } if (!isPyangInstalled()) { log.error("Pyang is not installed. Skip conversion."); return; } long startClock = System.currentTimeMillis(); createResourceCollection(); List files = new ArrayList(); try { if (directories != null) { for (File directory : directories) { if (directory.exists() && directory.isDirectory()) { collection.setBaseDir(directory); addCollectionFiles(files); } } } else if (this.sourceDirectory != null && this.sourceDirectory.exists() && this.sourceDirectory.isDirectory()) { log.info("Using Source Directory." + this.sourceDirectory); collection.setBaseDir(this.sourceDirectory); addCollectionFiles(files); } else { log.error("No source directory specified to scan yang files."); } } catch (IOException e) { throw new MojoExecutionException("Unable to find files using includes/excludes", e); } int numberOfFiles = files.size(); log.info("Number of files for " + operationType + " " + numberOfFiles); if (numberOfFiles > 0) { String basedirPath = getBasedirPath(); Properties hashCache = readFileHashCacheFile(); ResultCollector resultCollector = new ResultCollector(); for (int i = 0, n = files.size(); i < n; i++) { File file = (File) files.get(i); performOperation(file, resultCollector, hashCache, basedirPath); } log.info("\nOperation : " + operationType); log.info("Number of yang files : " + numberOfFiles); log.info("Successful : " + resultCollector.successCount + " file(s)"); log.info("Failed : " + resultCollector.failCount + " file(s)"); log.info("Skipped : " + resultCollector.skippedCount + " file(s)\n"); storeFileHashCache(hashCache); long endClock = System.currentTimeMillis(); log.info("Approximate time taken: " + ((endClock - startClock) / 1000) + "s"); } }
From source file:com.ariht.maven.plugins.config.io.DirectoryDeleter.java
License:Apache License
/** * Clear contents of config generation build target/output io ready for new directory. *///www. j a va 2s. c o m public void clearTargetDirectory(final String outputBasePath, final Log logger) throws MojoFailureException { final File outputDir = new File(outputBasePath); if (outputDir.exists()) { logger.debug("Deleting : " + outputDir); try { FileUtils.forceDelete(outputDir); } catch (IOException e) { logger.error("Error while clearing config generation output io: [" + outputDir + "], error was: " + String.valueOf(e.getMessage())); throw new MojoFailureException(e.getMessage(), e); } } }
From source file:com.chuidiang.pom_version.Listado.java
License:Apache License
/** * Analiza el pom.xml y realiza el listado. */// w w w . j a va 2 s . c o m public void execute() throws MojoExecutionException { Log log = getLog(); while (null != proyecto.getParent()) proyecto = proyecto.getParent(); outputDirectory = new File(proyecto.getBuild().getDirectory()); if (!outputDirectory.exists()) outputDirectory.mkdirs(); // Si a CambiaPom se le pasa un Hashtable de cambios null, // no hace ningun cambio, pero genera igualmente el listado // de artifacts en el pom.xml CambiaPom cp = new CambiaPom(null, basedir, todo, log, proyecto.getProperties()); LinkedList<Artifact> listado = cp.getListado(); File ficheroCambiaConf = new File(outputDirectory, "cambia.conf"); LinkedList<String> listaArtefactos = new LinkedList<String>(); if (ficheroCambiaConf.canRead()) { BufferedReader br; try { br = new BufferedReader(new FileReader(ficheroCambiaConf)); String linea = br.readLine(); while (null != linea) { String artefacto = linea.substring(0, linea.indexOf(" ")); listaArtefactos.add(artefacto); linea = br.readLine(); } } catch (Exception e) { log.error(e); } } try { PrintWriter pw = new PrintWriter(new FileWriter(new File(outputDirectory, "cambia.conf"), true)); for (Artifact a : listado) { String artefacto = a.toString(); if (-1 == listaArtefactos.indexOf(artefacto)) { String[] partesArtefacto = artefacto.split(":"); if (null != groupId) partesArtefacto[0] = groupId; if (null != version) partesArtefacto[2] = version; pw.println(artefacto + " " + partesArtefacto[0] + ":" + partesArtefacto[1] + ":" + partesArtefacto[2]); listaArtefactos.add(artefacto); } } pw.close(); } catch (IOException e) { log.error(e); } }
From source file:com.codecrate.webstart.AntToMavenLogger.java
License:Apache License
private void log(BuildEvent event) { int priority = event.getPriority(); Log log = mojo.getLog(); switch (priority) { case Project.MSG_ERR: log.error(event.getMessage()); break;/*w w w. j a va2 s . c om*/ case Project.MSG_WARN: log.warn(event.getMessage()); break; case Project.MSG_INFO: log.info(event.getMessage()); break; case Project.MSG_VERBOSE: log.debug(event.getMessage()); break; case Project.MSG_DEBUG: log.debug(event.getMessage()); break; default: log.info(event.getMessage()); break; } }
From source file:com.collaborne.jsonschema.validator.plugin.ValidateMojo.java
License:Apache License
@VisibleForTesting protected void log(String filename, ProcessingMessage message) { // FIXME: #getMessage() is ok, but ideally we also need the other key/value pairs. // Doing that would require knowing that "message" is the one holding the message // itself. StringBuilder logMessageBuilder = new StringBuilder(); logMessageBuilder.append(filename);//from w w w. j a va 2s. c om logMessageBuilder.append(": "); logMessageBuilder.append(message.getMessage()); String logMessage = logMessageBuilder.toString(); Log log = getLog(); switch (message.getLogLevel()) { case NONE: // XXX: Do nothing? break; case DEBUG: log.debug(logMessage); break; case INFO: log.info(logMessage); break; case WARNING: log.warn(logMessage); break; case ERROR: case FATAL: log.error(logMessage); break; } }