List of usage examples for org.apache.maven.plugin.logging Log info
void info(Throwable error);
From source file:org.jasig.maven.plugin.sass.AbstractSassMojo.java
License:Apache License
protected void buildBasicSASSScript(final StringBuilder sassScript) throws MojoExecutionException { final Log log = this.getLog(); sassScript.append("require 'rubygems'\n"); if (gemPaths.length > 0) { sassScript.append("env = { 'GEM_PATH' => [\n"); for (final String gemPath : gemPaths) { sassScript.append(" '").append(gemPath).append("',\n"); }//from www . j ava 2s . c o m final String gemPath = System.getenv("GEM_PATH"); if (gemPath != null) { for (final String p : gemPath.split(File.pathSeparator)) { sassScript.append(" '").append(p).append("',\n"); } } sassScript.setLength(sassScript.length() - 2); // remove trailing comma sassScript.append("\n"); sassScript.append("] }\n"); sassScript.append("Gem.paths = env\n"); } for (final String gem : gems) { sassScript.append("require '").append(gem).append("'\n"); } sassScript.append("require 'sass/plugin'\n"); sassScript.append("require 'java'\n"); if (this.useCompass) { log.info("Running with Compass enabled."); sassScript.append("require 'compass'\n"); sassScript.append("require 'compass/exec'\n"); sassScript.append("Compass.add_project_configuration \n"); this.sassOptions.put("load_paths", "Compass.configuration.sass_load_paths"); // manually specify these paths sassScript.append( "Compass::Frameworks.register_directory('jar:'+ File.join(Compass::Core.base_directory, 'stylesheets'))\n"); } // Get all template locations from resources and set option 'template_location' and // 'css_location' (to override default "./public/stylesheets/sass", "./public/stylesheets") // remaining locations are added later with 'add_template_location' final Iterator<Entry<String, String>> templateLocations = getTemplateLocations(); if (templateLocations.hasNext()) { Entry<String, String> location = templateLocations.next(); sassOptions.put("template_location", "'" + location.getKey() + "'"); sassOptions.put("css_location", "'" + location.getValue() + "'"); } //If not explicitly set place the cache location in the target dir if (!this.sassOptions.containsKey("cache_location")) { final File sassCacheDir = new File(this.buildDirectory, "sass_cache"); final String sassCacheDirStr = sassCacheDir.toString(); this.sassOptions.put("cache_location", "'" + FilenameUtils.separatorsToUnix(sassCacheDirStr) + "'"); } //Add the plugin configuration options sassScript.append("Sass::Plugin.options.merge!(\n"); for (final Iterator<Entry<String, String>> entryItr = this.sassOptions.entrySet().iterator(); entryItr .hasNext();) { final Entry<String, String> optEntry = entryItr.next(); final String opt = optEntry.getKey(); final String value = optEntry.getValue(); sassScript.append(" :").append(opt).append(" => ").append(value); if (entryItr.hasNext()) { sassScript.append(","); } sassScript.append("\n"); } sassScript.append(")\n"); // add remaining template locations with 'add_template_location' (need to be done after options.merge) while (templateLocations.hasNext()) { Entry<String, String> location = templateLocations.next(); sassScript.append("Sass::Plugin.add_template_location('").append(location.getKey()).append("', '") .append(location.getValue()).append("')\n"); } // set up sass compiler callback for reporting sassScript.append( "Sass::Plugin.on_compilation_error {|error, template, css| $compiler_callback.compilationError(error.message, template, css) }\n"); sassScript.append( "Sass::Plugin.on_updated_stylesheet {|template, css| $compiler_callback.updatedStylesheeet(template, css) }\n"); sassScript.append( "Sass::Plugin.on_template_modified {|template| $compiler_callback.templateModified(template) }\n"); sassScript.append( "Sass::Plugin.on_template_created {|template| $compiler_callback.templateCreated(template) }\n"); sassScript.append( "Sass::Plugin.on_template_deleted {|template| $compiler_callback.templateDeleted(template) }\n"); // make ruby give use some debugging info when requested if (log.isDebugEnabled()) { sassScript.append("require 'pp'\npp Sass::Plugin.options\n"); if (useCompass) { sassScript.append("pp Compass::configuration\n"); } } }
From source file:org.jasig.maven.plugin.sass.AbstractSassMojo.java
License:Apache License
private Iterator<Entry<String, String>> getTemplateLocations() { final Log log = getLog(); List<Resource> r = this.resources; //If no resources specified if (r == null) { final Resource resource = new Resource(); resource.source = new FileSet(); resource.source.setDirectory(this.sassSourceDirectory.toString()); if (this.includes != null) { resource.source.setIncludes(Arrays.asList(this.includes)); }// ww w . j a v a2 s . c o m if (this.excludes != null) { resource.source.setExcludes(Arrays.asList(this.excludes)); } resource.relativeOutputDirectory = this.relativeOutputDirectory; resource.destination = this.destination; r = ImmutableList.of(resource); } List<Entry<String, String>> locations = new ArrayList<Entry<String, String>>(); for (final Resource source : r) { for (final Entry<String, String> entry : source.getDirectoriesAndDestinations().entrySet()) { log.info("Queueing SASS Template for compile: " + entry.getKey() + " => " + entry.getValue()); locations.add(entry); } } return locations.iterator(); }
From source file:org.jasig.resource.aggr.mojo.BatchSkinResourcesAggregatorMojo.java
License:Apache License
@Override public void execute() throws MojoExecutionException, MojoFailureException { final Log log = this.getLog(); try {/*w w w. ja v a 2s . c o m*/ final ResourcesAggregator aggr = this.createResourcesAggregator(); final Set<String> skinConfigurationFiles = this.findSkinConfigurationFiles(); for (final String fileName : skinConfigurationFiles) { log.info("Aggregating: " + fileName); final File skinConfigurationFile = new File(this.skinSourceDirectory, fileName); final File skinOutputDirectory = new File(this.baseOutputDirectory, fileName).getParentFile(); this.doAggregation(aggr, skinConfigurationFile, skinOutputDirectory); } } catch (AggregationException e) { throw new MojoExecutionException("aggregation failed", e); } catch (IOException e) { throw new MojoExecutionException("IOException occurred", e); } }
From source file:org.jbehave.site.JBehaveMojo.java
License:Apache License
@Override protected void executeReport(Locale arg0) throws MavenReportException { Log log = getLog(); if (sourceDirectory.exists()) { FreemarkerViewGenerator view = new FreemarkerViewGenerator(); view.generateReportsView(sourceDirectory, getFormats(), getViewResources()); ReportsCount count = view.getReportsCount(); log.info("Generated " + count.getStories() + " stories with " + count.getScenarios() + " scenarios"); log.info("Stories: " + (count.getStories() - count.getStoriesNotAllowed() - count.getStoriesPending()) + " success " + count.getStoriesPending() + " pending " + count.getStoriesNotAllowed() + " not allowed"); log.info("Scenarios: " + (count.getScenarios() - count.getScenariosNotAllowed() - count.getScenariosPending() + count.getScenariosFailed()) + " success " + count.getScenariosPending() + " pending " + count.getScenariosFailed() + " failed " + count.getScenariosNotAllowed() + " not allowed"); external = true;//from www . jav a 2s. com try { unpackViewResource(); copyCss(); } catch (IOException e) { log.warn(e); } catch (NoSuchElementException e) { log.warn(e); } catch (NullPointerException e) { log.warn(e); } } else { log.info("No story to report."); Sink sink = getSink(); sink.body(); sink.section1(); sink.sectionTitle1(); sink.text("No story to report."); sink.sectionTitle1_(); sink.section1_(); sink.body_(); sink.flush(); sink.close(); external = false; } }
From source file:org.jboss.as.plugin.server.Run.java
License:Open Source License
@Override protected void doExecute() throws MojoExecutionException, MojoFailureException { final Log log = getLog(); final File deploymentFile = file(); final String deploymentName = deploymentFile.getName(); final File targetDir = deploymentFile.getParentFile(); // The deployment must exist before we do anything if (!deploymentFile.exists()) { throw new MojoExecutionException( String.format("The deployment '%s' could not be found.", deploymentFile.getAbsolutePath())); }/*from ww w . j a v a 2 s. c o m*/ // Validate the environment final File jbossHome = extractIfRequired(targetDir); if (!jbossHome.isDirectory()) { throw new MojoExecutionException(String.format("JBOSS_HOME '%s' is not a valid directory.", jbossHome)); } final String javaHome; if (this.javaHome == null) { javaHome = SecurityActions.getEnvironmentVariable("JAVA_HOME"); } else { javaHome = this.javaHome; } final List<String> invalidPaths = modulesPath.validate(); if (!invalidPaths.isEmpty()) { throw new MojoExecutionException("Invalid module path(s). " + invalidPaths); } final ServerConfig serverConfig = ServerConfig.of(this, jbossHome).setJavaHome(javaHome) .setModulesDir(modulesPath.get()).setBundlesDir(bundlesPath).setJvmArgs(jvmArgs.getArgs()) .setServerConfig(this.serverConfig).setPropertiesFile(propertiesFile).setServerArgs(serverArgs) .setStartupTimeout(startupTimeout); // Print some server information log.info(String.format("JAVA_HOME=%s", javaHome)); log.info(String.format("JBOSS_HOME=%s%n", jbossHome)); try { // Create the server final Server server = new StandaloneServer(serverConfig); // Add the shutdown hook SecurityActions.registerShutdown(server); // Start the server log.info("Server is starting up. Press CTRL + C to stop the server."); server.start(); // Deploy the application server.checkServerState(); if (server.isRunning()) { log.info(String.format("Deploying application '%s'%n", deploymentFile.getName())); final ModelControllerClient client = server.getClient(); final Deployment deployment = StandaloneDeployment.create(client, deploymentFile, deploymentName, getType(), null, null); switch (executeDeployment(client, deployment)) { case REQUIRES_RESTART: { client.execute(ServerOperations.createOperation(ServerOperations.RELOAD)); break; } case SUCCESS: break; } } else { throw new DeploymentFailureException("Cannot deploy to a server that is not running."); } while (server.isRunning()) { TimeUnit.SECONDS.sleep(1L); } server.stop(); } catch (Exception e) { throw new MojoExecutionException("The server failed to start", e); } }
From source file:org.jboss.as.plugin.server.Start.java
License:Open Source License
@Override public void execute() throws MojoExecutionException, MojoFailureException { final Log log = getLog(); if (isSkip()) { log.debug("Skipping server start"); return;//from w w w .j av a 2s .c o m } // Validate the environment final File jbossHome = extractIfRequired(targetDir); if (!jbossHome.isDirectory()) { throw new MojoExecutionException(String.format("JBOSS_HOME '%s' is not a valid directory.", jbossHome)); } final String javaHome; if (this.javaHome == null) { javaHome = SecurityActions.getEnvironmentVariable("JAVA_HOME"); } else { javaHome = this.javaHome; } final List<String> invalidPaths = modulesPath.validate(); if (!invalidPaths.isEmpty()) { throw new MojoExecutionException("Invalid module path(s). " + invalidPaths); } final ServerConfig serverConfig = ServerConfig.of(this, jbossHome).setJavaHome(javaHome) .setModulesDir(modulesPath.get()).setBundlesDir(bundlesPath).setJvmArgs(jvmArgs.getArgs()) .setServerConfig(this.serverConfig).setPropertiesFile(propertiesFile).setServerArgs(serverArgs) .setStartupTimeout(startupTimeout); // Print some server information log.info(String.format("JAVA_HOME=%s", javaHome)); log.info(String.format("JBOSS_HOME=%s%n", jbossHome)); try { // Create the server final Server server = new StandaloneServer(serverConfig); // Add the shutdown hook SecurityActions.registerShutdown(server); // Start the server log.info("Server is starting up."); server.start(); server.checkServerState(); } catch (Exception e) { throw new MojoExecutionException("The server failed to start", e); } }
From source file:org.jboss.bridger.BridgerMojo.java
License:Open Source License
@Override public void execute() throws MojoExecutionException, MojoFailureException { final Log log = getLog(); if (skip) {/*w ww. j a v a 2 s . co m*/ log.info("Skipping bridger transform"); } else { final Bridger bridger = new Bridger(); final File[] files = getFiles(); if (log.isDebugEnabled()) { final String newLine = String.format("%n\t"); final StringBuilder sb = new StringBuilder("Transforming Files:"); sb.append(newLine); for (File file : files) { sb.append(file.getAbsolutePath()).append(newLine); } log.debug(sb); } bridger.transformRecursive(files); log.info(String.format("Translated %d methods and %d method calls%n", bridger.getTransformedMethodCount(), bridger.getTransformedMethodCallCount())); } }
From source file:org.jboss.maven.plugins.qstools.AbstractProjectWalker.java
License:Apache License
@Override public Map<String, List<Violation>> check(MavenProject project, MavenSession mavenSession, List<MavenProject> reactorProjects, Log log) throws QSToolsException { Map<String, List<Violation>> results = new TreeMap<String, List<Violation>>(); // iterate over all reactor projects walk(WalkType.CHECK, project, mavenSession, reactorProjects, log, results); if (getCheckerMessage() != null) { log.info("--> Checker Message: " + getCheckerMessage()); }/* ww w. j a v a 2 s . com*/ if (violationsQtd > 0) { log.info("There are " + violationsQtd + " checkers violations"); } return results; }
From source file:org.jboss.maven.plugins.qstools.checkers.AbstractCheckstyleChecker.java
License:Apache License
@Override public Map<String, List<Violation>> check(MavenProject project, MavenSession mavenSession, List<MavenProject> reactorProjects, Log log) throws QSToolsException { Map<String, List<Violation>> results = new TreeMap<String, List<Violation>>(); if (configurationProvider.getQuickstartsRules(project.getGroupId()).isCheckerIgnored(this.getClass())) { checkerMessage = "This checker is ignored for this groupId in config file."; } else {//www . j a v a 2 s . com CheckstyleExecutorRequest executorRequest = new CheckstyleExecutorRequest(); Rules rules = configurationProvider.getQuickstartsRules(project.getGroupId()); try { executorRequest.setReactorProjects(reactorProjects).setSourceDirectory(project.getBasedir()) .setTestSourceDirectory(project.getBasedir()).setFailsOnError(false).setProject(project) .setConfigLocation(getCheckstyleConfig()).setLog(log).setEncoding("UTF-8") .setHeaderLocation(rules.getHeaderLocation()).setIncludes(getIncludes()) .setExcludes(rules.getExcludes() + ", " + rules.getCheckerSpecificExcludes(this)); CheckstyleResults checkstyleResults = checkstyleExecutor.executeCheckstyle(executorRequest); Map<String, List<AuditEvent>> files = checkstyleResults.getFiles(); for (String file : files.keySet()) { List<AuditEvent> events = files.get(file); // If file has events/violations if (events.size() > 0) { List<Violation> violations = new ArrayList<Violation>(); for (AuditEvent event : events) { // Add each checktyle AuditEvent as a new Violation violations.add(new Violation(this.getClass(), event.getLine(), event.getMessage())); violationsQtd++; } results.put(file, violations); } } } catch (Exception e) { throw new QSToolsException(e); } } if (getCheckerMessage() != null) { log.info("--> Checker Message: " + getCheckerMessage()); } return results; }
From source file:org.jboss.maven.plugins.qstools.checkers.AbstractProjectChecker.java
License:Apache License
@Override @SuppressWarnings("unchecked") public Map<String, List<Violation>> check(MavenProject project, MavenSession mavenSession, List<MavenProject> reactorProjects, Log log) throws QSCheckerException { this.mavenSession = mavenSession; this.log = log; Map<String, List<Violation>> results = new TreeMap<String, List<Violation>>(); try {/*from w ww.ja v a 2 s .com*/ List<String> ignoredQuickstarts = (List<String>) context.get(Constants.IGNORED_QUICKSTARTS_CONTEXT); for (MavenProject mavenProject : reactorProjects) { if (!ignoredQuickstarts.contains(mavenProject.getBasedir().getName())) { Document doc = PositionalXMLReader.readXML(new FileInputStream(mavenProject.getFile())); if (configurationProvider.getQuickstartsRules(project.getGroupId()).isCheckerIgnored(this)) { String msg = "Skiping %s for %s:%s"; log.warn(String.format(msg, this.getClass().getSimpleName(), project.getGroupId(), project.getArtifactId())); } else { processProject(mavenProject, doc, results); } } else { log.debug("Ignoring " + mavenProject.getBasedir().getName() + ". It is listed on .quickstarts_ignore file"); } } if (violationsQtd > 0) { log.info("There are " + violationsQtd + " checkers errors"); } } catch (Exception e) { // Any other exception is a problem. throw new QSCheckerException(e); } return results; }