List of usage examples for org.apache.maven.plugin.logging Log warn
void warn(CharSequence content, Throwable error);
From source file:org.mule.devkit.maven.AbstractGitHubMojo.java
License:Open Source License
/** * Log given message and throwable at warn level * * @param message//from w w w . j av a 2s .co m * @param throwable */ protected void warn(String message, Throwable throwable) { Log log = getLog(); if (log != null) { log.warn(message, throwable); } }
From source file:org.sonatype.nexus.maven.m2settings.MojoLogger.java
License:Open Source License
@Override protected void doLog(final Event event) { Log mojoLog = getOwner().getLog(); if (mojoLog == null) { log.warn("Mojo.log not configured; owner: {}, event: {}", owner, event); return;/*from w w w . jav a2s. c om*/ } switch (event.getLevel()) { case TRACE: case DEBUG: mojoLog.debug(event.getMessage(), event.getCause()); break; case INFO: mojoLog.info(event.getMessage(), event.getCause()); break; case WARN: mojoLog.warn(event.getMessage(), event.getCause()); break; case ERROR: mojoLog.error(event.getMessage(), event.getCause()); break; default: throw new UnsupportedOperationException(); } }
From source file:org.universAAL.support.directives.checks.SVNCheck.java
License:Apache License
public boolean check(MavenProject mavenProject, Log log) throws MojoExecutionException, MojoFailureException { this.mavenProject = mavenProject; log.debug("checking svn for " + mavenProject.getBasedir().getPath()); try {/*from ww w . j a v a 2s .c o m*/ surl = getSVNURL(mavenProject.getBasedir()); log.debug("found URL : " + surl); log.debug("comparing with : " + mavenProject.getScm().getConnection()); log.debug("comparing with : " + mavenProject.getScm().getDeveloperConnection()); if (missMatchURLs(surl) || missMatchURLs(surl.replace(OLD_URL, NEW_URL))) { throw new MojoFailureException(SCM_NOT_CONFIGURED); } else { log.debug("SCM and SVN info are in sync."); return true; } } catch (SVNException e) { log.warn("SVN Error.", e); log.warn("directory seems not to be a local SVN working copy."); throw new MojoExecutionException("Directory seems not to be a local SVN working copy.", e); } catch (MojoFailureException e) { throw e; } catch (MojoExecutionException e) { throw e; } catch (Exception e1) { throw new MojoExecutionException("Unexpected Exception", e1); } }
From source file:org.wso2.maven.p2.utils.FileManagementUtil.java
License:Open Source License
/** * Updated the given config.ini file with a given key value pair. * * @param configIniFile File object representing the config.ini * @param propKey property key// w ww. j a v a 2s.c om * @param value property value * @param log Logger to log any warnings */ public static void changeConfigIniProperty(File configIniFile, String propKey, String value, Log log) { Properties prop = new Properties(); try (InputStream inputStream = new FileInputStream(configIniFile)) { prop.load(inputStream); prop.setProperty(propKey, value); try (OutputStream outputStream = new FileOutputStream(configIniFile)) { prop.store(outputStream, null); } } catch (IOException e) { log.warn("Error occurred while updating " + configIniFile.getName(), e); } }
From source file:org.wso2.maven.p2.utils.FileManagementUtil.java
License:Open Source License
/** * Zip a give folder to a give output zip file. * * @param srcFolder source folder/*from ww w . j a v a 2s . com*/ * @param destZipFile path to the output zip file * @param log Logger to log any warnings */ public static void zipFolder(String srcFolder, String destZipFile, Log log) { try (FileOutputStream fileWriter = new FileOutputStream(destZipFile); ZipOutputStream zip = new ZipOutputStream(fileWriter)) { addFolderContentsToZip(srcFolder, zip, log); } catch (IOException e) { log.warn("Error occurred while archiving " + srcFolder, e); } }
From source file:org.wso2.maven.p2.utils.FileManagementUtil.java
License:Open Source License
/** * Add a given folder/file into the given {@link ZipOutputStream}. * * @param path {@code String} Location inside the ZipOutputStream * @param srcFile {@code String} folder/file to be added into ZipOutputStream * @param zip {@link ZipOutputStream} zip output stream * @param log {@link Log}//from w w w . j a va 2 s . c o m */ private static void addToZip(String path, String srcFile, ZipOutputStream zip, Log log) { File folder = new File(srcFile); if (folder.isDirectory()) { addFolderToZip(path, srcFile, zip, log); } else { // Transfer bytes from in to out byte[] buf = new byte[1024]; int len; try (FileInputStream inputStream = new FileInputStream(srcFile)) { if (path.trim().equals("")) { zip.putNextEntry(new ZipEntry(folder.getName())); } else { zip.putNextEntry(new ZipEntry(path + "/" + folder.getName())); } while ((len = inputStream.read(buf)) > 0) { zip.write(buf, 0, len); } } catch (IOException e) { log.warn("Error occurred while archiving " + srcFile, e); } } }
From source file:org.wso2.maven.p2.utils.FileManagementUtil.java
License:Open Source License
/** * Add root level content of a folder to the given {@link ZipOutputStream}. * * @param srcFolder {@code String} location of the folder to be included into the ZipOutputStream * @param zip {@link ZipOutputStream} * @param log {@link Log}//from w w w. j a v a 2s .c o m */ private static void addFolderContentsToZip(String srcFolder, ZipOutputStream zip, Log log) { File folder = new File(srcFolder); String fileList[] = folder.list(); if (fileList != null) { try { int i = 0; while (true) { if (fileList.length == i) { break; } if (new File(folder, fileList[i]).isDirectory()) { zip.putNextEntry(new ZipEntry(fileList[i] + "/")); zip.closeEntry(); } addToZip("", srcFolder + "/" + fileList[i], zip, log); i++; } } catch (IOException e) { log.warn("Error occurred while archiving " + srcFolder, e); } } }
From source file:org.wso2.maven.p2.utils.FileManagementUtil.java
License:Open Source License
/** * Add non root level folders into a given {@link ZipOutputStream}. * @param path {@code String}//from w w w.jav a2 s . c o m * @param srcFolder {@code String} * @param zip {@link ZipOutputStream} * @param log {@link Log} */ private static void addFolderToZip(String path, String srcFolder, ZipOutputStream zip, Log log) { File folder = new File(srcFolder); String fileList[] = folder.list(); if (fileList != null) { try { int i = 0; while (true) { if (fileList.length == i) { break; } String newPath = folder.getName(); if (!path.equalsIgnoreCase("")) { newPath = path + "/" + newPath; } if (new File(folder, fileList[i]).isDirectory()) { zip.putNextEntry(new ZipEntry(newPath + "/" + fileList[i] + "/")); zip.closeEntry(); } addToZip(newPath, srcFolder + "/" + fileList[i], zip, log); i++; } } catch (IOException e) { log.warn("Error occurred while archiving " + srcFolder, e); } } }
From source file:vitkin.sfdc.mojo.wsdl.WsdlDownloadlMojo.java
License:Apache License
/** * Download the WSDL./*from ww w .jav a2s. c o m*/ * * @param client HTTP client. * @param resourceServer URL of the resource server from where to download. * * @throws MojoExecutionException */ private void downloadWsdl(final HttpClient client, final String resourceServer) throws MojoExecutionException { final Log logger = getLog(); final String baseUrl = resourceServer + '/' + wsdlUri; logger.info("Getting WSDL from " + baseUrl); final HttpGet wsdlRequest = new HttpGet(baseUrl); try { final HttpResponse response = client.execute(wsdlRequest); final int code = response.getStatusLine().getStatusCode(); if (code != HttpStatus.SC_OK) { throw new MojoExecutionException("Failed getting the WSDL! Got HTTP Code " + code); } PrintWriter pw = null; BufferedReader br = null; try { if (filename == null) { logger.info("No filename defined. Using default one from server..."); final Header header = response.getFirstHeader("Content-Disposition"); if (header == null) { if (logger.isDebugEnabled()) { debugResponse(response); } throw new MojoExecutionException("Couldn't get filename from server!"); } final HeaderElement[] elements = header.getElements(); filename = elements[0].getParameterByName("filename").getValue(); } if (!outputDirectory.exists()) { outputDirectory.mkdirs(); } final File wsdlFile = new File(outputDirectory, filename); logger.info("Saving WSDL to '" + wsdlFile + "'..."); br = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); pw = new PrintWriter(wsdlFile); for (String line = br.readLine(); line != null; line = br.readLine()) { pw.println(line); } } catch (IOException ex) { throw new MojoExecutionException("Failed saving the WSDL!", ex); } catch (IllegalStateException ex) { throw new MojoExecutionException("Failed saving the WSDL!", ex); } catch (ParseException ex) { throw new MojoExecutionException("Failed saving the WSDL!", ex); } finally { try { if (br != null) { br.close(); } if (pw != null) { pw.close(); } } catch (IOException ex) { logger.warn(ex.getMessage(), ex); } } } catch (IOException ex) { throw new MojoExecutionException("Cannot get WSDL!", ex); } }
From source file:vitkin.sfdc.mojo.wsdl.WsdlDownloadlMojo.java
License:Apache License
/** * Load cookies from the previous instance execution. * * @param env Salesforce environment. Either 'sandbox' or 'dev-prod'. * * @return The loaded cookie store or null if it can't load it. */// w w w .j a v a 2 s .c om private CookieStore loadCookies(final String env) { final Log logger = getLog(); final File cookieStorePath = new File(cookiesDirectory, env); CookieStore cookieStore = null; if (cookieStorePath.exists()) { final File cookieStoreFile = new File(cookieStorePath, username + COOKIES_SUFFIX); if (cookieStoreFile.exists()) { logger.info("Found cookies from previous execution. Loading from '" + cookieStoreFile + "'..."); ObjectInputStream ois = null; try { ois = xstream .createObjectInputStream(new BufferedInputStream(new FileInputStream(cookieStoreFile))); cookieStore = (BasicCookieStore) ois.readObject(); } catch (IOException ex) { logger.warn("Failed reading cookies from previous run!", ex); } catch (ClassNotFoundException ex) { logger.warn("Failed loading cookies from previous run!", ex); } finally { if (ois != null) { try { ois.close(); } catch (IOException ex) { logger.warn(ex.getMessage(), ex); } } } } } return cookieStore; }