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:jflex.maven.plugin.unicode.UnicodeVersion.java

License:Open Source License

/**
 * Fetches and parses the data files defined for this Unicode version.
 *
 * @param log Where to put info about which files have been fetched and parsed
 * @throws IOException If there is a problem fetching or parsing any of this version's data files.
 *///w ww  .j a v  a2s  .c  o  m
public void fetchAndParseDataFiles(Log log) throws IOException {
    // Use the enum ordering to process in the correct order
    for (EnumMap.Entry<DataFileType, URL> entry : dataFiles.entrySet()) {
        DataFileType fileType = entry.getKey();
        URL url = entry.getValue();
        log.info("\t\tFetching/parsing: " + url.getPath());
        fileType.scan(url, this);
        log.info("\t\tCompleted: " + url.getPath());
    }
}

From source file:jflex.UnicodeVersion.java

License:Open Source License

/**
 * Fetches and parses the data files defined for this Unicode version.
 * //from ww w  .  j  a  v  a 2s.c o m
 * @param log Where to put info about which files have been fetched and parsed
 * @throws IOException If there is a problem fetching or parsing
 *  any of this version's data files.
 */
public void fetchAndParseDataFiles(Log log) throws IOException {
    // Use the enum ordering to process in the correct order 
    for (EnumMap.Entry<DataFileType, URL> entry : dataFiles.entrySet()) {
        DataFileType fileType = entry.getKey();
        URL url = entry.getValue();
        log.info("\t\tFetching/parsing: " + url.getPath());
        fileType.scan(url, this);
        log.info("\t\tCompleted: " + url.getPath());
    }
}

From source file:jp.uphy.maven.svg.mojo.AbstractRasterizeMojo.java

License:Apache License

@Override
public final void execute() throws MojoExecutionException, MojoFailureException {
    initialize();/*  w  w  w  .j a va2  s  . co  m*/
    final SvgTool svgTool = new SvgTool();
    final Log log = getLog();
    for (final Rasterization rasterization : rasterizations) {
        log.info(MessageFormat.format("Rasterizing[{0}]", rasterization));
        createDirectory("outputDirectory", rasterization.output.getParentFile());
        rasterization.execute(svgTool);
    }
}

From source file:meme.singularsyntax.mojo.JavaflowEnhanceMojo.java

License:Open Source License

private void enhanceClassFiles(String outputDir, File backupDir, List<String> classFileNames)
        throws MojoExecutionException {

    Log log = getLog();
    ResourceTransformer transformer = new AsmClassTransformer();

    for (String classFileName : classFileNames) {
        try {/*w  ww.jav  a  2 s . c  om*/
            File source = new File(outputDir, classFileName);
            File destination = new File(String.format(CLASSFILE_REWRITE_TEMPLATE, source.getAbsolutePath()));
            File backupClassFile = new File(backupDir, classFileName);

            if (backupClassFile.exists() && (source.lastModified() <= backupClassFile.lastModified())) {
                log.info(source + " is up to date");
                continue;
            }

            log.info(String.format("Enhancing class file bytecode for Javaflow: %s", source));
            RewritingUtils.rewriteClassFile(source, transformer, destination);

            if (backupClassFile.exists()) {
                log.debug(String.format("Backup for original class file %s already exists - removing it",
                        backupClassFile));
                backupClassFile.delete();
            }

            log.debug(String.format("Renaming original class file from %s to %s", source, backupClassFile));
            FileUtils.moveFile(source, backupClassFile);

            log.debug(String.format("Renaming rewritten class file from %s to %s", destination, source));
            FileUtils.moveFile(destination, source);

            backupClassFile.setLastModified(source.lastModified());

        } catch (IOException e) {
            throw new MojoExecutionException(e.getMessage());
        }
    }
}

From source file:net.champemont.jean.hogancompile.maven.plugins.HoganTemplateCompilerMojo.java

License:Apache License

public void execute() throws MojoExecutionException {
    Log log = getLog();
    String root = project.getBasedir().getPath();
    String[] matchingFiles = scan(new File(root));
    for (String matchingFile : matchingFiles) {
        log.info("compiling '" + matchingFile + "'...");
        Path sourceFile = Paths.get(matchingFile);
        try {/*  w w w. j av  a2  s  . c o m*/
            //Reading template file
            byte[] fileBytes = Files.readAllBytes(sourceFile);
            String template = Charset.forName(sourceEncoding).decode(ByteBuffer.wrap(fileBytes)).toString();
            //Creating template name
            int templateNameExtensionIndex = sourceFile.getFileName().toString().lastIndexOf('.');
            String templateName = templateNameExtensionIndex > 0
                    ? sourceFile.getFileName().toString().substring(0, templateNameExtensionIndex)
                    : sourceFile.getFileName().toString();
            //Compiling template
            String result = HoganTemplateCompileHelper.compileHoganTemplate(template, templateName);
            //Writing output file
            ByteBuffer bb = Charset.forName(outputEncoding).encode(result);
            fileBytes = new byte[bb.remaining()];
            bb.get(fileBytes);
            Path outputFilePath = sourceFile.getParent().resolve(templateName + ".js");
            log.info("writing '" + outputFilePath.toString() + "'");
            Files.write(outputFilePath, fileBytes, StandardOpenOption.CREATE);
        } catch (IOException e) {
            throw new MojoExecutionException("Error while compiling Hogan Template", e);
        }
    }
}

From source file:net.champemont.jean.hogancompile.maven.plugins.HoganTemplateCompilerMojo.java

License:Apache License

private String[] scan(File root) throws MojoExecutionException {
    Log log = getLog();
    if (!root.exists()) {
        return new String[] {};
    }/*w  w w .j  a  va 2  s  .c o  m*/

    log.info("scanning source file directory '" + root + "'");

    final DirectoryScanner directoryScanner = new DirectoryScanner();
    directoryScanner.setIncludes(includes);
    directoryScanner.setExcludes(excludes);
    directoryScanner.setBasedir(root);
    directoryScanner.scan();
    return directoryScanner.getIncludedFiles();
}

From source file:net.eckenfels.mavenplugins.lockdeps.LockDependenciesMojo.java

License:Apache License

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

    log.debug("Now scanning dependencies..." + project);

    Set<Artifact> deps = project.getArtifacts();
    for (Artifact a : deps) {
        ArtifactRepository rep = a.getRepository();
        log.info("artifact: " + a.getId() + " (" + a.getScope() + ") from " + a.getDownloadUrl() + " "
                + a.getFile() + " repid=" + ((rep != null) ? rep.getId() : null));
    }/*from  w w w .  j  a va2s .  co m*/

    deps = project.getPluginArtifacts();
    for (Artifact a : deps) {
        log.info("plugin artifact: " + a.getId() + " (" + a.getScope() + ") from " + a.getDownloadUrl() + " "
                + a.getFile());
    }
}

From source file:net.eckenfels.mavenplugins.lockdeps.VerifyMojo.java

License:Apache License

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

    if (lockFile == null) {
        lockFile = new File(".dependencies.lock");
    }//from   ww w  . j av  a  2  s .  c  o m

    if (currentFile == null) {
        currentFile = new File(".dependencies.current");
    }

    if (!lockFile.exists()) {
        if (createCurrent) {
            log.info("We do not have a lockfile " + lockFile + " will create " + currentFile);
            try {
                ProjectScanner projectScanner = new ProjectScanner(project, "SHA-1");
                projectScanner.scan();
                projectScanner.writeTo(currentFile);
            } catch (IOException ioe) {
                throw new MojoExecutionException("I/O Error while scanning artifacts", ioe);
            } catch (NoSuchAlgorithmException nsa) {
                throw new MojoExecutionException("Cannot use algorithm SHA-1", nsa);
            }
        }
    } else {
        log.debug("Found version lockfile " + lockFile + " will compare hashes...");
        //readDependencies(project);
        //readLockfile();
    }
}

From source file:net.kozelka.contentcheck.mojo.LicenseShowMojo.java

License:Open Source License

private List<MavenProject> getMavenProjectForDependencies()
        throws MojoExecutionException, MojoFailureException {
    final DependencyNode dependencyTreeNode = resolveProject();
    final Dependencies dependencies = new Dependencies(project, dependencyTreeNode, classesAnalyzer);
    final Log log = getLog();
    final RepositoryUtils repoUtils = new RepositoryUtils(log, wagonManager, settings, mavenProjectBuilder,
            factory, resolver, project.getRemoteArtifactRepositories(), project.getPluginArtifactRepositories(),
            localRepository, repositoryMetadataManager);
    final Artifact projectArtifact = project.getArtifact();
    log.info(String.format("Resolving project %s:%s:%s dependencies", projectArtifact.getGroupId(),
            projectArtifact.getArtifactId(), projectArtifact.getVersion()));
    final List<Artifact> allDependencies = dependencies.getAllDependencies();
    final List<MavenProject> mavenProjects = new ArrayList<MavenProject>();
    for (Artifact artifact : allDependencies) {
        log.debug(String.format("Resolving project information for %s:%s:%s", artifact.getGroupId(),
                artifact.getArtifactId(), artifact.getVersion()));
        try {/*from   www.  ja va2 s . co m*/
            final MavenProject mavenProject = repoUtils.getMavenProjectFromRepository(artifact);
            mavenProjects.add(mavenProject);
        } catch (ProjectBuildingException e) {
            throw new MojoFailureException(
                    String.format("Cannot get project information for artifact %s:%s:%s from repository",
                            artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion()),
                    e);
        }
    }
    return mavenProjects;
}

From source file:net.nicoulaj.maven.plugins.soot.MavenLogPrintStream.java

License:Apache License

/**
 * Constructor.// ww  w. j a  v  a 2s  .c o m
 *
 * @param log the {@link Log} to which all output should be redirected.
 */
public MavenLogPrintStream(final Log log) {
    super(new ByteArrayOutputStream() {
        @Override
        public void flush() throws IOException {
            synchronized (this) {
                super.flush();
                final String buffer = toString();
                if (buffer.length() > 0 && !LINE_SEPARATOR.equals(buffer)) {
                    log.info(buffer);
                }
                super.reset();
            }
        }
    }, true);
}