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.universAAL.support.directives.checks.ModulesCheckFix.java

License:Apache License

private boolean passRootCheckCommonType(MavenProject mavenProject2, Log log) {
    List<String> mods = (List<String>) mavenProject2.getModules();
    List<File> listed = new ArrayList<File>();
    for (String m : mods) {
        try {/*w w  w.  j av  a  2s  .co  m*/
            listed.add(new File(mavenProject2.getBasedir(), m).getCanonicalFile());
        } catch (IOException e) {
            log.error(e);
        }
    }
    //gather the existent modules
    File dir = mavenProject2.getBasedir();
    for (File f : dir.listFiles()) {
        String rel = f.getName();
        if (f.isDirectory() && directoryContains(f, "pom.xml") && !listed.contains(f) // it is not already listed
                && !rel.contains(SVN_FOLDER)
        // it is not the svn folder
        ) {
            toBeFixed.add(rel);
            log.debug("Found not listed module : " + rel);
        }
    }
    return toBeFixed.isEmpty();
}

From source file:org.universAAL.support.directives.checks.ModulesCheckFix.java

License:Apache License

private boolean passRootCheckSiblingType(MavenProject mavenProject2, Log log) {
    List<String> listed = (List<String>) mavenProject2.getModules();

    //gather the existent modules
    File dir = mavenProject2.getBasedir().getParentFile();
    for (File f : dir.listFiles()) {
        String rel = "../" + f.getName();
        if (f.isDirectory() && directoryContains(f, "pom.xml") && !listed.contains(rel) // it is not already listed
                && !rel.endsWith(mavenProject2.getBasedir().getName())
                // it is not the parent project
                && !rel.contains(SVN_FOLDER)
        // it is not the svn folder
        ) {/*from ww  w  .  j a  va  2s  . c  o m*/
            toBeFixed.add(rel);
            log.debug("Found not listed module : " + rel);
        }
    }
    return toBeFixed.isEmpty();
}

From source file:org.universAAL.support.directives.checks.ParentGForgePropertyCheck.java

License:Apache License

private String getCorrectPropValue(MavenProject mavenProject, Log log)
        throws SVNException, MalformedURLException, Exception {

    String correctValue = getSVNURL(mavenProject.getBasedir());
    URL u = new URL(correctValue);
    correctValue = u.getPath().split("/")[1];
    log.debug("Determined Correct Value for " + PROP + ": " + correctValue);
    return correctValue;
}

From source file:org.universAAL.support.directives.checks.SVNCheck.java

License:Apache License

public boolean check(MavenProject mavenProject, Log log) throws MojoExecutionException, MojoFailureException {
    this.mavenProject = mavenProject;
    log.debug("checking svn for " + mavenProject.getBasedir().getPath());
    try {//  w ww .  j  a v a 2s.  c  o m
        surl = getSVNURL(mavenProject.getBasedir());

        log.debug("found URL   : " + surl);
        log.debug("comparing with   : " + mavenProject.getScm().getConnection());
        log.debug("comparing with   : " + mavenProject.getScm().getDeveloperConnection());
        if (missMatchURLs(surl) || missMatchURLs(surl.replace(OLD_URL, NEW_URL))) {
            throw new MojoFailureException(SCM_NOT_CONFIGURED);

        } else {
            log.debug("SCM and SVN info are in sync.");
            return true;
        }
    } catch (SVNException e) {
        log.warn("SVN Error.", e);
        log.warn("directory seems not to be a local SVN working copy.");
        throw new MojoExecutionException("Directory seems not to be a local SVN working copy.", e);
    } catch (MojoFailureException e) {
        throw e;
    } catch (MojoExecutionException e) {
        throw e;
    } catch (Exception e1) {
        throw new MojoExecutionException("Unexpected Exception", e1);
    }
}

From source file:org.universAAL.support.directives.checks.SVNCheck.java

License:Apache License

public void fix(MavenProject mavenProject, Log log) throws MojoFailureException {
    log.debug("Fixing SCM with URL: " + surl);
    fixSCMWith(surl, log);//from  w w w.j av a2 s .  c om
}

From source file:org.universAAL.support.directives.checks.SVNIgnoreCheck.java

License:Apache License

/** {@inheritDoc} */
public boolean check(MavenProject mavenProject, Log log) throws MojoExecutionException, MojoFailureException {
    this.log = log;
    SVNClientManager cli = SVNClientManager.newInstance();
    log.debug("checking svn ignore Rules in: " + mavenProject.getBasedir().getPath());
    try {//  w  ww .ja v  a 2 s. c  om
        wcCli = cli.getWCClient();
        SVNPropertyData pd = wcCli.doGetProperty(mavenProject.getBasedir(), SVNProperty.IGNORE,
                SVNRevision.WORKING, SVNRevision.WORKING);
        boolean changed = false;
        if (pd == null) {
            changed = true;
            prop = "";
            for (int i = 0; i < ignores.length; i++)
                prop += ignores[i] + "\n";
        } else {
            prop = pd.getValue().getString();
            log.debug("Ignore Property contains: " + prop);// .split("\n")[0]
            for (int i = 0; i < ignores.length; i++) {
                if (!prop.contains(ignores[i]) && exists(mavenProject, ignores[i])) {
                    prop += ignores[i] + "\n";
                    changed = true;
                }
            }
        }
        if (changed) {
            String err = NO_IGNORES;
            for (int i = 0; i < ignores.length; i++) {
                err += "\n\t" + ignores[i];
            }
            throw new MojoFailureException(err);
        }
    } catch (SVNException e) {
        e.printStackTrace();
        log.warn("SVN Error.");
        log.warn("directory seems not to be a local SVN working copy.");
        return false;
    }
    return true;
}

From source file:org.wildfly.plugin.common.AbstractServerConnection.java

License:Open Source License

/**
 * Gets a client configuration used to create a new {@link ModelControllerClient}.
 *
 * @return the configuration to use//  w  w  w .  jav  a 2  s  .  c  o m
 */
protected synchronized ModelControllerClientConfiguration getClientConfiguration() {
    if (clientConfiguration == null) {
        final Log log = getLog();
        String username = this.username;
        String password = this.password;
        if (username == null && password == null) {
            if (id != null) {
                if (settings != null) {
                    Server server = settings.getServer(id);
                    if (server != null) {
                        log.debug(DEBUG_MESSAGE_SETTINGS_HAS_ID);
                        password = decrypt(server);
                        username = server.getUsername();
                        if (username != null && password != null) {
                            log.debug(DEBUG_MESSAGE_SETTINGS_HAS_CREDS);
                        } else {
                            log.debug(DEBUG_MESSAGE_NO_CREDS);
                        }
                    } else {
                        log.debug(DEBUG_MESSAGE_NO_SERVER_SECTION);
                    }
                } else {
                    log.debug(DEBUG_MESSAGE_NO_SETTINGS_FILE);
                }
            } else {
                log.debug(DEBUG_MESSAGE_NO_ID);
            }
        } else {
            log.debug(DEBUG_MESSAGE_POM_HAS_CREDS);
        }
        final String u = username;
        final String p = password;
        clientConfiguration = new ModelControllerClientConfiguration.Builder().setProtocol(protocol)
                .setHostName(hostname).setPort(port).setConnectionTimeout(timeout * 1000)
                .setHandler(new ClientCallbackHandler(u, p, log)).build();
    }
    return clientConfiguration;
}

From source file:org.wildfly.plugin.server.StartMojo.java

License:Open Source License

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    final Log log = getLog();
    if (skip) {//from  www .ja va2  s .  co m
        log.debug("Skipping server start");
        return;
    }
    // Validate the environment
    final Path jbossHome = extractIfRequired(targetDir.toPath());
    if (!Files.isDirectory(jbossHome)) {
        throw new MojoExecutionException(String.format("JBOSS_HOME '%s' is not a valid directory.", jbossHome));
    }

    try {
        // Determine how stdout should be consumed
        OutputStream out = null;
        if (stdout != null) {
            final String value = stdout.trim().toLowerCase(Locale.ENGLISH);
            if ("system.out".equals(value)) {
                out = System.out;
            } else if ("system.err".equals(value)) {
                out = System.err;
            } else if ("none".equals(value)) {
                out = null;
            } else {
                // Attempt to create a file
                final Path path = Paths.get(value);
                if (Files.notExists(path)) {
                    final Path parent = path.getParent();
                    if (parent != null) {
                        Files.createDirectories(parent);
                    }
                    Files.createFile(path);
                }
                out = new BufferedOutputStream(Files.newOutputStream(path));
            }
        }
        // Create the server, note the client should be shutdown when the server is stopped
        final Server server = Server.create(createCommandBuilder(jbossHome), env, createClient(), out);
        // Start the server
        log.info(String.format("%s server is starting up.", serverType));
        server.start(startupTimeout);
        server.checkServerState();
    } catch (Exception e) {
        throw new MojoExecutionException("The server failed to start", e);
    }

}

From source file:org.xolstice.maven.plugin.protobuf.Protoc.java

License:Open Source License

/**
 * Logs execution parameters on debug level to the specified logger.
 * All log messages will be prefixed with "{@value #LOG_PREFIX}".
 *
 * @param log a logger.//from   w  w  w .ja v  a2  s  .  c o  m
 */
public void logExecutionParameters(final Log log) {
    if (log.isDebugEnabled()) {
        log.debug(LOG_PREFIX + "Executable: ");
        log.debug(LOG_PREFIX + ' ' + executable);

        if (protoPathElements != null && !protoPathElements.isEmpty()) {
            log.debug(LOG_PREFIX + "Protobuf import paths:");
            for (final File protoPathElement : protoPathElements) {
                log.debug(LOG_PREFIX + ' ' + protoPathElement);
            }
        }

        if (javaOutputDirectory != null) {
            log.debug(LOG_PREFIX + "Java output directory:");
            log.debug(LOG_PREFIX + ' ' + javaOutputDirectory);

            if (plugins.size() > 0) {
                log.debug(LOG_PREFIX + "Plugins for Java output:");
                for (final ProtocPlugin plugin : plugins) {
                    log.debug(LOG_PREFIX + ' ' + plugin.getId());
                }
            }
        }

        if (pluginDirectory != null) {
            log.debug(LOG_PREFIX + "Plugin directory:");
            log.debug(LOG_PREFIX + ' ' + pluginDirectory);
        }

        if (javaNanoOutputDirectory != null) {
            log.debug(LOG_PREFIX + "Java Nano output directory:");
            log.debug(LOG_PREFIX + ' ' + javaNanoOutputDirectory);
        }
        if (cppOutputDirectory != null) {
            log.debug(LOG_PREFIX + "C++ output directory:");
            log.debug(LOG_PREFIX + ' ' + cppOutputDirectory);
        }
        if (pythonOutputDirectory != null) {
            log.debug(LOG_PREFIX + "Python output directory:");
            log.debug(LOG_PREFIX + ' ' + pythonOutputDirectory);
        }

        if (descriptorSetFile != null) {
            log.debug(LOG_PREFIX + "Descriptor set output file:");
            log.debug(LOG_PREFIX + ' ' + descriptorSetFile);
            log.debug(LOG_PREFIX + "Include imports:");
            log.debug(LOG_PREFIX + ' ' + includeImportsInDescriptorSet);
        }

        log.debug(LOG_PREFIX + "Protobuf descriptors:");
        for (final File protoFile : protoFiles) {
            log.debug(LOG_PREFIX + ' ' + protoFile);
        }

        final List<String> cl = buildProtocCommand();
        if (cl != null && !cl.isEmpty()) {
            log.debug(LOG_PREFIX + "Command line options:");
            log.debug(LOG_PREFIX + Joiner.on(' ').join(cl));
        }
    }
}

From source file:org.xolstice.maven.plugin.protobuf.ProtocPlugin.java

License:Open Source License

/**
 * Validate the state of this plugin specification.
 *
 * @param log a logger instance for diagnostic output.
 * @throws IllegalStateException if properties are incorrect or are missing
 *//*from  w w w  .  j  av  a2s.  co  m*/
public void validate(final Log log) {
    checkState(id != null, "id must be set in protocPlugin definition");
    checkState(groupId != null, "groupId must be set in protocPlugin definition");
    checkState(artifactId != null, "artifactId must be set in protocPlugin definition");
    checkState(version != null, "version must be set in protocPlugin definition");
    checkState(mainClass != null, "mainClass must be set in protocPlugin definition");
    checkState(javaHome != null && new File(javaHome).isDirectory(), "javaHome is invalid: " + javaHome);
    if (Os.isFamily(Os.FAMILY_WINDOWS)) {

        // If winJvmDataModel isn't set explicitly, try to guess the architecture
        // by looking at the directories in the JDK/JRE javaHome points at.
        // If that fails, try to figure out from the currently running JVM.

        if (winJvmDataModel != null) {
            checkState(
                    winJvmDataModel.equals(WIN_JVM_DATA_MODEL_32)
                            || winJvmDataModel.equals(WIN_JVM_DATA_MODEL_64),
                    "winJvmDataModel must be '32' or '64'");
        } else if (archDirectoryExists("amd64")) {
            winJvmDataModel = WIN_JVM_DATA_MODEL_64;
            if (log.isDebugEnabled()) {
                log.debug("detected 64-bit JVM from directory structure");
            }
        } else if (archDirectoryExists("i386")) {
            winJvmDataModel = WIN_JVM_DATA_MODEL_32;
            if (log.isDebugEnabled()) {
                log.debug("detected 32-bit JVM from directory structure");
            }
        } else if (System.getProperty(DATA_MODEL_SYSPROP) != null) {
            winJvmDataModel = System.getProperty(DATA_MODEL_SYSPROP);
            if (log.isDebugEnabled()) {
                log.debug(
                        "detected " + winJvmDataModel + "-bit JVM from system property " + DATA_MODEL_SYSPROP);
            }
        } else {
            winJvmDataModel = WIN_JVM_DATA_MODEL_32;
            if (log.isDebugEnabled()) {
                log.debug("defaulting to 32-bit JVM");
            }
        }
    }
}