List of usage examples for org.apache.maven.plugin.logging Log info
void info(Throwable error);
From source file:cool.arch.iconfist.enforcer.PackageInfoPresenceRule.java
License:Apache License
/** * {@inheritDoc}//from w ww .j a va2 s . c o m */ @Override public void execute(final EnforcerRuleHelper helper) throws EnforcerRuleException { final Log log = helper.getLog(); try { final String sourceDirectoryRoot = (String) helper.evaluate("${basedir}/src/main/java"); final String groupId = (String) helper.evaluate("${project.groupId}"); final String packaging = (String) helper.evaluate("${project.packaging}"); final String artifactIdPrefix = (String) helper.evaluate("${stack.artifactId.prefix}"); final String artifactId = (String) helper.evaluate("${project.artifactId}"); switch (packaging) { case "jar": case "war": case "ear": attemptProcessClasses(log, sourceDirectoryRoot, groupId, artifactId, artifactIdPrefix); break; default: log.info(MessageFormat.format("Not an applicable project type '{0}'. Skipping rule checks for {1}.", packaging, this.getClass().getSimpleName())); break; } } catch (final ExpressionEvaluationException e) { throw new EnforcerRuleException( MessageFormat.format("Unable to lookup an expression: {0}", e.getLocalizedMessage()), e); } catch (final IOException e) { throw new EnforcerRuleException("Error attempting to locate directories.", e); } }
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 w w.jav a 2 s . c o m*/ } 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.ReleaseMultipleJiraVersionsMojo.java
License:Apache License
/** * {@inheritDoc}/*from w ww . ja v a 2 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 { boolean isBranch = this.scmConnection != null && this.scmConnection.contains("branches"); Log log = getLog(); log.info("ReleaseMultipleJiraVersionsMojo current projectVersion: " + this.projectVersion + ", scmConnection: " + this.scmConnection); JiraVersionManager versionManager = new JiraVersionManager(jiraService, loginToken, getLog()); if (this.jiraVersionSpecs == null || this.jiraVersionSpecs.length == 0) { log.warn( "ReleaseMultipleJiraVersionsMojo not releasing jira versions as no versions were configured in the configuration."); } else if (this.projectVersion.contains("SNAPSHOT")) { log.info("ReleaseMultipleJiraVersionsMojo not releasing jira versions as projectVersion: " + this.projectVersion + " is a snapshot but will create any existing versions if necessary"); for (JiraVersionSpec versionSpec : this.jiraVersionSpecs) { versionManager.optionallyCreateVersion(versionSpec); } } else { for (JiraVersionSpec versionSpec : this.jiraVersionSpecs) { versionManager.releaseVersion(versionSpec, isBranch); } } }
From source file:croche.maven.plugin.jira.ReleaseVersionMojo.java
License:Apache License
/** * {@inheritDoc}/*from w ww .j a v a 2 s.c om*/ * @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 { Log log = getLog(); boolean isBranch = this.scmConnection != null && this.scmConnection.contains("branches"); log.info("ReleaseVersionMojo current projectVersion: " + this.projectVersion + ", scmConnection: " + this.scmConnection); JiraVersionManager versionManager = new JiraVersionManager(jiraService, loginToken, getLog()); JiraVersionSpec versionSpec = new JiraVersionSpec(); versionSpec.setExistingVersion(this.projectVersion); versionSpec.setJiraProjectKey(this.jiraProjectKey); versionSpec.setJiraVersionPrefix(this.jiraVersionPrefix); versionSpec.setNextVersionGroup(this.nextVersionGroup); versionSpec.setNextVersionRegex(this.nextVersionRegex); versionSpec.setNextVersionReplacement(this.nextVersionReplacement); versionSpec.setMaxIssuesToUpdate(this.maxIssuesToUpdate); versionSpec.setVersionType(this.versionType); versionSpec.setMoveIssuesToNextJiraVersion(this.moveIssuesToNextJiraVersion); if (this.projectVersion.contains("SNAPSHOT")) { log.info("ReleaseVersionMojo not releasing jira version as projectVersion: " + this.projectVersion + " is a snapshot, however matching jira version will be created if necessary"); versionManager.optionallyCreateVersion(versionSpec); } else { versionManager.releaseVersion(versionSpec, isBranch); } }
From source file:croche.maven.plugin.jira.SyncVersionMojo.java
License:Apache License
/** * {@inheritDoc}/* w w w . java2 s. com*/ * @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)); } }
From source file:de.bbe_consulting.mavento.helper.DiffUtil.java
License:Apache License
/** * Apply diff style patchFile to targetPath. dryRun will not write any changes to disk. * /*w ww.j a v a2 s .c o m*/ * @param patchFile * @param targetPath * @param dryRun * @param silent * @param logger * @throws IOException * @throws MojoExecutionException * @throws PatchFailedException */ public static void patchDirectory(String patchFile, String targetPath, boolean dryRun, boolean silent, Log logger) throws IOException, MojoExecutionException, PatchFailedException { final List<DiffPatch> filteredPatchList = splitPatch(FileUtil.getFileAsLines(patchFile), targetPath); if (filteredPatchList.isEmpty()) { throw new MojoExecutionException("Patch file " + patchFile + " is not a valid diff file!"); } for (DiffPatch patchEntry : filteredPatchList) { if (!silent) { logger.info(".." + patchEntry.getPatchFileName() + " " + patchEntry.getStatsLine()); } Patch patch = DiffUtils.parseUnifiedDiff(patchEntry.getDiffContent()); @SuppressWarnings("unchecked") List<String> result = (List<String>) DiffUtils .patch(FileUtil.getFileAsLines(patchEntry.getTargetFileName()), patch); if (!dryRun) { FileUtil.writeFile(result, patchEntry.getTargetFileName()); } } if (!silent) { logger.info("..done."); } }
From source file:de.bbe_consulting.mavento.helper.FileUtil.java
License:Apache License
/** * Mass symlink files, wraps symlinkFile. * //ww w . j ava 2 s.com * @param fileNameMap map with source/target link * @param logger * @throws MojoExecutionException * @throws IOException */ public static void symlinkFiles(Map<String, String> fileNameMap, Log logger) throws MojoExecutionException, IOException { for (Map.Entry<String, String> fileNames : fileNameMap.entrySet()) { logger.info("..linking: " + fileNames.getKey()); symlinkFile(fileNames.getKey(), fileNames.getValue(), logger); } }
From source file:de.bbe_consulting.mavento.helper.MagentoSqlUtil.java
License:Apache License
/** * Reindex magento database./*from ww w. jav a 2 s . c om*/ * * @param magentoDir * @param logger * @throws MojoExecutionException */ public static void indexDb(String magentoDir, Log logger) throws MojoExecutionException { final Commandline cl = new Commandline(); cl.addArguments(new String[] { "indexer.php", "--reindexall" }); cl.setWorkingDirectory(magentoDir + "/shell"); cl.setExecutable("php"); final StringStreamConsumer output = new CommandLineUtils.StringStreamConsumer(); final StringStreamConsumer error = new CommandLineUtils.StringStreamConsumer(); try { logger.info("Rebuilding all magento indices.."); final int returnValue = CommandLineUtils.executeCommandLine(cl, output, error); if (returnValue != 0) { logger.info("retval: " + returnValue); logger.info(output.getOutput().toString()); logger.info(error.getOutput().toString()); throw new MojoExecutionException("Error while reindexing magento database!"); } logger.info("..done."); } catch (CommandLineException e) { throw new MojoExecutionException("Error while reindexing magento database!", e); } }
From source file:de.bbe_consulting.mavento.helper.MagentoSqlUtil.java
License:Apache License
/** * Execute raw sql query via mysql exec. * /*from w ww.ja va 2 s. c om*/ * @param query * @param cl * @param logger * @throws MojoExecutionException */ private static void executeRawSql(String query, Commandline cl, Log logger) throws MojoExecutionException { InputStream input = null; try { input = new ByteArrayInputStream(query.getBytes("UTF-8")); } catch (UnsupportedEncodingException e) { throw new MojoExecutionException("Error: " + e.getMessage(), e); } final StringStreamConsumer output = new CommandLineUtils.StringStreamConsumer(); final StringStreamConsumer error = new CommandLineUtils.StringStreamConsumer(); try { final int returnValue = CommandLineUtils.executeCommandLine(cl, input, output, error); if (returnValue != 0) { logger.debug("retval: " + returnValue); logger.debug(output.getOutput().toString()); logger.debug(error.getOutput().toString()); throw new MojoExecutionException(error.getOutput().toString()); } else { logger.info("..done."); } } catch (CommandLineException e) { throw new MojoExecutionException("Error: " + e.getMessage(), e); } }
From source file:de.bbe_consulting.mavento.helper.MagentoSqlUtil.java
License:Apache License
/** * Creates a new mysql database.//from w ww. j a v a2s . com * * @param magentoDbUser * @param magentoDbPasswd * @param magentoDbHost * @param magentoDbPort * @throws MojoExecutionException */ public static void createMagentoDb(String magentoDbUser, String magentoDbPasswd, String magentoDbHost, String magentoDbPort, String magentoDbName, Log logger) throws MojoExecutionException { try { logger.info("Creating database " + magentoDbName + ".."); String query = "CREATE DATABASE IF NOT EXISTS `" + magentoDbName + "`"; executeRawSql(query, magentoDbUser, magentoDbPasswd, magentoDbHost, magentoDbPort, logger); } catch (Exception e) { throw new MojoExecutionException("Error while creating database!", e); } }