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.mule.tools.apikit.input.MuleDomainParser.java

License:Open Source License

public MuleDomainParser(Log log, InputStream domainStream) {

    if (domainStream != null) {
        try {/*from   ww w  .  j av  a 2  s  .  c  om*/
            parseMuleDomainFile(domainStream);
        } catch (Exception e) {
            log.error("Error parsing Mule domain file. Reason: " + e.getMessage());
            log.debug(e);
        }
    }
}

From source file:org.mule.tools.apikit.input.RAMLFilesParser.java

License:Open Source License

public RAMLFilesParser(Log log, Map<File, InputStream> fileStreams, APIFactory apiFactory) {
    this.log = log;
    this.apiFactory = apiFactory;
    List<File> processedFiles = new ArrayList<File>();
    for (Map.Entry<File, InputStream> fileInputStreamEntry : fileStreams.entrySet()) {
        String content;/*from w w w.  ja va2  s. com*/
        File ramlFile = fileInputStreamEntry.getKey();
        try {
            content = IOUtils.toString(fileInputStreamEntry.getValue());
        } catch (IOException ioe) {
            this.log.info("Error loading file " + ramlFile.getName());
            break;

        }
        ResourceLoader resourceLoader = new CompositeResourceLoader(new DefaultResourceLoader(),
                new FileResourceLoader(ramlFile.getParentFile()));

        if (isValidYaml(ramlFile.getName(), content, resourceLoader)) {
            RamlDocumentBuilder builderNodeHandler = new RamlDocumentBuilder(resourceLoader);
            try {
                Raml raml = builderNodeHandler.build(content, ramlFile.getName());
                String host = APIKitTools.getHostFromUri(raml.getBaseUri());
                if (host == "") {
                    host = HttpListenerConfig.DEFAULT_HOST;
                }
                String port = APIKitTools.getPortFromUri(raml.getBaseUri());
                if (port == "") {
                    port = HttpListenerConfig.DEFAULT_PORT;
                }
                String path = APIKitTools.getPathFromUri(raml.getBaseUri());
                collectResources(ramlFile, raml.getResources(), host, port,
                        HttpListenerConfig.DEFAULT_BASE_PATH, path);
                processedFiles.add(ramlFile);
            } catch (Exception e) {
                log.info("Could not parse [" + ramlFile + "] as root RAML file. Reason: " + e.getMessage());
                log.debug(e);
            }
        }

    }
    if (processedFiles.size() > 0) {
        this.log.info("The following RAML files were parsed correctly: " + processedFiles);
    } else {
        this.log.error("RAML Root not found. None of the files were recognized as valid root RAML files.");
    }
}

From source file:org.mule.tools.recess.RecessMojo.java

License:Open Source License

public void execute() throws MojoExecutionException {

    Log log = getLog();

    if (!sourceDirectory.exists() || !sourceDirectory.isDirectory()) {
        throw new MojoExecutionException("Source directory does not exist.");
    }//from w ww  . ja  v a2s.  c  om

    Object[] files = getIncludedFiles();

    new File(getJavascriptFilesDirectory()).mkdirs();

    if (outputFile != null) {
        log.debug("outputFile parameter found. Using it to store the result.");
        new Recess(new WrappingConsoleFactory(MavenConsole.fromMavenLog(log)), files, getRecessConfig(),
                outputFile, true, getJavascriptFilesDirectory(), outputDirectory).run();

    } else if (outputDirectory != null) {

        log.debug("outputFile parameter not found. Using outputDirectory and changing the extension "
                + "of the contained files to css.");

        new Recess(new WrappingConsoleFactory(MavenConsole.fromMavenLog(log)), files, getRecessConfig(), null,
                false, getJavascriptFilesDirectory(), outputDirectory).run();

    } else {
        throw new MojoExecutionException("Error: Either outputFile or outputDirectory should be set.");
    }
}

From source file:org.objectledge.maven.plugins.jsc.JscMojo.java

License:Open Source License

public void execute() throws MojoExecutionException, MojoFailureException {
    Log log = getLog();
    log.debug(String.format("sourceDirectory : %s\n", sourceDirectory));
    log.debug(String.format("sourceExtension : %s\n", sourceExtension));
    log.debug(String.format("outputDirectory : %s\n", outputDirectory));
    log.debug(String.format("packageName     : %s\n", packageName));
    log.debug(String.format("versionNumber   : %s\n", versionNumber));

    File f = outputDirectory;//  w  ww.  j a v a2s. c o m
    if (!f.exists()) {
        f.mkdirs();
    }

    List<String> argList = new ArrayList<String>();
    appendArguments(argList);
    appendSources(argList);

    Main.main(argList.toArray(new String[argList.size()]));
}

From source file:org.onos.yangtools.yang2sources.plugin.Util.java

License:Open Source License

static Collection<File> findYangFilesInDependencies(Log log, MavenProject project) throws MojoFailureException {
    final List<File> yangsFilesFromDependencies = new ArrayList<>();

    try {/*from   w w  w.  j a  v  a2 s.  c  om*/
        List<File> filesOnCp = Util.getClassPath(project);
        log.info(Util.message("Searching for yang files in following dependencies: %s",
                YangToSourcesProcessor.LOG_PREFIX, filesOnCp));

        for (File file : filesOnCp) {
            // is it jar file or directory?
            if (file.isDirectory()) {
                //FIXME: code duplicate
                File yangDir = new File(file, YangToSourcesProcessor.META_INF_YANG_STRING);
                if (yangDir.exists() && yangDir.isDirectory()) {
                    File[] yangFiles = yangDir.listFiles(new FilenameFilter() {
                        @Override
                        public boolean accept(File dir, String name) {
                            return name.endsWith(".yang") && new File(dir, name).isFile();
                        }
                    });

                    yangsFilesFromDependencies.addAll(Arrays.asList(yangFiles));
                }
            } else {
                try (ZipFile zip = new ZipFile(file)) {

                    final Enumeration<? extends ZipEntry> entries = zip.entries();
                    while (entries.hasMoreElements()) {
                        ZipEntry entry = entries.nextElement();
                        String entryName = entry.getName();

                        if (entryName.startsWith(YangToSourcesProcessor.META_INF_YANG_STRING_JAR)
                                && !entry.isDirectory() && entryName.endsWith(".yang")) {
                            log.debug(Util.message("Found a YANG file in %s: %s",
                                    YangToSourcesProcessor.LOG_PREFIX, file, entryName));
                            yangsFilesFromDependencies.add(file);
                            break;
                        }
                    }
                }
            }
        }
    } catch (Exception e) {
        throw new MojoFailureException("Failed to scan for YANG files in depedencies", e);
    }
    return yangsFilesFromDependencies;
}

From source file:org.openengsb.openengsbplugin.tools.DefaultMavenExecutor.java

License:Apache License

private void printExecutionStartInfoLog(Log log) {
    log.info("////////////////////////////////////////////////");
    log.info(String.format("EMBEDDED EXECUTION REQUESTS - BEGIN"));

    LOG.debug("####################");
    LOG.debug("# GOALS:");
    LOG.debug("####################");

    String goalsInfo = "";
    for (String goal : embeddedRequest.getGoals()) {
        goalsInfo += String.format("\t* %s\n", goal);
    }//www.j  a v  a 2  s.co m
    LOG.debug(goalsInfo);

    LOG.debug("####################");
    LOG.debug("# ACTIVE PROFILES:");
    LOG.debug("####################");

    if (embeddedRequest.getActiveProfiles() != null && embeddedRequest.getActiveProfiles().size() > 0) {
        String profilesInfo = "";
        for (String profile : embeddedRequest.getActiveProfiles()) {
            profilesInfo += String.format("\t* %s\n", profile);
        }
        LOG.debug(profilesInfo);
    }

    LOG.debug("####################");
    LOG.debug("# INACTIVE PROFILES:");
    LOG.debug("####################");

    if (embeddedRequest.getInactiveProfiles() != null && embeddedRequest.getInactiveProfiles().size() > 0) {
        String profilesInfo = "";
        for (String profile : embeddedRequest.getInactiveProfiles()) {
            profilesInfo += String.format("\t* %s\n", profile);
        }
        log.debug(profilesInfo);
    }

    LOG.debug("####################");
    LOG.debug("# PROPERTIES:");
    LOG.debug("####################");

    if (embeddedRequest.getUserProperties() != null && embeddedRequest.getUserProperties().size() > 0) {
        String propertiesInfo = "";
        for (Object propName : embeddedRequest.getUserProperties().keySet()) {
            propertiesInfo += String.format("\t* %s=%s\n", propName,
                    embeddedRequest.getUserProperties().get(propName));
        }
        LOG.debug(propertiesInfo);
    }
}

From source file:org.openhab.tools.analysis.tools.CheckstyleChecker.java

License:Open Source License

@Override
public void execute() throws MojoExecutionException {
    Log log = getLog();
    ClassLoader cl = getMavenRuntimeClasspathClassLoader();
    Properties userProps = loadPropertiesFromFile(cl, CHECKSTYLE_PROPERTIES_FILE);

    String ruleset = getLocation(checkstyleRuleset, DEFAULT_RULESET_XML);
    log.debug("Ruleset location is " + ruleset);
    userProps.setProperty(CHECKSTYLE_RULESET_USER_PROPERTY, ruleset);

    String supression = getLocation(checkstyleFilter, DEFAULT_FILTER_XML);
    log.debug("Filter location is " + supression);
    userProps.setProperty(CHECKSTYLE_SUPPRESSION_USER_PROPERTY, supression);

    // Maven may load an older version, if I not specify any
    Dependency checktyle = dependency("com.puppycrawl.tools", "checkstyle", "7.2");
    Dependency[] allDependencies = getDependencies(checkstylePlugins, checktyle);

    Xpp3Dom config = configuration(element("sourceDirectory", mavenProject.getBasedir().toString()));

    executeCheck(MAVEN_CHECKSTYLE_PLUGIN_GROUP_ID, MAVEN_CHECKSTYLE_PLUGIN_ARTIFACT_ID, checkstyleMavenVersion,
            MAVEN_CHECKSTYLE_PLUGIN_GOAL, config, allDependencies);

    log.debug("Checkstyle execution has been finished.");

}

From source file:org.openhab.tools.analysis.tools.FindBugsChecker.java

License:Open Source License

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

    ClassLoader cl = getMavenRuntimeClasspathClassLoader();
    Properties userProps = loadPropertiesFromFile(cl, FINDBUGS_PROPERTIES_FILE);

    // Load the include filter file
    String includeLocation = getLocation(findbugsInclude, DEFAULT_INCLUDE_FILTER_XML);
    log.debug("Ruleset location is " + includeLocation);
    userProps.setProperty(FINDBUGS_INCLUDE_FILTER_USER_PROPERTY, includeLocation);

    // Load the exclude filter file
    String excludeLocation = getLocation(findbugsExclude, DEFAULT_EXCLUDE_FILTER_XML);
    log.debug("Filter location is " + excludeLocation);
    userProps.setProperty(FINDBUGS_EXCLUDE_FILTER_USER_PROPERTY, excludeLocation);

    String visitors = getVisitorsString(findbugsRuleset, DEFAULT_VISITORS_XML);
    log.debug("FindBugs visitors " + visitors);
    userProps.setProperty(FINDBUGS_VISITORS_PROPERTY, visitors);
    String outputDir = userProps.getProperty("findbugs.report.dir");

    // These configuration properties are not exposed from the findbugs-maven-plugin as user
    // properties, so they have to be set direct in the configuration
    Xpp3Dom config = configuration(element("outputDirectory", outputDir),
            element("xmlOutputDirectory", outputDir), element("findbugsXmlOutputDirectory", outputDir),
            getFindBugsPlugins());//from w w  w.  jav a 2 s . com

    // If this dependency is missing, findbugs can not load the core plugin because of classpath
    // issues
    Dependency findBugsDep = dependency("com.google.code.findbugs", "findbugs", findBugsPluginVersion);
    Dependency[] allDependencies = getDependencies(findbugsPlugins, findBugsDep);

    executeCheck(FINDBUGS_MAVEN_PLUGIN_GROUP_ID, FINDBUGS_MAVEN_PLUGIN_ARTIFACT_ID, findBugsPluginVersion,
            FINDBUGS_MAVEN_PLUGIN_GOAL, config, allDependencies);

    log.debug("FindBugs execution has been finished.");
}

From source file:org.openhab.tools.analysis.tools.PmdChecker.java

License:Open Source License

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

    ClassLoader cl = getMavenRuntimeClasspathClassLoader();
    Properties userProps = loadPropertiesFromFile(cl, PMD_PROPERTIES_FILE);

    String rulesetLocation = getLocation(pmdRuleset, DEFAULT_RULESET_XML);
    log.debug("Ruleset location is " + rulesetLocation);

    // These configuration properties are not exposed from the maven-pmd-plugin as user properties,
    // so they have to be set direct in the configuration
    Xpp3Dom configuration = configuration(
            element("targetDirectory", userProps.getProperty("pmd.custom.targetDirectory")),
            element("rulesets", element("ruleset", rulesetLocation)));

    Dependency[] allDependencies = getDependencies(pmdPlugins, null);

    executeCheck(MAVEN_PMD_PLUGIN_GROUP_ID, MAVEN_PMD_PLUGIN_ARTIFACT_ID, mavenPmdVersion,
            MAVEN_PMD_PLUGIN_GOAL, configuration, allDependencies);

    log.debug("PMD execution has been finished.");

}

From source file:org.phpmaven.core.ExecutionUtils.java

License:Apache License

/**
 * Executes a command.//from  w w w. j ava 2s. c om
 * @param log the logger
 * @param command command line
 * @param workDir working directory
 * @return result string.
 * @throws CommandLineException throw on execution errors.
 */
public static String executeCommand(Log log, String command, final File workDir) throws CommandLineException {
    final Commandline cli = new Commandline(command);
    if (log != null) {
        log.debug("Executing " + command);
    }

    if (workDir != null) {
        if (!workDir.exists()) {
            workDir.mkdirs();
        }
        cli.setWorkingDirectory(workDir);
    }

    final StringBuilder stdout = new StringBuilder();
    final StringBuilder stderr = new StringBuilder();
    final StreamConsumer systemOut = new StreamConsumer() {
        @Override
        public void consumeLine(String line) {
            stdout.append(line);
            stdout.append("\n");
        }
    };
    final StreamConsumer systemErr = new StreamConsumer() {
        @Override
        public void consumeLine(String line) {
            stderr.append(line);
            stderr.append("\n");
        }
    };
    try {
        final int result = CommandLineUtils.executeCommandLine(cli, systemOut, systemErr);
        if (result != 0) {
            if (log != null) {
                log.warn("Error invoking command. Return code " + result + "\n\nstd-out:\n" + stdout
                        + "\n\nstd-err:\n" + stderr);
            }
            throw new CommandLineException("Error invoking command. Return code " + result);
        }
    } catch (CommandLineException ex) {
        if (log != null) {
            log.warn("Error invoking command\n\nstd-out:\n" + stdout + "\n\nstd-err:\n" + stderr);
        }
        throw ex;
    }
    if (log != null) {
        log.debug("stdout: " + stdout.toString());
    }
    return stdout.toString();
}