List of usage examples for org.apache.maven.plugin.logging Log debug
void debug(Throwable error);
From source file:org.jetbrains.kotlin.maven.KotlinCompileMojoBase.java
License:Apache License
protected void configureBaseCompilerArguments(Log log, K2JVMCompilerArguments arguments, String module, List<String> sources, List<String> classpath, String output) throws MojoExecutionException { // don't include runtime, it should be in maven dependencies arguments.noStdlib = true;/*from www . ja v a 2 s .c o m*/ final ArrayList<String> classpathList = new ArrayList<String>(); if (module != null) { log.info("Compiling Kotlin module " + module); arguments.setModule(module); } else { if (sources.size() <= 0) throw new MojoExecutionException("No source roots to compile"); arguments.setSourceDirs(sources); log.info("Compiling Kotlin sources from " + arguments.getSourceDirs()); // TODO: Move it compiler classpathList.addAll(sources); } classpathList.addAll(classpath); if (classpathList.remove(output)) { log.debug("Removed target directory from compiler classpath (" + output + ")"); } // final String runtime = getRuntimeFromClassPath(classpath); // if (runtime != null) { // log.debug("Removed Kotlin runtime from compiler classpath (" + runtime + ")"); // classpathList.remove(runtime); // } if (classpathList.size() > 0) { final String classPathString = Joiner.on(File.pathSeparator).join(classpathList); log.info("Classpath: " + classPathString); arguments.setClasspath(classPathString); } log.info("Classes directory is " + output); arguments.setOutputDir(output); arguments.noJdkAnnotations = true; arguments.annotations = getFullAnnotationsPath(log, annotationPaths); log.info("Using kotlin annotations from " + arguments.annotations); }
From source file:org.junite2.MyMojo.java
License:Apache License
protected void execute(JUnitEETest test) throws Exception { StringBuffer arguments = new StringBuffer(); boolean done; String sessionCookie;//from w w w. j a v a 2 s . c o m URL requestUrl; URLConnection con; Log log = getLog(); arguments.append(url).append("?output=xml"); if (threaded) { log.debug("Threaded mode"); arguments.append("&thread=true"); } if (test.getResource() != null) { arguments.append("&resource=").append(test.getResource()); } if (test.getRunall()) { arguments.append("&all=true"); } else if (test.getName() != null) { arguments.append("&suite=").append(URLEncoder.encode(test.getName())); } else { throw new Exception("You must specify the test name or runall attribute"); } if (!test.getFiltertrace()) { arguments.append("&filterTrace=false"); } log.debug("url is " + arguments.toString()); InputStream in = null; requestUrl = new URL(arguments.toString()); try { con = requestUrl.openConnection(); sessionCookie = con.getHeaderField("Set-Cookie"); log.debug("Session cookie : " + sessionCookie); if (sessionCookie != null) { int index = sessionCookie.indexOf(';'); if (index != -1) { sessionCookie = sessionCookie.substring(0, index); } } in = con.getInputStream(); done = parseResult(in, test); } catch (MojoExecutionException me) { throw me; } catch (Exception e) { throw new Exception("Error accessing url " + requestUrl.toString(), e); } finally { if (in != null) { try { in.close(); } catch (IOException e) { } ; } } try { while (!done) { try { log.debug("Sleeping ... "); Thread.sleep(1000); } catch (InterruptedException e) { // continue work } //log("Get xml again using URL " + requestUrl, Project.MSG_DEBUG); con = requestUrl.openConnection(); if (sessionCookie != null) { con.setRequestProperty("Cookie", sessionCookie); } in = con.getInputStream(); try { done = parseResult(in, test); } catch (MojoExecutionException me) { throw me; } catch (Throwable thr) { log.debug(thr); throw new MojoExecutionException(thr.getMessage()); } finally { try { in.close(); } catch (IOException e) { } ; } } } catch (Exception e) { log.error("Failed to execute test: " + e.getMessage()); throw new Exception(e); } }
From source file:org.jvnet.hyperjaxb3.maven2.Hyperjaxb3Mojo.java
License:Apache License
/** * Sets up the verbose and debug mode depending on mvn logging level, and * sets up hyperjaxb logging.//from w ww . j ava2s. c o m */ protected void setupLogging() { super.setupLogging(); final Logger rootLogger = LogManager.getRootLogger(); rootLogger.addAppender(new NullAppender()); final Logger logger = LogManager.getLogger("org.jvnet.hyperjaxb3"); final Log log = getLog(); logger.addAppender(new Appender(getLog(), new PatternLayout("%m%n %c%n"))); if (this.getDebug()) { log.debug("Logger level set to [debug]."); logger.setLevel(Level.DEBUG); } else if (this.getVerbose()) logger.setLevel(Level.INFO); else if (log.isWarnEnabled()) logger.setLevel(Level.WARN); else logger.setLevel(Level.ERROR); }
From source file:org.kaazing.k3po.maven.plugin.internal.StartMojo.java
License:Open Source License
@Override protected void executeImpl() throws MojoExecutionException { try {//from w w w.ja v a2 s . com 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.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 v a 2s. co m*/ */ 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()); try {//from w w w .ja v a 2 s . c om 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.ListDependencies.java
License:Apache License
public void execute() throws MojoExecutionException { Log log = getLog(); try {/* w w w . ja v a 2s . c o m*/ Model model = project.getModel(); if (!outputFile.getParentFile().exists()) { outputFile.getParentFile().mkdirs(); } if (outputFile.exists()) { outputFile.delete(); } log.info("Writing to: " + outputFile); FileOutputStream fos = new FileOutputStream(outputFile); PrintWriter pw = new PrintWriter(fos); pw.println("# Main Jar: "); pw.println("# GroupId | ArtifactId | Version | Name"); pw.print(model.getGroupId() + separator + model.getArtifactId() + separator + model.getVersion() + separator); pw.println(model.getArtifactId() + "-" + model.getVersion() + "." + model.getPackaging()); pw.println("\n\n# Dependencies: "); pw.println("# GroupId | ArtifactId | Version | Classifier | Type | Scope | Name"); try { org.apache.maven.shared.dependency.graph.DependencyNode root = dependencyGraphBuilder .buildDependencyGraph(project, null); // StringWriter writer = new StringWriter(); // // SerializingDependencyNodeVisitor visitor = new SerializingDependencyNodeVisitor(writer); // root.accept(visitor); // // log.info(writer.toString()); DependencyVisitor visitor = new DependencyVisitor(); root.accept(visitor); for (Artifact artifact : visitor.getArtifacts()) { { log.debug(artifact.getGroupId() + separator + artifact.getArtifactId() + separator + artifact.getVersion() + separator + (artifact.getClassifier() != null ? artifact.getClassifier() : "") + separator + artifact.getType() + separator + artifact.getScope() + separator + makeFile(artifact)); pw.println(artifact.getGroupId() + separator + artifact.getArtifactId() + separator + artifact.getVersion() + separator + (artifact.getClassifier() != null ? artifact.getClassifier() : "") + separator + artifact.getType() + separator + artifact.getScope() + separator + makeFile(artifact)); } } } catch (DependencyGraphBuilderException e) { e.printStackTrace(); } // Map<String, Artifact> artifacts = new TreeMap<>(); // Map<String, String> scopes = new HashMap<>(); // // for (org.apache.maven.model.Dependency dep : model.getDependencies()) // { // //Artifact root = new DefaultArtifact(model.getGroupId(), model.getArtifactId(), model.getPackaging(), model.getVersion()); // Artifact root = // new DefaultArtifact(dep.getGroupId(), dep.getArtifactId(), dep.getType(), dep.getVersion()); // // artifacts.put(makeName(root), root); // scopes.put(makeName(root), dep.getScope()); // // for (String scope : new String[]{"compile", "runtime"}) // { // try // { // Dependency dependency = new Dependency(root, scope); // CollectRequest collectRequest = new CollectRequest(); // collectRequest.setRoot(dependency); // // // this will collect the transitive dependencies of an artifact and build a dependency graph // DependencyNode node = repoSystem.collectDependencies(repoSession, collectRequest).getRoot(); // DependencyRequest dependencyRequest = new DependencyRequest(); // // dependencyRequest.setRoot(node); // // // this will collect and resolve the transitive dependencies of an artifact // DependencyResult depRes = repoSystem.resolveDependencies(repoSession, dependencyRequest); // // List<ArtifactResult> results = depRes.getArtifactResults(); // // for (ArtifactResult result : results) // { // Artifact artifact = result.getArtifact(); // // ArtifactRequest artifactRequest = new ArtifactRequest(); // artifactRequest.setArtifact(artifact); // // try // { // ArtifactResult ar = repoSystem.resolveArtifact(repoSession, artifactRequest); // // Artifact a = ar.getArtifact(); // log.info("###" + a.toString()); // } // catch (ArtifactResolutionException e) // { // e.printStackTrace(); // } // // artifacts.put(makeName(artifact), artifact); // scopes.put(makeName(artifact), scope); // // if (artifact.getGroupId().equals("org.apache.avro")) // { // log.info("***" + artifact.getGroupId() + separator + // artifact.getArtifactId() + separator + // artifact.getVersion() + separator + // (artifact.getClassifier() != null ? artifact.getClassifier() : "") + separator + // artifact.getExtension() + separator + // scopes.get(makeName(artifact)) + separator + // makeFile(artifact) + " *** " + makeName(root)); // // } // } // } // catch (DependencyCollectionException | DependencyResolutionException e) // { // // no op // } // } // } // // for (Artifact artifact : artifacts.values()) // { // { // log.debug(artifact.getGroupId() + separator + // artifact.getArtifactId() + separator + // artifact.getVersion() + separator + // (artifact.getClassifier() != null ? artifact.getClassifier() : "") + separator + // artifact.getExtension() + separator + // scopes.get(makeName(artifact)) + separator + // makeFile(artifact)); // // pw.println(artifact.getGroupId() + separator + // artifact.getArtifactId() + separator + // artifact.getVersion() + separator + // (artifact.getClassifier() != null ? artifact.getClassifier() : "") + separator + // artifact.getExtension() + separator + // scopes.get(makeName(artifact)) + separator + // makeFile(artifact)); // } // } // String[] scopes = new String[]{MavenClasspath.COMPILE_SCOPE, MavenClasspath.RUNTIME_SCOPE}; //DefaultDependencyGraphBuilder builder = new DefaultDependencyGraphBuilder(); //dumpTree(node); // builder.enableLogging(new ConsoleLogger(ConsoleLogger.LEVEL_DEBUG, "DefaultDependencyGraphBuilder" )); // // log.info(builder.toString()); // log.info(project.getId()); // // // DependencyNode node = builder.buildDependencyGraph(project, null); // // MavenClasspath mcp = new MavenClasspath(builder, mavenSession, Arrays.asList(scopes)); // for (File jar: mcp) // { // log.info(jar.getCanonicalPath()); // } // // Classpath jars = new Classpath( // project, // session.getLocalRepository().getBasedir(), Arrays.asList(scopes) // ); // // for (File jar: jars) // { // log.info(jar.getCanonicalPath()); // } // Aether aether = new Aether(project, session.getLocalRepository().getBasedir()); // for (Dependency dep : model.getDependencies()) // { // Artifact root = new DefaultArtifact(dep.getGroupId(), dep.getArtifactId(), dep.getType(), // dep.getVersion()); // String rootName = dep.getArtifactId() + "-" + dep.getVersion() + "." + dep.getType(); // for (String scope : new String[]{"compile", "runtime"}) // { // for (Artifact artifact : aether.resolve(root, scope)) // { // // if (!artifact.getFile().getName().equals(rootName)) // { // log.info(artifact.getGroupId() + separator + // artifact.getArtifactId() + separator + // artifact.getVersion() + separator + // (artifact.getClassifier() != null ? artifact.getClassifier() : "") + separator + // artifact.getExtension() + separator + // scope + separator + // artifact.getFile().getName()); // // pw.println(artifact.getGroupId() + separator + // artifact.getArtifactId() + separator + // artifact.getVersion() + separator + // (artifact.getClassifier() != null ? artifact.getClassifier() : "") + separator + // artifact.getExtension() + separator + // scope + separator + // artifact.getFile().getName()); // } // } // } // // } // Artifact root = new DefaultArtifact(model.getGroupId(), model.getArtifactId(), model.getPackaging(), model.getVersion()); // String rootName = model.getArtifactId() + "-" + model.getVersion() + "." + model.getPackaging(); // // // log.info("***" + session.getLocalRepository().getBasedir()); // Aether aether = new Aether(project, session.getLocalRepository().getBasedir()); // for (String scope : new String[]{"compile", "runtime"}) // { // for (Artifact artifact : aether.resolve(root, scope)) // { // if (!artifact.getFile().getName().equals(rootName)) // { //// log.info(artifact.getGroupId() + separator + //// artifact.getArtifactId() + separator + //// artifact.getVersion() + separator + //// (artifact.getClassifier() != null ? artifact.getClassifier() : "") + separator + //// artifact.getExtension() + separator + //// scope + separator + //// artifact.getFile().getName()); // // pw.println(artifact.getGroupId() + separator + // artifact.getArtifactId() + separator + // artifact.getVersion() + separator + // (artifact.getClassifier() != null ? artifact.getClassifier() : "") + separator + // artifact.getExtension() + separator + // scope + separator + // artifact.getFile().getName()); // } // } // } pw.close(); fos.close(); } catch (IOException e) { e.printStackTrace(); throw new MojoExecutionException(e, "IOException", "IOException"); } }
From source file:org.mule.devkit.maven.AbstractGitHubMojo.java
License:Open Source License
/** * Log given message at debug level/* w w w . j a v a2 s . c o m*/ * * @param message */ protected void debug(String message) { Log log = getLog(); if (log != null) { log.debug(message); } }
From source file:org.mule.tooling.tools.CheckerMojo.java
License:Apache License
@Override public void execute() throws MojoExecutionException { try {/* w w w . j av a 2 s. com*/ Log log = getLog(); switch (packaging) { case "eclipse-plugin": log.debug("Checking for jars SNAPSHOT in the plugin:" + pluginBuildDirectory); CheckerResults results = JarFinder.checkJarSnapshots(pluginDirectory, new JarSnapshotFilter(), log, ignoreJarList); results.logResults(log); if (results.hasSnapshots()) { String message = "There are snapshot jars in this plugin!."; throw new MojoExecutionException(message); } else log.debug("There is not any jar SNAPSHOT in the plugin:" + pluginBuildDirectory); break; case "eclipse-repository": CheckerResults resultsBuilt = JarFinder.checkJarSnapshotsBuilt( pluginBuildDirectory + "/target/repository/plugins", new JarFilter(), log, ignoreJarList); resultsBuilt.logTotalResults(log); if (resultsBuilt.hasResults()) { String message = "There are snapshot jars in the built project!."; throw new MojoExecutionException(message); } break; default: log.info("This pom does not have to be tested"); break; } } catch (IOException e) { throw new MojoExecutionException("Error processing plugin directory ", e); } }
From source file:org.mule.tools.apikit.input.MuleConfigParser.java
License:Open Source License
public MuleConfigParser(Log log, Set<File> yamlPaths, Map<File, InputStream> streams, APIFactory apiFactory) { this.apiFactory = apiFactory; for (Entry<File, InputStream> fileStreamEntry : streams.entrySet()) { InputStream stream = fileStreamEntry.getValue(); File file = fileStreamEntry.getKey(); try {/* w ww.ja va 2 s . c o m*/ parseMuleConfigFile(file, stream, yamlPaths); stream.close(); } catch (Exception e) { log.error("Error parsing Mule xml config file: [" + file + "]. Reason: " + e.getMessage()); log.debug(e); } } }