Example usage for org.apache.maven.plugin.logging Log info

List of usage examples for org.apache.maven.plugin.logging Log info

Introduction

In this page you can find the example usage for org.apache.maven.plugin.logging Log info.

Prototype

void info(Throwable error);

Source Link

Document

Send an exception to the user in the info error level.
The stack trace for this exception will be output when this error level is enabled.

Usage

From source file:com.google.code.rptm.ListPmcMojo.java

License:Apache License

public void execute() throws MojoExecutionException, MojoFailureException {
    String projectId = PmcUtil.getProjectIdFromSiteUrl(projectUrl);
    if (projectId == null) {
        throw new MojoFailureException("Unable to determine ASF project ID from URL " + projectUrl);
    }/*from w w w .j a va2 s .  c om*/

    List<PmcMember> members;
    try {
        members = metadataProvider.getPmcMembers(new ProjectByIdMatcher(projectId));
    } catch (MetadataException ex) {
        throw new MojoExecutionException("Failed to get PMC info: " + ex.getMessage(), ex);
    }

    if (members == null) {
        throw new MojoFailureException("Unable to find project in committee-info.txt");
    } else {
        Log log = getLog();
        log.info("List of PMC members:");
        for (PmcMember member : members) {
            log.info("  " + member.getName() + " <" + member.getAddress() + ">");
        }
    }
}

From source file:com.google.dart.util.UnpackUtil.java

License:Apache License

private static void logUnpack(final File file, final File location, final Log logger) {
    if (!logger.isInfoEnabled()) {
        return;/*from   w ww  .j a va 2 s.com*/
    }

    final StringBuffer msg = new StringBuffer();
    msg.append("Unpacking ");
    msg.append(file);
    msg.append(" to ");
    msg.append(location);

    logger.info(msg.toString());
}

From source file:com.google.dart.util.UnpackUtil.java

License:Apache License

private static void logUnpackDone(final File file, final File location, final Log logger) {
    if (!logger.isInfoEnabled()) {
        return;/*ww  w .j ava2  s.  co m*/
    }

    final StringBuffer msg = new StringBuffer();
    msg.append("Unpacked ");
    msg.append(file);
    msg.append(" to ");
    msg.append(location);

    logger.info(msg.toString());
}

From source file:com.googlecode.ounit.maven.GenerateResultsMojo.java

License:Open Source License

public void execute() throws MojoExecutionException {
    Log log = getLog();

    try {/*w  ww .  j  av a2 s  .co  m*/
        ResultsGenerator gen = new ResultsGenerator(this);

        PrintStream fstream = new PrintStream(createOutputFile("results.html"));
        fstream.println(gen.generateHtmlReport());
        log.info("");
        for (String l : gen.generateTextReport().split("\n")) {
            log.info(l);
        }
        log.info("");

        Properties marks = gen.generateMarks();
        marks.store(new FileOutputStream(createOutputFile("marks.properties")), "");
        log.info("Total Score: " + marks.getProperty("default") + " %");
        log.info("");
    } catch (Exception e) {
        throw new MojoExecutionException("Failed to parse test results", e);
    }
}

From source file:com.googlecode.t7mp.PreConditions.java

License:Apache License

static void checkConfiguredTomcatVersion(Log log, String tomcatVersion) throws MojoExecutionException {
    if (!tomcatVersion.startsWith("7.") && !tomcatVersion.startsWith("6.")) {
        log.info("");
        log.info("");
        log.error("======================= MAVEN-T7-PLUGIN ==================");
        log.error("This plugin supports only Version 7 or 6 of Tomcat. You configured: " + tomcatVersion
                + ". Cancel the Build.");
        log.error("===========================================================");
        log.info("");
        log.info("");
        throw new MojoExecutionException(
                "This plugin supports only Version 7 or 6 of Tomcat. You configured " + tomcatVersion);
    }/*ww w.j ava2s.  c o m*/
}

From source file:com.googlecode.yaxv.mkresources.GenerateMojo.java

License:Apache License

public void execute() throws MojoExecutionException, MojoFailureException {
    Log log = getLog();
    boolean doAddSources = false;
    for (Resource resource : resources) {
        File dir = new File(resource.getDirectory());
        DirectoryScanner scanner = new DirectoryScanner();
        scanner.setBasedir(resource.getDirectory());
        scanner.setIncludes(includes != null ? includes : new String[] { "**/*.properties" });
        scanner.setExcludes(excludes);//from w  ww  .jav a 2 s  .co  m
        scanner.scan();
        String[] includedFiles = scanner.getIncludedFiles();
        if (includedFiles.length > 0) {
            URL url;
            try {
                url = dir.toURI().toURL();
            } catch (MalformedURLException ex) {
                throw new MojoExecutionException("Unexpected exception", ex);
            }
            ClassLoader loader = new URLClassLoader(new URL[] { url });
            for (String file : includedFiles) {
                if (file.endsWith(".properties")) {
                    String[] baseNameComponents = file.substring(0, file.length() - 11).split("[/\\\\]");
                    String baseName = StringUtils.join(baseNameComponents, ".");
                    log.info("Generating constants for resource bundle " + baseName);
                    ResourceBundle messages = ResourceBundle.getBundle(baseName, Locale.ENGLISH, loader);
                    String className = baseNameComponents[baseNameComponents.length - 1];
                    className = className.substring(0, 1).toUpperCase() + className.substring(1);
                    File outputFile = outputDirectory;
                    StringBuilder packageName = new StringBuilder();
                    for (int i = 0; i < baseNameComponents.length - 1; i++) {
                        if (i > 0) {
                            packageName.append('.');
                        }
                        String component = baseNameComponents[i];
                        packageName.append(component);
                        outputFile = new File(outputFile, component);
                    }
                    outputFile.mkdirs();
                    outputFile = new File(outputFile, className + ".java");
                    try {
                        generate(baseName, messages, outputFile, packageName.toString(), className);
                    } catch (IOException ex) {
                        throw new MojoExecutionException(
                                "Failed to generate " + outputFile + ": " + ex.getMessage(), ex);
                    }
                    doAddSources = true;
                } else {
                    log.warn("Skipping file " + file + ": not a resource bundle");
                }
            }
        }
    }
    if (doAddSources) {
        project.addCompileSourceRoot(outputDirectory.getPath());
    }
}

From source file:com.igormaznitsa.jcp.maven.PreprocessorClearMojo.java

License:Apache License

private void processPredefinedFolders(@Nonnull final Log log) throws MojoFailureException {
    if (this.preprocessedSources != null) {
        final String path = preprocessedSources.getAbsolutePath();
        log.info("Removing preprocessed source folder '" + path + '\'');
        if (this.preprocessedSources.isDirectory()) {
            try {
                FileUtils.deleteDirectory(this.preprocessedSources);
            } catch (IOException ex) {
                throw new MojoFailureException("Can't delete preprocessed source folder", ex);
            }/*from   ww  w.  j a  v a2 s.c  o m*/
        } else {
            log.info("Preprocessed Source folder '" + path + "' doesn't exist");
        }
    }

    if (this.preprocessedTestSources != null) {
        final String path = preprocessedTestSources.getAbsolutePath();
        log.info("Removing preprocessed test source folder '" + path + '\'');
        if (this.preprocessedTestSources.isDirectory()) {
            try {
                FileUtils.deleteDirectory(this.preprocessedTestSources);
            } catch (IOException ex) {
                throw new MojoFailureException("Can't delete preprocessed test source folder", ex);
            }
        } else {
            log.info("Preprocessed Test Source folder '" + path + "' doesn't exist");
        }
    }
}

From source file:com.igormaznitsa.jcp.maven.PreprocessorClearMojo.java

License:Apache License

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    final Log log = getLog();

    log.info("Cleaning has been started");
    if (this.fileSets == null) {
        processPredefinedFolders(log);/*from w ww  .  j  a  va2  s. c om*/
    } else {
        processFileSet(this.fileSets, log);
    }
    log.info("Cleaning has been completed");
}

From source file:com.igormaznitsa.jute.JuteMojo.java

License:Apache License

private static List<String> collectAllPotentialTestClassPaths(final Log log, final boolean verbose,
        final File rootFolder, final String[] includes, final String[] excludes) {
    final List<String> result = new ArrayList<String>();

    final Iterator<File> iterator = FileUtils.iterateFiles(rootFolder, new IOFileFilter() {
        private final AntPathMatcher matcher = new AntPathMatcher();

        @Override/*from w  w w.ja v a 2  s . co  m*/
        public boolean accept(final File file) {
            if (file.isDirectory()) {
                return false;
            }

            final String path = file.getAbsolutePath();
            boolean include = false;

            if (path.endsWith(".class")) {
                if (includes.length != 0) {
                    for (final String patteen : includes) {
                        if (matcher.match(patteen, path)) {
                            include = true;
                            break;
                        }
                    }
                } else {
                    include = true;
                }

                if (include && excludes.length != 0) {
                    for (final String pattern : excludes) {
                        if (matcher.match(pattern, path)) {
                            include = false;
                            break;
                        }
                    }
                }
            }

            if (!include && verbose) {
                log.info("File " + path + " excluded");
            }

            return include;
        }

        @Override
        public boolean accept(final File dir, final String name) {
            final String path = name;
            boolean include = false;
            if (includes.length != 0) {
                for (final String pattern : includes) {
                    if (matcher.match(pattern, path)) {
                        include = true;
                        break;
                    }
                }
            } else {
                include = true;
            }

            if (include && excludes.length != 0) {
                for (final String pattern : excludes) {
                    if (matcher.match(pattern, path)) {
                        include = false;
                        break;
                    }
                }
            }

            if (!include && verbose) {
                log.info("Folder " + name + " excluded");
            }

            return include;
        }
    }, DirectoryFileFilter.DIRECTORY);

    while (iterator.hasNext()) {
        final String detectedFile = iterator.next().getAbsolutePath();
        if (verbose) {
            log.info("Found potential test class : " + detectedFile);
        }
        result.add(detectedFile);
    }

    if (result.isEmpty()) {
        log.warn("No test files found in " + rootFolder.getAbsolutePath());
    }

    return result;
}

From source file:com.igormaznitsa.upom.UPomModel.java

License:Apache License

public String asXML(final Log log, final boolean removeDuplicatedSiblings) throws Exception {
    final MavenXpp3Writer mavenWritter = new MavenXpp3Writer();
    final StringWriter buffer = new StringWriter(16384);
    mavenWritter.write(buffer, this.model);
    String result = buffer.toString();
    if (removeDuplicatedSiblings) {
        if (log != null) {
            log.warn("Activated search and removing of duplicated sibling elements!");
        }//ww w  .  j av a 2  s .co  m
        result = findAndRemoveDuplicatedSiblings(log, result);
    } else if (log != null) {
        log.info("Search and removing of duplicated sibling elements is OFF");
    }
    return result;
}