List of usage examples for org.apache.maven.plugin.logging Log info
void info(Throwable error);
From source file:org.buildforce.tomcat.util.FileSystemUtils.java
License:Apache License
/** * Deletes the specified file set. If the base directory of the file set is relative, it will be resolved against * the base directory of the current project. * * @param fileset The file set to delete, must not be <code>null</code>. * @throws MojoExecutionException When the file set failed to get deleted. *//* ww w. j av a2 s .c o m*/ public static void removeFileSet(org.apache.maven.shared.model.fileset.FileSet fileset, Log log) throws MojoExecutionException { try { File dir = new File(fileset.getDirectory()).getAbsoluteFile(); if (!dir.exists()) { log.debug("Skipping non-existing directory: " + dir); return; } if (!dir.isDirectory()) { throw new MojoExecutionException(dir + " is not a directory."); } log.info("Deleting " + fileset.getDirectory()); FileSetManager fileSetManager = new FileSetManager(log, true); fileSetManager.delete(fileset); } catch (IOException e) { throw new MojoExecutionException( "Failed to delete directory: " + fileset.getDirectory() + ". Reason: " + e.getMessage(), e); } catch (IllegalStateException e) { // TODO: IOException from plexus-utils should be acceptable here throw new MojoExecutionException( "Failed to delete directory: " + fileset.getDirectory() + ". Reason: " + e.getMessage(), e); } }
From source file:org.bytedeco.javacpp.tools.BuildMojo.java
License:Apache License
@Override public void execute() throws MojoExecutionException { final Log log = getLog(); try {/*w ww . ja v a 2 s. c o m*/ if (log.isDebugEnabled()) { log.debug("classPath: " + classPath); log.debug("classPaths: " + Arrays.deepToString(classPaths)); log.debug("includePath: " + includePath); log.debug("includePaths: " + Arrays.deepToString(includePaths)); log.debug("linkPath: " + linkPath); log.debug("linkPaths: " + Arrays.deepToString(linkPaths)); log.debug("preloadPath: " + preloadPath); log.debug("preloadPaths: " + Arrays.deepToString(preloadPaths)); log.debug("outputDirectory: " + outputDirectory); log.debug("outputName: " + outputName); log.debug("compile: " + compile); log.debug("deleteJniFiles: " + deleteJniFiles); log.debug("header: " + header); log.debug("copyLibs: " + copyLibs); log.debug("jarPrefix: " + jarPrefix); log.debug("properties: " + properties); log.debug("propertyFile: " + propertyFile); log.debug("propertyKeysAndValues: " + propertyKeysAndValues); log.debug("classOrPackageName: " + classOrPackageName); log.debug("classOrPackageNames: " + Arrays.deepToString(classOrPackageNames)); log.debug("environmentVariables: " + environmentVariables); log.debug("compilerOptions: " + Arrays.deepToString(compilerOptions)); log.debug("skip: " + skip); } if (skip) { log.info("Skipping execution of JavaCPP Builder"); return; } classPaths = merge(classPaths, classPath); classOrPackageNames = merge(classOrPackageNames, classOrPackageName); Logger logger = new Logger() { @Override public void debug(String s) { log.debug(s); } @Override public void info(String s) { log.info(s); } @Override public void warn(String s) { log.warn(s); } @Override public void error(String s) { log.error(s); } }; Builder builder = new Builder(logger).classPaths(classPaths).outputDirectory(outputDirectory) .outputName(outputName).compile(compile).deleteJniFiles(deleteJniFiles).header(header) .copyLibs(copyLibs).jarPrefix(jarPrefix).properties(properties).propertyFile(propertyFile) .properties(propertyKeysAndValues).classesOrPackages(classOrPackageNames) .environmentVariables(environmentVariables).compilerOptions(compilerOptions); Properties properties = builder.properties; log.info("Detected platform \"" + Loader.getPlatform() + "\""); log.info("Building for platform \"" + properties.get("platform") + "\""); String separator = properties.getProperty("platform.path.separator"); for (String s : merge(includePaths, includePath)) { String v = properties.getProperty("platform.includepath", ""); properties.setProperty("platform.includepath", v.length() == 0 || v.endsWith(separator) ? v + s : v + separator + s); } for (String s : merge(linkPaths, linkPath)) { String v = properties.getProperty("platform.linkpath", ""); properties.setProperty("platform.linkpath", v.length() == 0 || v.endsWith(separator) ? v + s : v + separator + s); } for (String s : merge(preloadPaths, preloadPath)) { String v = properties.getProperty("platform.preloadpath", ""); properties.setProperty("platform.preloadpath", v.length() == 0 || v.endsWith(separator) ? v + s : v + separator + s); } Properties projectProperties = project.getProperties(); for (String key : properties.stringPropertyNames()) { projectProperties.setProperty("javacpp." + key, properties.getProperty(key)); } File[] outputFiles = builder.build(); if (log.isDebugEnabled()) { log.debug("outputFiles: " + Arrays.deepToString(outputFiles)); } } catch (IOException | ClassNotFoundException | NoClassDefFoundError | InterruptedException | ParserException e) { log.error("Failed to execute JavaCPP Builder: " + e.getMessage()); throw new MojoExecutionException("Failed to execute JavaCPP Builder", e); } }
From source file:org.cakeframework.website.Load.java
License:Open Source License
public static void forVersion(Log log, File baseDir, File target) throws IOException { Model model = loadModel(new File(baseDir, "src/site.yaml")); // for (Model m : allModels(VERSIONS)) { // for (Release r : m.getReleases()) { // // only add previous versions???? // model.addAllRelease(r); // }/*from ww w . ja va 2 s . c om*/ // } File f = new File(baseDir, "src/vm"); try (DirectoryStream<Path> stream = Files.newDirectoryStream(f.toPath(), "*.vm")) { for (Path p : stream) { Properties props = new Properties(); props.setProperty("resource.loader", "file, class"); props.setProperty("file.resource.loader.path", f.toString() + ", " + new File(baseDir, "src/configuration")); props.setProperty("class.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); props.setProperty("runtime.log.logsystem.class", "org.apache.velocity.runtime.log.NullLogSystem"); Velocity.init(props); VelocityContext context = new VelocityContext(); String file = p.getFileName().toString().replace(".vm", ".html"); File outputFile = new File(target, file); try (Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outputFile)))) { context.put("body", p.getFileName()); context.put("model", model); context.put("version", Version.parseVersion("0.8")); Velocity.getTemplate("site.vm").merge(context, writer); } log.info("Wrote " + outputFile); } } }
From source file:org.callistasoftware.maven.plugins.propertyscanner.MyMojo.java
License:Apache License
private Properties loadProperties(Log logger) throws MojoExecutionException { FilenameFilter filter = new SuffixFileFilter(".properties"); Properties allProperties = new Properties(); for (File propertiesDirectory : propertiesDirectories) { if (!propertiesDirectory.exists()) { throw new MojoExecutionException("Could not find properties directory: " + propertiesDirectory); }/*from w ww .ja v a 2 s .c om*/ File[] propertiesFiles = propertiesDirectory.listFiles(filter); for (File propertiesFile : propertiesFiles) { if (!propertiesFile.exists()) { throw new MojoExecutionException("Could not find properties file: " + propertiesFile); } //loading properties Properties properties = new Properties(); FileReader r = null; try { r = new FileReader(propertiesFile); properties.load(r); } catch (IOException e) { throw new MojoExecutionException( "Error loading properties from translation file: " + propertiesFile, e); } finally { try { r.close(); } catch (Exception e) { //nothing } } logger.debug("Loaded properties, read " + properties.size() + " entries"); allProperties.putAll(properties); } } logger.info("Total properties loaded: " + allProperties.size()); return allProperties; }
From source file:org.callistasoftware.maven.plugins.propertyscanner.MyMojo.java
License:Apache License
private Set<String> scanJspFiles(Log logger) throws MojoExecutionException { logger.info("JSP source directory is " + scriptSourceDirectory); MyDirectoryWalker jspDirectoryWalker = new MyDirectoryWalker(FileFilterUtils.suffixFileFilter(".jsp")); List<File> allJspFiles; try {/* w w w . j a v a2 s .com*/ allJspFiles = jspDirectoryWalker.getAllFiles(scriptSourceDirectory); } catch (IOException e) { throw new MojoExecutionException("Unable to walk through jsp directories: ", e); } FileParser fileParser = new FileParser(scriptMatchPattern, logger); for (File jspFile : allJspFiles.toArray(new File[allJspFiles.size()])) { fileParser.parseFile(jspFile); } logger.info("the keys found in jsp are: " + fileParser.getKeys()); return fileParser.getKeys(); }
From source file:org.callistasoftware.maven.plugins.propertyscanner.MyMojo.java
License:Apache License
private Set<String> scanJavaFiles(Log logger) throws MojoExecutionException { logger.info("Java source directory is " + javaSourceDirectory); MyDirectoryWalker javaDirectoryWalker = new MyDirectoryWalker(FileFilterUtils.suffixFileFilter(".java")); List<File> allJavaFiles; try {//from www. j a va2 s .c o m allJavaFiles = javaDirectoryWalker.getAllFiles(javaSourceDirectory); } catch (IOException e) { throw new MojoExecutionException("Unable to walk through java directories: ", e); } FileParser fileParser = new FileParser(javaMatchPattern, logger); for (File javaFile : allJavaFiles.toArray(new File[allJavaFiles.size()])) { fileParser.parseFile(javaFile); } logger.info("the keys found in java are: " + fileParser.getKeys()); return fileParser.getKeys(); }
From source file:org.codehaus.mojo.apt.LogUtils.java
License:Open Source License
public static void log(Log log, int level, CharSequence message) { if (level == LEVEL_DEBUG) { log.debug(message);//w w w . j av a 2 s . c o m } else if (level == LEVEL_INFO) { log.info(message); } else if (level == LEVEL_WARN) { log.warn(message); } else if (level == LEVEL_ERROR) { log.error(message); } else { throw new IllegalArgumentException("Unknown log level: " + level); } }
From source file:org.codehaus.mojo.cassandra.Utils.java
License:Apache License
/** * Stops the Cassandra service.//from www.j a v a2 s . co m * * @param rpcAddress The rpcAddress to connect to in order to see if Cassandra has stopped. * @param rpcPort The rpcPort to connect on to check if Cassandra has stopped. * @param stopPort The port to stop on. * @param stopKey The key to stop with, * @param log The log to write to. */ static void stopCassandraServer(String rpcAddress, int rpcPort, String stopAddress, int stopPort, String stopKey, Log log) { try { Socket s = new Socket(InetAddress.getByName(stopAddress), stopPort); s.setSoLinger(false, 0); OutputStream out = s.getOutputStream(); out.write((stopKey + "\r\nstop\r\n").getBytes()); out.flush(); s.close(); } catch (ConnectException e) { log.info("Cassandra not running!"); return; } catch (Exception e) { log.error(e); return; } log.info("Waiting for Cassandra to stop..."); long maxWaiting = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(30); boolean stopped = false; while (!stopped && System.currentTimeMillis() < maxWaiting) { TTransport tr = new TFramedTransport(new TSocket(rpcAddress, rpcPort)); try { TProtocol proto = new TBinaryProtocol(tr); Cassandra.Client client = new Cassandra.Client(proto); try { tr.open(); } catch (TTransportException e) { if (e.getCause() instanceof ConnectException) { stopped = true; continue; } log.debug(e.getLocalizedMessage(), e); try { Thread.sleep(500); } catch (InterruptedException e1) { // ignore } } } finally { if (tr.isOpen()) { tr.close(); } } } if (stopped) { log.info("Cassandra has stopped."); } else { log.warn("Gave up waiting for Cassandra to stop."); } }
From source file:org.codehaus.mojo.cassandra.Utils.java
License:Apache License
/** * Waits until the Cassandra server at the specified RPC address and port has started accepting connections. * * @param rpcAddress The RPC address to connect to. * @param rpcPort The RPC port to connect on. * @param startWaitSeconds The maximum number of seconds to wait. * @param log the {@link Log} to log to. * @return {@code true} if Cassandra is started. * @throws MojoExecutionException if something went wrong. */// w w w . j a v a 2 s . c o m static boolean waitUntilStarted(String rpcAddress, int rpcPort, int startWaitSeconds, Log log) throws MojoExecutionException { long maxWaiting = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(startWaitSeconds); while (startWaitSeconds == 0 || System.currentTimeMillis() < maxWaiting) { TTransport tr = new TFramedTransport(new TSocket(rpcAddress, rpcPort)); try { TProtocol proto = new TBinaryProtocol(tr); Cassandra.Client client = new Cassandra.Client(proto); try { tr.open(); } catch (TTransportException e) { if (!(e.getCause() instanceof ConnectException)) { log.debug(e.getLocalizedMessage(), e); } try { Thread.sleep(500); } catch (InterruptedException e1) { // ignore } continue; } try { log.info("Cassandra cluster \"" + client.describe_cluster_name() + "\" started."); return true; } catch (TException e) { throw new MojoExecutionException(e.getLocalizedMessage(), e); } } finally { if (tr.isOpen()) { tr.close(); } } } return false; }
From source file:org.codehaus.mojo.fitnesse.runner.ClassPathBuilder.java
License:Open Source License
public String getPath(List pSubstitutions, Log pLog) throws MojoExecutionException { String tOriginalPath;//from w w w .j a va 2 s . c o m String tUrl = "GET /" + mPage + "?responder=fitClient&includePaths=yes HTTP/1.1\r\n\r\n"; pLog.debug("Use URL for classPath download [" + tUrl + "]"); try { StreamReader tSocketReader = establishConnection(tUrl); int tNbBytes = FitProtocol.readSize(tSocketReader); if (tNbBytes != 0) { throw new MojoExecutionException("Unable to connect to server."); } tNbBytes = FitProtocol.readSize(tSocketReader); tOriginalPath = FitProtocol.readDocument(tSocketReader, tNbBytes); pLog.debug("Download classpath is [" + tOriginalPath + "]"); String tPath = transformPath(tOriginalPath, pSubstitutions); pLog.info("Use path [" + tPath + "]"); return tPath; } catch (Exception e) { throw new MojoExecutionException("Unable to download path from FitNesse Server", e); } }