List of usage examples for org.apache.maven.plugin.logging Log info
void info(Throwable error);
From source file:org.kaazing.k3po.maven.plugin.internal.StartMojo.java
License:Open Source License
@Override protected void executeImpl() throws MojoExecutionException { try {/*w w w . j a va 2 s . c om*/ ClassLoader scriptLoader = createScriptLoader(); RobotServer server = new RobotServer(getControl(), verbose, scriptLoader); // TODO: detect Maven version to determine logger factory // 3.0 -> MavenLoggerFactory // 3.1 -> Slf4JLoggerFactory // see http://brettporter.wordpress.com/2010/10/05/creating-a-custom-build-extension-for-maven-3-0/ // note: using SLf4J for Robot breaks in Maven 3.0 at runtime // setDefaultFactory(new Slf4JLoggerFactory()); // use Maven3 logger for Robot when started via plugin Log log = getLog(); setDefaultFactory(new MavenLoggerFactory(log)); long checkpoint = currentTimeMillis(); server.start(); float duration = (currentTimeMillis() - checkpoint) / 1000.0f; if (log.isDebugEnabled()) { if (!daemon) { log.debug(format("K3PO [%08x] started in %.3fsec (CTRL+C to stop)", identityHashCode(server), duration)); } else { log.debug(format("K3PO [%08x] started in %.3fsec", identityHashCode(server), duration)); } } else { if (!daemon) { log.info("K3PO started (CTRL+C to stop)"); } else { log.info("K3PO started"); } } setServer(server); if (!daemon) { server.join(); } } catch (Exception e) { throw new MojoExecutionException("K3PO failed to start", e); } }
From source file:org.kie.maven.plugin.CompilerHelper.java
License:Apache License
public void shareKieObjectsWithMap(InternalKieModule kModule, String compilationID, Map<String, Object> kieMap, Log log) { if (kModule != null && compilationID != null) { KieMetaInfoBuilder builder = new KieMetaInfoBuilder(kModule); KieModuleMetaInfo modelMetaInfo = builder.getKieModuleMetaInfo(); if (modelMetaInfo != null) { /*Standard for the kieMap keys -> compilationID + dot + class name */ StringBuilder sbModelMetaInfo = new StringBuilder(compilationID).append(".") .append(KieModuleMetaInfo.class.getName()); kieMap.put(sbModelMetaInfo.toString(), modelMetaInfo); log.info("KieModelMetaInfo available in the map shared with the Maven Embedder with key:" + sbModelMetaInfo.toString()); }// w w w. j a v a 2 s .c o m if (kModule != null) { /*Standard for the kieMap keys -> compilationID + dot + class name */ StringBuilder sbkModule = new StringBuilder(compilationID).append(".") .append(FileKieModule.class.getName()); kieMap.put(sbkModule.toString(), kModule); log.info("KieModule available in the map shared with the Maven Embedder with key:" + sbkModule.toString()); } } }
From source file:org.kie.maven.plugin.CompilerHelper.java
License:Apache License
public void shareStoreWithMap(ClassLoader classLoader, String compilationID, Map<String, Object> kieMap, Log log) { if (classLoader instanceof ProjectClassLoader) { ProjectClassLoader projectClassloder = (ProjectClassLoader) classLoader; Map<String, byte[]> types = projectClassloder.getStore(); if (projectClassloder.getStore() != null) { StringBuilder sbTypes = new StringBuilder(compilationID).append(".") .append("ProjectClassloaderStore"); kieMap.put(sbTypes.toString(), types); log.info("ProjectClassloader Store available in the map shared with the Maven Embedder"); }/*from w ww.j a v a 2 s.com*/ } }
From source file:org.kie.maven.plugin.CompilerHelper.java
License:Apache License
public void shareTypesMetaInfoWithMap(Map<String, TypeMetaInfo> typesMetaInfo, Map<String, Object> kieMap, String compilationID, Log log) { if (typesMetaInfo != null) { StringBuilder sbTypes = new StringBuilder(compilationID).append(".") .append(TypeMetaInfo.class.getName()); Set<String> eventClasses = new HashSet<>(); for (Map.Entry<String, TypeMetaInfo> item : typesMetaInfo.entrySet()) { if (item.getValue().isEvent()) { eventClasses.add(item.getKey()); }/*from w ww . ja v a2 s. c o m*/ } if (!eventClasses.isEmpty()) { kieMap.put(sbTypes.toString(), eventClasses); log.info("TypesMetaInfo keys available in the map shared with the Maven Embedder"); } } }
From source file:org.kie.server.controller.log.LogHelper.java
License:Apache License
public static void logServerTemplate(Log log, ServerTemplate serverTemplate) { log.info("--- Server Template --- "); log.info("Server Template Id: " + serverTemplate.getId()); log.info("Server Template Name: " + serverTemplate.getName()); log.info("Capabilities: " + serverTemplate.getCapabilities()); for (ServerInstanceKey server : serverTemplate.getServerInstanceKeys()) { log.info(" Server: " + server.getUrl()); }/* w w w . java2s . co m*/ logContainers(log, serverTemplate.getContainersSpec()); log.info("----------------------- "); }
From source file:org.kie.server.controller.log.LogHelper.java
License:Apache License
public static void logContainer(Log log, ContainerSpec container) { log.info(" --- Container --- "); log.info(" Container: " + container.getId()); log.info(" Release: " + container.getReleasedId()); log.info(" Status: " + container.getStatus()); for (Map.Entry<Capability, ContainerConfig> capability : container.getConfigs().entrySet()) { log.info(" Capability: " + capability.getKey().toString()); log.info(" Config: " + writeConfig(capability.getValue())); }// ww w . j a va 2 s .com log.info(" ----------------- "); }
From source file:org.kiji.maven.plugins.hbase.PluginMiniHBaseClusterSingleton.java
License:Apache License
/** * Starts the HBase cluster and blocks until it is ready. * * @param log The maven log. * @param alsoStartMapReduce Whether to also start a mini MapReduce cluster. * @param conf Hadoop configuration for the cluster. * @throws IOException If there is an error. *//* ww w .j a v a2 s . c o m*/ public void startAndWaitUntilReady(final Log log, final boolean alsoStartMapReduce, final Configuration conf) throws IOException { _miniCluster = new PluginMiniHBaseCluster(log, alsoStartMapReduce, conf); _miniHBaseClusterThread = new PluginMiniHBaseClusterThread(log, _miniCluster); log.info("Starting new thread..."); _miniHBaseClusterThread.start(); // Wait for the cluster to be ready. log.info("Waiting for cluster to be ready..."); while (!_miniHBaseClusterThread.isClusterReady()) { try { Thread.sleep(1000); } catch (final InterruptedException e) { log.info("Still waiting..."); } } log.info("Finished waiting for HBase cluster thread."); }
From source file:org.kiji.maven.plugins.hbase.PluginMiniHBaseClusterSingleton.java
License:Apache License
/** * Stops the HBase cluster and blocks until is has been shutdown completely. * * @param log The maven log.//from w w w.j a va2s .c om */ public void stop(final Log log) { if (null == _miniCluster) { log.error("Attempted to stop a cluster, but no cluster was ever started in this process."); return; } log.info("Stopping the HBase cluster thread..."); _miniHBaseClusterThread.stopClusterGracefully(); while (_miniHBaseClusterThread.isAlive()) { try { _miniHBaseClusterThread.join(); } catch (final InterruptedException e) { log.debug("HBase cluster thread interrupted."); } } log.info("HBase cluster thread stopped."); }
From source file:org.lazydoc.plugin.LazyDocMojo.java
License:Apache License
@Override public void execute() throws MojoExecutionException, MojoFailureException { Log log = getLog(); String logLevel = log.isDebugEnabled() ? "DEBUG" : log.isWarnEnabled() ? "WARN" : log.isInfoEnabled() ? "INFO" : "ERROR"; log.info("Log level is " + logLevel); log.debug(config.toString());// w ww . j av a 2s . c o m try { ClassLoader classLoader = getClassLoader(); Thread.currentThread().setContextClassLoader(classLoader); Class<?> lazyDocClass = classLoader.loadClass("org.lazydoc.LazyDoc"); Class<?> lazyDocConfigClass = classLoader.loadClass("org.lazydoc.config.Config"); Class<?> lazyDocPrinterConfigClass = classLoader.loadClass("org.lazydoc.config.PrinterConfig"); Object lazydocConfig = lazyDocConfigClass.newInstance(); BeanUtils.copyProperties(lazydocConfig, config); List lazyDocPrinterConfigs = new ArrayList(); if (printerConfigs != null) { for (PrinterConfig printerConfig : printerConfigs) { Object lazydocPrinterConfig = lazyDocPrinterConfigClass.newInstance(); BeanUtils.copyProperties(lazydocPrinterConfig, printerConfig); lazyDocPrinterConfigs.add(lazydocPrinterConfig); } } lazyDocClass.getDeclaredMethod("document", lazyDocConfigClass, List.class, String.class) .invoke(lazyDocClass.newInstance(), lazydocConfig, lazyDocPrinterConfigs, logLevel); } catch (Exception e) { getLog().error("Error parsing for documentation.", e); throw new MojoFailureException("Error parsing for documentation." + e.getMessage()); } }
From source file:org.mrgeo.plugins.GeneratePom.java
License:Apache License
public void execute() throws MojoExecutionException { Log log = getLog(); try {/*from ww w .j ava 2 s .c o m*/ MavenXpp3Writer writer = new MavenXpp3Writer(); Model model = project.getModel(); String originalGroupId = model.getGroupId(); String originalArtifactId = model.getArtifactId(); String originalVersion = model.getVersion(); if (!groupId.equals(originalGroupId)) { log.info("groupId: " + groupId); model.setGroupId(groupId); } if (!artifactId.equals(originalArtifactId)) { log.info("artifactId: " + artifactId); model.setArtifactId(artifactId); } if (!version.equals(originalVersion)) { log.info("version: " + version); model.setVersion(version); } if (project.hasParent()) { String parentVersion = project.getParent().getVersion(); Parent mParent = model.getParent(); if (mParent != null) { mParent.setVersion(parentVersion); log.info("parent: " + mParent.toString()); } } //model.setProperties(null); String basedir = model.getProjectDirectory().toString(); Build build = model.getBuild(); String target = build.getDirectory(); // get all the dependencies org.apache.maven.shared.dependency.graph.DependencyNode root = dependencyGraphBuilder .buildDependencyGraph(project, null); DependencyVisitor visitor = new DependencyVisitor(); root.accept(visitor); // add any missing dependencies from the graph to our list. These will be all inherited // dependencies not explicitly referenced out in the pom List<Dependency> dependencies = model.getDependencies(); for (Artifact artifact : visitor.getArtifacts()) { if (contains(artifact, dependencies)) { Dependency dep = new Dependency(); dep.setArtifactId(artifact.getArtifactId()); dep.setGroupId(artifact.getGroupId()); dep.setVersion(artifact.getVersion()); dep.setClassifier(artifact.getClassifier()); dep.setScope(artifact.getScope()); dep.setType(artifact.getType()); dep.setVersion(artifact.getVersion()); dependencies.add(dep); } } // OK, now find any org.mrgeo dependencies and change the group version accordingly for (Dependency dep : dependencies) { if (dep.getGroupId().equals(originalGroupId) && dep.getVersion().equals(originalVersion)) { dep.setGroupId(groupId); dep.setVersion(version); } } model.setDependencies(dependencies); // no need for dependencyManagement, the dependency section includes all dependencies. // ignore this if we don't have parents (A top-level POM) if (project.hasParent()) { model.setDependencyManagement(null); } else { DependencyManagement dependencyManagement = model.getDependencyManagement(); List<Dependency> dependencyManagements = dependencyManagement.getDependencies(); for (Dependency dep : dependencyManagements) { if (dep.getGroupId().equals(originalGroupId) && dep.getVersion().equals(originalVersion)) { dep.setGroupId(groupId); dep.setVersion(version); } } model.setDependencyManagement(dependencyManagement); } StringWriter stringWriter = new StringWriter(); writer.write(stringWriter, model); String pom = stringWriter.toString(); String saveme = "___save_me___"; String targettag = "<directory>" + target + "</directory>"; // make a placeholder for the <directory> tag for the target directory pom = pom.replace(targettag, saveme); // this simply replace the fully qualified paths with the ${} equivalent pom = pom.replace(target, "${project.build.directory}"); // now undo the tag for the target directory, otherwise pom = pom.replace(saveme, targettag); pom = pom.replace(basedir, "${project.basedir}"); if (!outputFile.getParentFile().exists()) { outputFile.getParentFile().mkdirs(); } if (outputFile.exists()) { outputFile.delete(); } log.info("Writing to: " + outputFile); log.info(" pom length: " + pom.length()); FileOutputStream fos = new FileOutputStream(outputFile); PrintWriter pw = new PrintWriter(fos); pw.write(pom); pw.close(); fos.close(); } catch (Exception e) { e.printStackTrace(); throw new MojoExecutionException(e, "error", "error"); } }