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

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

Introduction

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

Prototype

void debug(Throwable error);

Source Link

Document

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

Usage

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

License:Apache License

/**
 * Execute the SASS Compilation Ruby Script
 *//*from   ww  w .j  a  va  2  s.  c  om*/
protected void executeSassScript(String sassScript) throws MojoExecutionException, MojoFailureException {
    final Log log = this.getLog();
    System.setProperty("org.jruby.embed.localcontext.scope", "threadsafe");

    log.debug("Execute SASS Ruby Script:\n" + sassScript);

    final ScriptEngineManager scriptEngineManager = new ScriptEngineManager();
    final ScriptEngine jruby = scriptEngineManager.getEngineByName("jruby");
    try {
        CompilerCallback compilerCallback = new CompilerCallback(log);
        jruby.getBindings(ScriptContext.ENGINE_SCOPE).put("compiler_callback", compilerCallback);
        jruby.eval(sassScript);
        if (failOnError && compilerCallback.hadError()) {
            throw new MojoFailureException("SASS compilation encountered errors (see above for details).");
        }
    } catch (final ScriptException e) {
        throw new MojoExecutionException("Failed to execute SASS ruby script:\n" + sassScript, e);
    }
}

From source file:org.jasig.resource.aggr.mojo.AbstractSkinResourcesAggregatorMojo.java

License:Apache License

protected void doAggregation(ResourcesAggregator aggr, File skinConfigurationFile, File skinOutputDirectory)
        throws IOException {
    final Log log = this.getLog();

    final AggregationRequest aggregationRequest = new AggregationRequest();
    aggregationRequest.setResourcesXml(skinConfigurationFile).setOutputBaseDirectory(skinOutputDirectory);

    if (sharedJavaScriptDirectory != null) {
        final File fullSharedJavaScriptDirectory = new File(baseOutputDirectory, sharedJavaScriptDirectory);
        aggregationRequest.setSharedJavaScriptDirectory(fullSharedJavaScriptDirectory);
    }/*from   w w  w . ja v a2s .c  o  m*/

    if (useGeneratedSources) {
        aggregationRequest.addAdditionalSourceDirectory(skinOutputDirectory);
    }

    log.debug("Aggregating: " + aggregationRequest);
    aggr.aggregate(aggregationRequest);
}

From source file:org.jboss.as.plugin.server.Start.java

License:Open Source License

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    final Log log = getLog();
    if (isSkip()) {
        log.debug("Skipping server start");
        return;//from  w  ww. ja  va2 s . c  o m
    }
    // Validate the environment
    final File jbossHome = extractIfRequired(targetDir);
    if (!jbossHome.isDirectory()) {
        throw new MojoExecutionException(String.format("JBOSS_HOME '%s' is not a valid directory.", jbossHome));
    }
    final String javaHome;
    if (this.javaHome == null) {
        javaHome = SecurityActions.getEnvironmentVariable("JAVA_HOME");
    } else {
        javaHome = this.javaHome;
    }
    final List<String> invalidPaths = modulesPath.validate();
    if (!invalidPaths.isEmpty()) {
        throw new MojoExecutionException("Invalid module path(s). " + invalidPaths);
    }
    final ServerConfig serverConfig = ServerConfig.of(this, jbossHome).setJavaHome(javaHome)
            .setModulesDir(modulesPath.get()).setBundlesDir(bundlesPath).setJvmArgs(jvmArgs.getArgs())
            .setServerConfig(this.serverConfig).setPropertiesFile(propertiesFile).setServerArgs(serverArgs)
            .setStartupTimeout(startupTimeout);
    // Print some server information
    log.info(String.format("JAVA_HOME=%s", javaHome));
    log.info(String.format("JBOSS_HOME=%s%n", jbossHome));
    try {
        // Create the server
        final Server server = new StandaloneServer(serverConfig);
        // Add the shutdown hook
        SecurityActions.registerShutdown(server);
        // Start the server
        log.info("Server is starting up.");
        server.start();
        server.checkServerState();
    } catch (Exception e) {
        throw new MojoExecutionException("The server failed to start", e);
    }

}

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) {/*from   ww w  .j a  va 2  s .  co  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.maven.plugins.enforcer.rules.version.OSGIVersionRule.java

License:Open Source License

private boolean isOSGIVersion(String version, Log logger) {
    try {//w  ww.j  av  a 2s . com
        Version.parseVersion(version);
        return true;
    } catch (Exception e) {
        logger.debug(e.getLocalizedMessage()); // print out for debug the reason
    }
    return false;
}

From source file:org.jboss.maven.plugins.qstools.checkers.AbstractProjectChecker.java

License:Apache License

@Override
@SuppressWarnings("unchecked")
public Map<String, List<Violation>> check(MavenProject project, MavenSession mavenSession,
        List<MavenProject> reactorProjects, Log log) throws QSCheckerException {
    this.mavenSession = mavenSession;
    this.log = log;
    Map<String, List<Violation>> results = new TreeMap<String, List<Violation>>();
    try {//from   www  . j  a  v a2 s . co m
        List<String> ignoredQuickstarts = (List<String>) context.get(Constants.IGNORED_QUICKSTARTS_CONTEXT);
        for (MavenProject mavenProject : reactorProjects) {
            if (!ignoredQuickstarts.contains(mavenProject.getBasedir().getName())) {
                Document doc = PositionalXMLReader.readXML(new FileInputStream(mavenProject.getFile()));
                if (configurationProvider.getQuickstartsRules(project.getGroupId()).isCheckerIgnored(this)) {
                    String msg = "Skiping %s for %s:%s";
                    log.warn(String.format(msg, this.getClass().getSimpleName(), project.getGroupId(),
                            project.getArtifactId()));
                } else {
                    processProject(mavenProject, doc, results);
                }
            } else {
                log.debug("Ignoring " + mavenProject.getBasedir().getName()
                        + ". It is listed on .quickstarts_ignore file");
            }
        }
        if (violationsQtd > 0) {
            log.info("There are " + violationsQtd + " checkers errors");
        }
    } catch (Exception e) {
        // Any other exception is a problem.
        throw new QSCheckerException(e);
    }
    return results;
}

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  . jav a2 s  .  c om*/
        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.ModuleXmlVersionResolver.java

License:Apache License

private static void convert(final XMLEventReader r, final XMLEventWriter w, Map<String, Artifact> artifacts,
        Log log) throws IOException, XMLStreamException {
    XMLEventFactory eventFactory = XMLEventFactory.newInstance();
    while (r.hasNext()) {
        XMLEvent event = r.nextEvent();
        switch (event.getEventType()) {
        case XMLStreamConstants.START_ELEMENT:
            StartElement startElement = event.asStartElement();
            if ("module".equals(startElement.getName().getLocalPart())) {
                StartElement convertedModule = convertModuleElement(eventFactory, startElement, artifacts);
                log.debug(startElement + " has been converted to " + convertedModule);
                w.add(convertedModule);//from w ww . j a  v  a2  s  . c  om
            } else if ("artifact".equals(startElement.getName().getLocalPart())) {
                StartElement convertedArtifact = convertArtifactElement(eventFactory, startElement, artifacts,
                        log);
                log.debug(startElement + " has been converted to " + convertedArtifact);
                w.add(convertedArtifact);
            } else {
                w.add(event);
            }
            break;
        case XMLStreamConstants.START_DOCUMENT:
        case XMLStreamConstants.END_DOCUMENT:
        case XMLStreamConstants.PROCESSING_INSTRUCTION:
        case XMLStreamConstants.END_ELEMENT:
        case XMLStreamConstants.COMMENT:
        case XMLStreamConstants.CDATA:
        case XMLStreamConstants.SPACE:
        case XMLStreamConstants.CHARACTERS:
        case XMLStreamConstants.NAMESPACE:
            w.add(event);
            break;
        }
    }
    w.flush();
    w.close();
}

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));
    }/*from w ww.  ja  v  a2  s. c o m*/
}

From source file:org.jboss.tools.releng.NoSnapshotsAllowed.java

License:Open Source License

public void execute(EnforcerRuleHelper helper) throws EnforcerRuleException {
    Log log = helper.getLog();

    try {/*from  ww w  . j  av  a 2  s.c  o  m*/
        // get the various expressions out of the helper.
        MavenProject project = (MavenProject) helper.evaluate("${project}");

        //            MavenSession session = (MavenSession) helper.evaluate( "${session}" );
        String target = (String) helper.evaluate("${project.build.directory}");
        String artifactId = (String) helper.evaluate("${project.artifactId}");

        // defaults if not set
        if (includePattern == null || includePattern.equals("")) {
            includePattern = ".*";
        }
        if (excludePattern == null || excludePattern.equals("")) {
            excludePattern = "";
        }

        log.debug("Search for properties matching " + SNAPSHOT + "...");

        Properties projProps = project.getProperties();
        Enumeration<?> e = projProps.propertyNames();
        while (e.hasMoreElements()) {
            String key = (String) e.nextElement();
            // fetch from parent pom if not passed into the rule config
            if (buildAlias == null && key.equals("BUILD_ALIAS")) {
                buildAlias = projProps.getProperty(key);
                if (buildAlias.matches(buildAliasSearch)) {
                    log.info("Found buildAlias = " + buildAlias + " (for buildAliasSearch = " + buildAliasSearch
                            + ")");
                } else {
                    log.debug("Found buildAlias = " + buildAlias + " (for buildAliasSearch = "
                            + buildAliasSearch + ")");
                }
            } else if (key.matches(includePattern)
                    && (excludePattern.equals("") || !key.matches(excludePattern))
                    && projProps.getProperty(key).indexOf(SNAPSHOT) > -1) {
                log.error("Found property " + key + " = " + projProps.getProperty(key));
                snapshotKey = key;
                //                } else {
                //                    log.debug("Property: "+ key + " = " + projProps.getProperty(key));
            }
        }

        //            // retrieve any component out of the session directly
        //            ArtifactResolver resolver = (ArtifactResolver) helper.getComponent( ArtifactResolver.class );
        //            RuntimeInformation rti = (RuntimeInformation) helper.getComponent( RuntimeInformation.class );
        //            log.debug( "Retrieved Session: " + session );
        //            log.debug( "Retrieved Resolver: " + resolver );
        //            log.debug( "Retrieved RuntimeInfo: " + rti );

        log.debug("Retrieved Target Folder: " + target);
        log.debug("Retrieved ArtifactId: " + artifactId);
        log.debug("Retrieved Project: " + project);
        log.debug("Retrieved Project Version: " + project.getVersion());

        if (buildAlias.matches(buildAliasSearch) && snapshotKey != null) {
            throw new EnforcerRuleException("\nWhen buildAlias (" + buildAlias + ") matches /"
                    + buildAliasSearch + "/, cannot include " + SNAPSHOT + " dependencies.\n");
        }
    } catch (ExpressionEvaluationException e) {
        throw new EnforcerRuleException("Unable to lookup an expression " + e.getLocalizedMessage(), e);
    }
}