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

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

Introduction

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

Prototype

boolean isDebugEnabled();

Source Link

Usage

From source file:org.codehaus.mojo.xmlbeans.SchemaArtifact.java

License:Apache License

/**
 * Assuming that the artifact has a file handle, returns a collection of strings
 * pointing to each xsd file within the jar.
 *
 * @return Collection of xsd file paths relative to the jar file.
 * @number MXMLBEANS-21/*from w  ww  . j a v a  2 s  . c om*/
 */
public static Map getFilePaths(Artifact artifact, Log logger, File prefix) throws XmlBeansException {
    Map xsds = new HashMap();
    File artifactFile = artifact.getFile();
    List nextSet;
    if (artifactFile != null) {
        try {
            FilteredJarFile jarFile = new FilteredJarFile(artifactFile, logger);

            nextSet = jarFile.getEntryPathsAndExtract(XSD_SUFFIXES, prefix);
            String fileName;
            for (Iterator i = nextSet.iterator(); i.hasNext();) {
                fileName = (String) i.next();
                if (logger.isDebugEnabled()) {
                    logger.debug("Adding " + fileName + "from an artifact.");
                }
                xsds.put(fileName, new File(prefix, fileName));
            }

        } catch (IOException ioe) {
            throw new XmlBeansException(XmlBeansException.XSD_ARTIFACT_JAR, ioe);

        }
    } else {
        throw new XmlBeansException(XmlBeansException.ARTIFACT_FILE_PATH, artifact.toString());
    }

    return xsds;
}

From source file:org.dthume.maven.xpom.mojo.ProjectMojo.java

License:Apache License

private Model getModel() {
    final Log log = getLog();

    Model model = null;//from   w w  w  .  j  a  v a 2s .  c  o  m
    if (isUseEffectiveModel()) {
        log.debug("Using effective project model");
        model = getProject().getModel();
    } else {
        log.debug("Using original project Model");
        model = getProject().getOriginalModel();
    }

    if (log.isDebugEnabled())
        log.debug("Model=" + model);

    return model;
}

From source file:org.eluder.coveralls.maven.plugin.logging.JobLogger.java

License:Open Source License

@Override
public void log(final Log log) {
    StringBuilder starting = new StringBuilder("Starting Coveralls job");
    if (job.getServiceName() != null) {
        starting.append(" for " + job.getServiceName());
        if (job.getServiceJobId() != null) {
            starting.append(" (" + job.getServiceJobId() + ")");
        } else if (job.getServiceBuildNumber() != null) {
            starting.append(" (" + job.getServiceBuildNumber());
            if (job.getServiceBuildUrl() != null) {
                starting.append(" / " + job.getServiceBuildUrl());
            }//  w w  w  . jav  a2s .  com
            starting.append(")");
        }
    }
    if (job.isDryRun()) {
        starting.append(" in dry run mode");
    }
    log.info(starting.toString());

    if (job.getRepoToken() != null) {
        log.info("Using repository token <secret>");
    }

    if (job.getGit() != null) {
        String commit = job.getGit().getHead().getId();
        String branch = (job.getBranch() != null ? job.getBranch() : job.getGit().getBranch());
        log.info("Git commit " + commit.substring(0, ABBREV) + " in " + branch);
    }

    if (log.isDebugEnabled()) {
        try {
            log.debug("Complete Job description:\n" + jsonMapper.writeValueAsString(job));
        } catch (JsonProcessingException ex) {
            throw new RuntimeException(ex);
        }
    }
}

From source file:org.impalaframework.maven.plugin.CopyModulesMojo.java

License:Apache License

public void execute() throws MojoExecutionException {

    final Log logger = getLog();

    if (isImpalaHost()) {

        moduleStagingDirectory = MojoUtils.getModuleStagingDirectory(getLog(), project, moduleStagingDirectory);

        if (logger.isDebugEnabled()) {
            logger.debug("Maven projects: " + dependencies);
            logger.debug("Current project: " + project);
        }//from w  w w .ja  va 2 s . c o  m

        File targetDirectory = getTargetDirectory();
        File stagingDirectory = new File(moduleStagingDirectory);

        try {
            if (logger.isDebugEnabled()) {
                logger.debug("Staging directory " + stagingDirectory.getCanonicalPath());
            }
            FileUtils.forceMkdir(targetDirectory);
        } catch (IOException e) {
            throw new MojoExecutionException(e.getMessage(), e);
        }

        if (logger.isInfoEnabled()) {
            logger.info("Copying files from staging directory: " + stagingDirectory);
        }

        final File[] listFiles = stagingDirectory.listFiles();

        if (listFiles != null) {
            for (File moduleFile : listFiles) {

                final String targetFileName = moduleFile.getName();

                MojoUtils.copyFile(moduleFile, targetDirectory, targetFileName);
                if (logger.isInfoEnabled()) {
                    logger.info("Copying from from staging directory: " + moduleFile);
                }
            }
        }
    }
}

From source file:org.izpack.mojo.IzPackNewMojo.java

License:Open Source License

private Handler createLogHandler() {
    final ConsoleHandler consoleHandler = new ConsoleHandler();
    consoleHandler.setFormatter(new MavenStyleLogFormatter());
    Log log = getLog();
    Level level = Level.OFF;
    if (log.isDebugEnabled()) {
        level = Level.FINE;/*w w  w. j  ava  2  s .  c  o m*/
    } else if (log.isInfoEnabled()) {
        level = Level.INFO;
    } else if (log.isWarnEnabled()) {
        level = Level.WARNING;
    } else if (log.isErrorEnabled()) {
        level = Level.SEVERE;
    }
    consoleHandler.setLevel(level);
    return consoleHandler;
}

From source file:org.jasig.maven.plugin.sass.AbstractSassMojo.java

License:Apache License

protected void buildBasicSASSScript(final StringBuilder sassScript) throws MojoExecutionException {
    final Log log = this.getLog();

    sassScript.append("require 'rubygems'\n");

    if (gemPaths.length > 0) {
        sassScript.append("env = { 'GEM_PATH' => [\n");
        for (final String gemPath : gemPaths) {
            sassScript.append("    '").append(gemPath).append("',\n");
        }/*from  w  w w  . j a  v  a2 s.  com*/

        final String gemPath = System.getenv("GEM_PATH");
        if (gemPath != null) {
            for (final String p : gemPath.split(File.pathSeparator)) {
                sassScript.append("    '").append(p).append("',\n");
            }
        }
        sassScript.setLength(sassScript.length() - 2); // remove trailing comma
        sassScript.append("\n");
        sassScript.append("] }\n");
        sassScript.append("Gem.paths = env\n");
    }

    for (final String gem : gems) {
        sassScript.append("require '").append(gem).append("'\n");
    }

    sassScript.append("require 'sass/plugin'\n");
    sassScript.append("require 'java'\n");

    if (this.useCompass) {
        log.info("Running with Compass enabled.");
        sassScript.append("require 'compass'\n");
        sassScript.append("require 'compass/exec'\n");
        sassScript.append("Compass.add_project_configuration \n");
        this.sassOptions.put("load_paths", "Compass.configuration.sass_load_paths");
        // manually specify these paths
        sassScript.append(
                "Compass::Frameworks.register_directory('jar:'+ File.join(Compass::Core.base_directory, 'stylesheets'))\n");
    }

    // Get all template locations from resources and set option 'template_location' and
    // 'css_location' (to override default "./public/stylesheets/sass", "./public/stylesheets")
    // remaining locations are added later with 'add_template_location'
    final Iterator<Entry<String, String>> templateLocations = getTemplateLocations();
    if (templateLocations.hasNext()) {
        Entry<String, String> location = templateLocations.next();
        sassOptions.put("template_location", "'" + location.getKey() + "'");
        sassOptions.put("css_location", "'" + location.getValue() + "'");
    }

    //If not explicitly set place the cache location in the target dir
    if (!this.sassOptions.containsKey("cache_location")) {
        final File sassCacheDir = new File(this.buildDirectory, "sass_cache");
        final String sassCacheDirStr = sassCacheDir.toString();
        this.sassOptions.put("cache_location", "'" + FilenameUtils.separatorsToUnix(sassCacheDirStr) + "'");
    }

    //Add the plugin configuration options
    sassScript.append("Sass::Plugin.options.merge!(\n");
    for (final Iterator<Entry<String, String>> entryItr = this.sassOptions.entrySet().iterator(); entryItr
            .hasNext();) {
        final Entry<String, String> optEntry = entryItr.next();
        final String opt = optEntry.getKey();
        final String value = optEntry.getValue();
        sassScript.append("    :").append(opt).append(" => ").append(value);
        if (entryItr.hasNext()) {
            sassScript.append(",");
        }
        sassScript.append("\n");
    }
    sassScript.append(")\n");

    // add remaining template locations with 'add_template_location' (need to be done after options.merge)
    while (templateLocations.hasNext()) {
        Entry<String, String> location = templateLocations.next();
        sassScript.append("Sass::Plugin.add_template_location('").append(location.getKey()).append("', '")
                .append(location.getValue()).append("')\n");
    }

    // set up sass compiler callback for reporting
    sassScript.append(
            "Sass::Plugin.on_compilation_error {|error, template, css| $compiler_callback.compilationError(error.message, template, css) }\n");
    sassScript.append(
            "Sass::Plugin.on_updated_stylesheet {|template, css| $compiler_callback.updatedStylesheeet(template, css) }\n");
    sassScript.append(
            "Sass::Plugin.on_template_modified {|template| $compiler_callback.templateModified(template) }\n");
    sassScript.append(
            "Sass::Plugin.on_template_created {|template| $compiler_callback.templateCreated(template) }\n");
    sassScript.append(
            "Sass::Plugin.on_template_deleted {|template| $compiler_callback.templateDeleted(template) }\n");

    // make ruby give use some debugging info when requested
    if (log.isDebugEnabled()) {
        sassScript.append("require 'pp'\npp Sass::Plugin.options\n");
        if (useCompass) {
            sassScript.append("pp Compass::configuration\n");
        }
    }
}

From source file:org.jboss.bridger.BridgerMojo.java

License:Open Source License

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    final Log log = getLog();
    if (skip) {/* ww w. j  a  v  a2s .  c o m*/
        log.info("Skipping bridger transform");
    } else {
        final Bridger bridger = new Bridger();
        final File[] files = getFiles();

        if (log.isDebugEnabled()) {
            final String newLine = String.format("%n\t");
            final StringBuilder sb = new StringBuilder("Transforming Files:");
            sb.append(newLine);
            for (File file : files) {
                sb.append(file.getAbsolutePath()).append(newLine);
            }
            log.debug(sb);
        }

        bridger.transformRecursive(files);
        log.info(String.format("Translated %d methods and %d method calls%n",
                bridger.getTransformedMethodCount(), bridger.getTransformedMethodCallCount()));
    }
}

From source file:org.jboss.provisioning.wildfly.build.ModuleXmlVersionResolver.java

License:Apache License

public static void filterAndConvertModules(Path fpDirectory, Path targetModuleDir,
        Map<String, Artifact> artifacts, Log log) throws IOException {
    Files.walkFileTree(fpDirectory, new FileVisitor<Path>() {
        @Override//from www.  j  ava  2  s .com
        public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
            if (isModules(dir)) {
                debug(log, "Copying %s to %s", dir, targetModuleDir);
                convertModules(dir, targetModuleDir, artifacts, log);
                return FileVisitResult.SKIP_SUBTREE;
            }
            return FileVisitResult.CONTINUE;
        }

        @Override
        public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
            return FileVisitResult.CONTINUE;
        }

        @Override
        public FileVisitResult visitFileFailed(Path file, IOException exc) throws IOException {
            return FileVisitResult.CONTINUE;
        }

        @Override
        public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
            return FileVisitResult.CONTINUE;
        }

        private void debug(Log log, String format, Object... args) {
            if (log.isDebugEnabled()) {
                log.debug(String.format(format, args));
            }
        }
    });
}

From source file:org.jboss.provisioning.wildfly.build.WfFeatureSpecBuildMojo.java

License:Apache License

private void debug(String format, Object... args) {
    final Log log = getLog();
    if (log.isDebugEnabled()) {
        log.debug(String.format(format, args));
    }// w ww  .  java2 s. co  m
}

From source file:org.kaazing.k3po.maven.plugin.internal.StartMojo.java

License:Open Source License

@Override
protected void executeImpl() throws MojoExecutionException {

    try {//ww w  .j av  a 2 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);
    }
}