List of usage examples for org.apache.maven.plugin.logging Log debug
void debug(Throwable error);
From source file:com.summit.i18nhelper.BundleGenerator.java
License:Apache License
public void generateResources(File baseDir, File inputFile, List<String> languageCodes, Log log) throws IOException { final Properties fullFile = new Properties(); final Charset charset = Charset.forName("UTF-8"); fullFile.load(new InputStreamReader(new FileInputStream(inputFile), charset)); BufferedReader in = null;/*from www .j ava 2s . com*/ try { in = new BufferedReader(new InputStreamReader(new FileInputStream(inputFile), charset)); String currentFile = ""; String line; while ((line = in.readLine()) != null) { //FIX ME this needs to be a better wildcard. if (line.startsWith("#")) { currentFile = line.substring(line.indexOf("#") + 1).replaceAll("\\\\", "/"); log.debug("Current base file: " + currentFile); } else { int splitIndex = line.indexOf("="); //if it doesnt have "=" or its empty after "=", skip if (splitIndex < 0 || splitIndex == line.length() - 1) { continue; } else { String[] splitLine = line.split("="); int pointIndex = splitLine[0].lastIndexOf("."); if (pointIndex > 0) { String possibleCode = splitLine[0].substring(pointIndex + 1); String key = splitLine[0].substring(0, pointIndex); if (languageCodes.contains(possibleCode)) { final String property = GoogleTranslateMojo .nativeToAscii(fullFile.getProperty(splitLine[0])); appendToFile(possibleCode, baseDir, currentFile, key, property); } } } } } } finally { try { in.close(); } catch (IOException ex) { } } }
From source file:com.topekalabs.maven.javaflow.JavaflowEnhanceMojo.java
License:Open Source License
private void instrumentClassFiles(File baseDirectory, File backupDirectory, List<File> classFiles) throws MojoExecutionException { Log log = getLog(); ResourceTransformer transformer = new AsmClassTransformer(); for (File classFile : classFiles) { try {/*from ww w.ja v a2 s . com*/ File instrumentedClassFile = new File(String.format(CLASSFILE_REWRITE_TEMPLATE, classFile)); File backupClassFile = com.topekalabs.file.utils.FileUtils.rebase(baseDirectory, backupDirectory, classFile); if (backupClassFile.exists() && (classFile.lastModified() <= backupClassFile.lastModified())) { log.info(classFile + " is up to date"); continue; } log.info(String.format("Enhancing class file bytecode for Javaflow: %s", classFile)); RewritingUtils.rewriteClassFile(classFile, transformer, instrumentedClassFile); if (backupClassFile.exists()) { log.debug(String.format("Backup for original class file %s already exists - removing it", backupClassFile)); backupClassFile.delete(); } log.info(String.format("Renaming original class file from %s to %s", classFile, backupClassFile)); FileUtils.moveFile(classFile, backupClassFile); log.info(String.format("Renaming rewritten class file from %s to %s", instrumentedClassFile, classFile)); FileUtils.moveFile(instrumentedClassFile, classFile); backupClassFile.setLastModified(classFile.lastModified()); } catch (IOException e) { throw new MojoExecutionException(e.getMessage()); } } }
From source file:com.umakantpatil.FileDownloader.java
License:Apache License
/** * Downloads, copies and untars PHP Code Sniffer. * * Example URL of a download package is//from w ww .j a va 2 s.c o m * http://download.pear.php.net/package/PHP_CodeSniffer-2.4.0.tgz * * @param phpCodeSnifferDownloadPath Path where to download PHP CodeSniffer * @param phpCodeSnifferVersion Which version to download. * @param logger Logger class to log the details for debugging. * * @since 0.0.1 * @throws DownloadFailed If version provided is not available on the website. * Or any IO Exception is thrown. */ public String get(String phpCodeSnifferDownloadPath, String phpCodeSnifferVersion, Log logger) throws DownloadFailed { InputStream is = null; FileOutputStream fos = null; String ds = File.separator; // System's temp directory. String tempDir = System.getProperty("java.io.tmpdir"); // Where to download sniffer temporary. String tempSniff = tempDir + ds + "PHPCodeSniffer" + phpCodeSnifferVersion; // Where to untar the downloaded sniffer. String tempUntaredSniff = tempDir + ds + "PHPCodeSniffer-untar-" + phpCodeSnifferVersion; String downloadPath = "http://download.pear.php.net/package/PHP_CodeSniffer-" + phpCodeSnifferVersion + ".tgz"; logger.info("Downloading PHP CodeSniffer from " + downloadPath); try { logger.debug("Dowmloading PHP CodeSniffer at " + tempSniff); URL url; url = new URL(downloadPath); URLConnection urlConn = url.openConnection(); is = urlConn.getInputStream(); fos = new FileOutputStream(tempSniff); byte[] buffer = new byte[4096]; int len; while ((len = is.read(buffer)) > 0) { fos.write(buffer, 0, len); } if (is != null) { is.close(); } } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { throw new DownloadFailed( "Provided version of PHP CodeSniffer is wrong or check your internet connection. details: " + e.getMessage()); } finally { try { if (fos != null) { fos.close(); } } catch (Exception e) { // TODO:: Catch right exceptions, not all. } } try { Archiver archiver = ArchiverFactory.createArchiver("tar", "gz"); archiver.extract(new File(tempSniff), new File(tempUntaredSniff)); logger.debug("Temporary untar directory is " + tempUntaredSniff); String tempSniffFolder = tempUntaredSniff + ds + "PHP_CodeSniffer-" + phpCodeSnifferVersion; File srcDir = new File(tempSniffFolder); File destDir = new File(phpCodeSnifferDownloadPath); recursiveCopy(srcDir, destDir); logger.debug("Copying PHP CodeSniffer from " + srcDir.getAbsolutePath()); logger.debug("Copying PHP CodeSniffer to " + destDir.getAbsolutePath()); File f = new File(phpCodeSnifferDownloadPath + ds + phpCodeSnifferVersion); f.createNewFile(); } catch (IOException e) { e.printStackTrace(); } return phpCodeSnifferDownloadPath; }
From source file:com.umakantpatil.PHPCodeSnifferDownloaderMojo.java
License:Apache License
/** * Checks if PHP CodeSniffer version exists at the path. * * @since 0.0.2//from ww w . j a va 2 s .c o m * @return Boolean If PHP CodeSniffer Exists. */ protected boolean checkIfPhpCodeSnifferExists() { String phpSniffPath = pathToPHPCodeSniffer(); File f = new File(phpSniffPath + File.separator + phpCodeSnifferVersion); Log logger = getLog(); logger.debug("Checking if file exists at " + f.getAbsolutePath()); if (f.exists()) { logger.info("PHP CodeSniffer " + phpCodeSnifferVersion + " already exists."); return true; } return false; }
From source file:com.wibidata.maven.plugins.hbase.MiniHBaseClusterSingleton.java
License:Apache License
/** * Stops the HBase cluster and blocks until is has been shutdown completely. * * @param log The maven log.//ww w. j a v a 2s . c o m */ public void stop(Log log) { if (null == mCluster) { log.error("Attempted to stop a cluster, but no cluster was ever started in this process."); return; } log.info("Stopping the HBase cluster thread..."); mThread.stopClusterGracefully(); while (mThread.isAlive()) { try { mThread.join(); } catch (InterruptedException e) { log.debug("HBase cluster thread interrupted."); } } log.info("HBase cluster thread stopped."); }
From source file:com.xebia.os.maven.couchdocsplugin.UpdateCouchDocsMojo.java
License:Apache License
private void dumpConfig() { final Log log = getLog(); if (log.isDebugEnabled()) { log.debug("Using configuration:"); log.debug(" couchUrl : " + couchUrl); log.debug(" baseDir : " + baseDir); log.debug(" unknownDatabases: " + unknownDatabases); log.debug(" existingDocs : " + existingDocs); log.debug(" failOnError : " + failOnError); }//from w w w.j a v a2s . c o m }
From source file:cool.arch.iconfist.enforcer.ClassPackageMembershipRule.java
License:Apache License
private void attemptProcessClasses(final Log log, final String groupId, final String artifactId, final String target, final String artifactIdPrefix) throws IOException, EnforcerRuleException { final String unprefixedArtifactId = artifactId.substring(artifactIdPrefix.length()); final StringBuilder requiredPackage = new StringBuilder(groupId).append(".") .append(unprefixedArtifactId.replace("-", ".")); final ClassFinder fileVisitor = new ClassFinder(requiredPackage.toString()); final File targetFolder = new File(target); if (!targetFolder.exists()) { targetFolder.mkdirs();/*from w w w .j av a 2s . com*/ } final Path root = Paths.get(target); log.debug(MessageFormat.format("Attempting to search: {0}", root.toString())); Files.walkFileTree(root, fileVisitor); if (!fileVisitor.getRejectedClassNames().isEmpty()) { final String message = buildError(requiredPackage.toString(), fileVisitor.getRejectedClassNames()); if (warnOnly) { log.warn(message); } else { throw new EnforcerRuleException(message); } } }
From source file:cool.arch.iconfist.enforcer.PackageInfoPresenceRule.java
License:Apache License
private void attemptProcessClasses(final Log log, final String sourceDirectoryRoot, final String groupId, final String artifactId, final String artifactIdPrefix) throws IOException, EnforcerRuleException { final File srcDirectory = new File(sourceDirectoryRoot); if (!srcDirectory.exists()) { return;//w w w. j a v a 2 s .c o m } final DirectoryFinder fileVisitor = new DirectoryFinder(); final String unprefixedArtifactId = artifactId.substring(artifactIdPrefix.length()); final StringBuilder requiredPackage = new StringBuilder(groupId).append(".") .append(unprefixedArtifactId.replace("-", "/")); final Path root = Paths.get(sourceDirectoryRoot + File.separatorChar + requiredPackage.toString().replace('.', File.separatorChar)); log.debug(MessageFormat.format("Attempting to search: {0}", root.toString())); Files.walkFileTree(root, fileVisitor); if (!fileVisitor.getRejectedPackages().isEmpty()) { final String message = buildError(fileVisitor.getRejectedPackages()); if (warnOnly) { log.warn(message); } else { throw new EnforcerRuleException(message); } } }
From source file:croche.maven.plugin.jira.AbstractJiraMojo.java
License:Apache License
public final void execute() throws MojoExecutionException, MojoFailureException { Log log = getLog(); if (isSkip()) { log.info("Skipping Plugin execution."); return;//from w ww.j a v a 2s .c om } try { JiraSoapService jiraService = getJiraSoapService(); loadUserInfoFromSettings(); log.debug("Logging in JIRA"); String loginToken = jiraService.login(this.jiraUser, this.jiraPassword); log.debug("Logged in JIRA"); try { doExecute(jiraService, loginToken); } finally { log.debug("Logging out from JIRA"); jiraService.logout(loginToken); log.debug("Logged out from JIRA"); } } catch (Exception e) { log.error("Error when executing mojo", e); } }
From source file:croche.maven.plugin.jira.SyncVersionMojo.java
License:Apache License
/** * {@inheritDoc}//w w w . ja v a2 s .c o m * @see croche.maven.plugin.jira.AbstractJiraMojo#doExecute(com.atlassian.jira.rpc.soap.client.JiraSoapService, java.lang.String) */ @Override public void doExecute(JiraSoapService jiraService, String loginToken) throws Exception { JiraVersionSpec versionSpec = new JiraVersionSpec(); versionSpec.setExistingVersion(getProjectVersion()); versionSpec.setJiraVersionPrefix(getJiraVersionPrefix()); String jiraVersion = versionSpec.generateCurrentJiraVersion(); Log log = getLog(); RemoteVersion[] versions = jiraService.getVersions(loginToken, this.jiraProjectKey); // check if this version exists in jira, if not create it if (!isVersionAlreadyPresent(versions, jiraVersion)) { RemoteVersion newVersion = new RemoteVersion(); log.debug("New Version in JIRA is: " + jiraVersion); newVersion.setName(jiraVersion); jiraService.addVersion(loginToken, this.jiraProjectKey, newVersion); log.info("Version created in JIRA for project key " + this.jiraProjectKey + " : " + jiraVersion); } else { log.info(String.format("Version %s is already created in JIRA. Nothing to do.", jiraVersion)); } }