List of usage examples for org.apache.maven.plugin.logging Log info
void info(Throwable error);
From source file:io.fabric8.vertx.maven.plugin.functions.Executor.java
License:Apache License
default void redirectOutput(Process process, Log logger) { StreamToLogConsumer logConsumer = line -> logger.info(line); StreamPumper outPumper = new StreamPumper(process.getInputStream(), logConsumer); StreamPumper errPumper = new StreamPumper(process.getErrorStream(), logConsumer); outPumper.setPriority(Thread.MIN_PRIORITY + 1); errPumper.setPriority(Thread.MIN_PRIORITY + 1); outPumper.start();//from www . j a va 2s .com errPumper.start(); }
From source file:io.fabric8.vertx.maven.plugin.utils.SetupTemplateUtils.java
License:Apache License
public static void createVerticle(MavenProject project, String verticle, Log log) throws MojoExecutionException { if (Strings.isNullOrEmpty(verticle)) { return;/*from w w w. j av a2s . c o m*/ } log.info("Creating verticle " + verticle); File root = new File(project.getBasedir(), "src/main/java"); String packageName = null; String className; if (verticle.endsWith(".java")) { verticle = verticle.substring(0, verticle.length() - ".java".length()); } if (verticle.contains(".")) { int idx = verticle.lastIndexOf('.'); packageName = verticle.substring(0, idx); className = verticle.substring(idx + 1); } else { className = verticle; } if (packageName != null) { File packageDir = new File(root, packageName.replace('.', '/')); if (!packageDir.exists()) { packageDir.mkdirs(); log.info("Creating directory " + packageDir.getAbsolutePath()); } root = packageDir; } File classFile = new File(root, className + ".java"); Map<String, String> context = new HashMap<>(); context.put("className", className); if (packageName != null) { context.put("packageName", packageName); } try { Template temp = cfg.getTemplate("templates/verticle-template.ftl"); Writer out = new FileWriter(classFile); temp.process(context, out); } catch (Exception e) { throw new MojoExecutionException("Unable to generate verticle", e); } }
From source file:io.fabric8.vertx.maven.plugin.utils.WatcherUtils.java
License:Apache License
/** * @param threadGroup// w ww . j ava 2s.com * @param project * @param mavenSession * @param buildPluginManager * @param redeployPatterns * @param logger * @param classLoader * @return * @throws MojoExecutionException * @throws MojoFailureException */ public static Thread spinWatcher(ThreadGroup threadGroup, MavenProject project, MavenSession mavenSession, BuildPluginManager buildPluginManager, List<String> redeployPatterns, Log logger, ClassLoader classLoader) throws MojoExecutionException, MojoFailureException { logger.info("Watching for incremental builds"); Thread redeployWatcher = null; // try { // // redeployWatcher = new Thread(threadGroup, new IncrementalBuilder(project, mavenSession, // buildPluginManager, redeployPatterns, logger)); // // } catch (IOException e) { // throw new MojoExecutionException("Error starting watcher :", e); // } // // redeployWatcher.setContextClassLoader(classLoader); // redeployWatcher.start(); return redeployWatcher; }
From source file:io.fabric8.vertx.maven.plugin.utils.WebJars.java
License:Apache License
/** * Checks whether the given file is a WebJar or not (http://www.webjars.org/documentation). * The check is based on the presence of {@literal META-INF/resources/webjars/} directory in the jar file. * * @param file the file.//from w w w . j a va 2 s .c om * @return {@literal true} if it's a bundle, {@literal false} otherwise. */ public static boolean isWebJar(Log log, File file) { if (file == null) { return false; } Set<String> found = new LinkedHashSet<>(); if (file.isFile() && file.getName().endsWith(".jar")) { JarFile jar = null; try { jar = new JarFile(file); // Fast return if the base structure is not there if (jar.getEntry(WEBJAR_LOCATION) == null) { return false; } Enumeration<JarEntry> entries = jar.entries(); while (entries.hasMoreElements()) { JarEntry entry = entries.nextElement(); Matcher matcher = WEBJAR_REGEX.matcher(entry.getName()); if (matcher.matches()) { found.add(matcher.group(1) + "-" + matcher.group(2)); } } } catch (IOException e) { log.error("Cannot check if the file " + file.getName() + " is a webjar, cannot open it", e); return false; } finally { final JarFile finalJar = jar; IOUtils.closeQuietly(() -> { if (finalJar != null) { finalJar.close(); } }); } for (String lib : found) { log.info("Web Library found in " + file.getName() + " : " + lib); } return !found.isEmpty(); } return false; }
From source file:io.joynr.generator.GeneratorTask.java
License:Apache License
public void printHelp(Log log) { IGenerator generator = executor.getGenerator(); if (generator instanceof IJoynrGenerator) { IJoynrGenerator joynrGenerator = (IJoynrGenerator) generator; Set<String> parameters = joynrGenerator.supportedParameters(); StringBuffer sb = new StringBuffer(); sb.append("Supported configuration parameters by the generator: "); if (parameters != null && parameters.size() > 0) { for (String parameter : parameters) { sb.append(parameter + ","); }/* w w w . j a va2 s . c om*/ sb.deleteCharAt(sb.length() - 1); } else { sb.append("none"); } log.info(sb.toString()); } else { log.info("no additional information available for the provider generator"); } }
From source file:io.reactiverse.vertx.maven.plugin.utils.WebJars.java
License:Apache License
/** * Checks whether the given file is a WebJar or not (http://www.webjars.org/documentation). * The check is based on the presence of {@literal META-INF/resources/webjars/} directory in the jar file. * * @param file the file./*w ww .j a v a 2 s. c o m*/ * @return {@literal true} if it's a bundle, {@literal false} otherwise. */ public static boolean isWebJar(Log log, File file) { if (file == null) { return false; } Set<String> found = new LinkedHashSet<>(); if (file.isFile() && file.getName().endsWith(".jar")) { try (JarFile jar = new JarFile(file)) { // Fast return if the base structure is not there if (jar.getEntry(WEBJAR_LOCATION) == null) { return false; } Enumeration<JarEntry> entries = jar.entries(); while (entries.hasMoreElements()) { JarEntry entry = entries.nextElement(); Matcher matcher = WEBJAR_REGEX.matcher(entry.getName()); if (matcher.matches()) { found.add(matcher.group(1) + "-" + matcher.group(2)); } } } catch (IOException e) { log.error("Cannot check if the file " + file.getName() + " is a webjar, cannot open it", e); return false; } for (String lib : found) { log.info("Web Library found in " + file.getName() + " : " + lib); } return !found.isEmpty(); } return false; }
From source file:io.sarl.maven.compiler.CompileMojo.java
License:Apache License
private void compileSARL() throws MojoExecutionException, MojoFailureException { final Log log = getLog(); File outputDirectory = getOutput(); log.info(Locale.getString(CompileMojo.class, "COMPILING_SARL")); //$NON-NLS-1$ if (log.isDebugEnabled()) { final StringBuilder properties = new StringBuilder(); buildPropertyString(properties); log.debug(properties.toString()); }//from www . j a v a2s . co m // If output is not explicitly set try to read SARL prefs from eclipse .settings folder if (getDefaultOutput().equals(getOutput())) { final String settingsValue = readSarlEclipseSetting(getProject().getBuild().getSourceDirectory()); if (settingsValue != null && !settingsValue.isEmpty()) { outputDirectory = new File(settingsValue); getLog().info(Locale.getString(CompileMojo.class, "OUTPUT_DIR_UPDATE", outputDirectory)); //$NON-NLS-1$ } } final MavenProject project = getProject(); final List<File> compileSourceRoots = new ArrayList<>(); for (final String filename : project.getCompileSourceRoots()) { final File file = new File(filename); if (!file.equals(outputDirectory)) { compileSourceRoots.add(file); } } final List<File> classPath = getClassPath(); project.addCompileSourceRoot(outputDirectory.getAbsolutePath()); compile(classPath, compileSourceRoots, outputDirectory); }
From source file:io.siddhi.doc.gen.core.utils.DocumentationUtils.java
License:Open Source License
/** * Executing a command/*from ww w . j ava2 s .c om*/ * * @param command The command to be executed * @param logger The maven plugin logger * @return The output lines from executing the command * @throws Throwable if any error occurs during the execution of the command */ private static List<String> getCommandOutput(String[] command, Log logger) throws Throwable { logger.info("Executing: " + String.join(" ", command)); Process process = Runtime.getRuntime().exec(command); List<String> executionOutputLines = new ArrayList<>(); // Logging the output of the command execution InputStream[] inputStreams = new InputStream[] { process.getInputStream(), process.getErrorStream() }; BufferedReader bufferedReader = null; try { for (InputStream inputStream : inputStreams) { bufferedReader = new BufferedReader(new InputStreamReader(inputStream, Constants.DEFAULT_CHARSET)); String commandOutput; while (true) { commandOutput = bufferedReader.readLine(); if (commandOutput == null) { break; } executionOutputLines.add(commandOutput); } } process.waitFor(); } finally { IOUtils.closeQuietly(bufferedReader); } return executionOutputLines; }
From source file:jatoo.maven.plugin.set_license.SetLicenseFileMojo.java
License:Apache License
@Override public final void execute() throws MojoExecutionException, MojoFailureException { final Log log = getLog(); final URL licenseResource; if (license == null) { if (licenseFile == null) { throw new MojoExecutionException("both parameters 'license' and 'licenseFile' are missing"); }//from w w w .java 2 s . co m try { licenseResource = licenseFile.toURI().toURL(); } catch (MalformedURLException e) { throw new MojoExecutionException("error getting license file (" + licenseFile + ")", e); } } else { try { licenseResource = getClass().getResource("licenses/" + license + "/LICENSE").toURI().toURL(); } catch (MalformedURLException | URISyntaxException e) { throw new MojoExecutionException("error getting license (" + license + ")", e); } } log.info("setting license file:"); log.info("from: " + licenseResource); log.info("to: " + new File(project.getBasedir(), "LICENSE").getAbsolutePath()); try { FileUtils.copyURLToFile(licenseResource, new File(project.getBasedir(), "LICENSE")); } catch (IOException e) { throw new MojoExecutionException("error copying license file", e); } }
From source file:jatoo.maven.plugin.set_license.SetLicenseHeaderMojo.java
License:Apache License
@Override public final void execute() throws MojoExecutionException, MojoFailureException { final Log log = getLog(); final String licenseHeaderText; if (license == null) { if (licenseHeader == null) { throw new MojoExecutionException("both parameters 'license' and 'licenseHeader' are missing"); }/* w ww .ja va2 s . co m*/ try { licenseHeaderText = FileUtils.readFileToString(licenseHeader).trim(); } catch (IOException e) { throw new MojoExecutionException("error reading license header file (" + licenseHeader + ")", e); } } else { if (copyright == null) { throw new MojoExecutionException("the parameter 'copyright' is missing"); } try { licenseHeaderText = IOUtils.toString(getClass().getResource("licenses/" + license + "/HEADER")) .replaceAll("\\$\\{copyright\\}", copyright).trim(); } catch (IOException e) { throw new MojoExecutionException("error reading license (" + license + ") header", e); } } log.info("license header text: " + IOUtils.LINE_SEPARATOR + licenseHeaderText); final DirectoryScanner directoryScanner = new DirectoryScanner(); directoryScanner.setIncludes(includes); directoryScanner.setBasedir(project.getBasedir()); directoryScanner.scan(); log.info("setting license header text on files:"); for (String file : directoryScanner.getIncludedFiles()) { log.info(file); try { String fileContent = FileUtils.readFileToString(new File(project.getBasedir(), file)); int index = fileContent.indexOf("package "); int indexComments = fileContent.indexOf("/**"); if (indexComments >= 0 && indexComments <= index) { index = indexComments; } fileContent = fileContent.substring(index); File targetFolder = new File(project.getBuild().getDirectory()); if (!targetFolder.exists() && !targetFolder.mkdirs()) { throw new MojoExecutionException("error creating target folder"); } FileUtils.write(new File(project.getBasedir(), file), licenseHeaderText + IOUtils.LINE_SEPARATOR + IOUtils.LINE_SEPARATOR + fileContent); } catch (IOException e) { throw new MojoExecutionException("error writing license header in " + file, e); } } }