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

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

Introduction

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

Prototype

void error(Throwable error);

Source Link

Document

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

Usage

From source file:org.acmsl.queryj.tools.maven.AntProjectAdapter.java

License:Open Source License

/**
 * See {@link Project#log(Target, String, int)}.
 * @param target the target.// w  ww .jav  a2  s.  c o  m
 * @param message the message.
 * @param msgLevel either {@link Project#MSG_ERR}, {@link Project#MSG_WARN},
 * {@link Project#MSG_INFO}, {@link Project#MSG_VERBOSE}, or {@link Project#MSG_DEBUG}.
 * @param log the {@link Log} instance.
 */
protected void log(@NotNull final Target target, @NotNull final String message, final int msgLevel,
        @NotNull final Log log) {
    @NotNull
    final String t_strMessage = "[" + target.getName() + "] " + message;

    switch (msgLevel) {
    case MSG_ERR:
        log.error(t_strMessage);
        break;
    case MSG_WARN:
        log.warn(t_strMessage);
        break;
    case MSG_VERBOSE:
    case MSG_DEBUG:
        log.debug(t_strMessage);
        break;
    default:
        log.info(t_strMessage);
        break;
    }
}

From source file:org.acmsl.queryj.tools.maven.CommonsLoggingMavenLogAdapter.java

License:Open Source License

/**
 * <p> Log a message with error log level. </p>
 * @param message log this message.//from  ww  w  . j  a  v a2s. c om
 * @param mavenLog the actual {@link Log} used for logging.
 */
protected void error(@NotNull final Object message, @NotNull final Log mavenLog) {
    mavenLog.error(message.toString());
}

From source file:org.acmsl.queryj.tools.maven.CommonsLoggingMavenLogAdapter.java

License:Open Source License

/**
 * <p> Log a message with error log level. </p>
 * @param error the error to log.// ww w  .  ja  v  a  2s . c o m
 * @param mavenLog the actual {@link Log} used for logging.
 */
protected void error(@NotNull final Throwable error, @NotNull final Log mavenLog) {
    mavenLog.error(error);
}

From source file:org.acmsl.queryj.tools.maven.CommonsLoggingMavenLogAdapter.java

License:Open Source License

/**
 * <p> Log a message with fatal log level. </p>
 * @param message log this message.//w  w w . j  av  a2  s  . c  o m
 * @param mavenLog the actual {@link Log} used for logging.
 */
protected void fatal(@NotNull final Object message, @NotNull final Log mavenLog) {
    mavenLog.error(message.toString());
}

From source file:org.acmsl.queryj.tools.maven.CommonsLoggingMavenLogAdapter.java

License:Open Source License

/**
 * <p> Log a message with fatal log level. </p>
 * @param fatal the fatal to log.// w w  w.  j  av  a2  s  .c  om
 * @param mavenLog the actual {@link Log} used for logging.
 */
protected void fatal(@NotNull final Throwable fatal, @NotNull final Log mavenLog) {
    mavenLog.error(fatal);
}

From source file:org.acmsl.queryj.tools.maven.QueryJMojo.java

License:Open Source License

/**
 * Executes QueryJ via Maven2./*from   w ww.j  av a 2  s. com*/
 * @param log the Maven log.
 * @param version the QueryJ version.
 * @throws MojoExecutionException if the process fails.
 */
protected void execute(@NotNull final Log log, final String version) throws MojoExecutionException {
    boolean running = false;

    @Nullable
    final File outputDirPath = getOutputDir();

    @Nullable
    final QueryJTask task;

    if (outputDirPath != null) {
        //initialize directories
        @NotNull
        final File outputDir = outputDirPath.getAbsoluteFile();

        if ((!outputDir.exists()) && (!outputDir.mkdirs())) {
            log.warn("Cannot create output folder: " + outputDir);
        }

        //execute task
        task = buildTask(version, log);

        log.info("Running QueryJ " + version);

        task.execute();

        running = true;
    } else {
        log.error("outputDir is null");
    }

    if (!running) {
        log.error("NOT running QueryJ " + version);
        throw new MojoExecutionException("QueryJ could not start");
    }
}

From source file:org.antlr.mojo.antlr4.Antlr4Mojo.java

License:BSD License

/**
 * The main entry point for this Mojo, it is responsible for converting
 * ANTLR 4.x grammars into the target language specified by the grammar.
 *
 * @exception MojoExecutionException if a configuration or grammar error causes
 * the code generation process to fail//  w  w w  . j a  v  a  2 s  . c om
 * @exception MojoFailureException if an instance of the ANTLR 4 {@link Tool}
 * cannot be created
 */
@Override
public void execute() throws MojoExecutionException, MojoFailureException {

    Log log = getLog();

    if (log.isDebugEnabled()) {
        for (String e : excludes) {
            log.debug("ANTLR: Exclude: " + e);
        }

        for (String e : includes) {
            log.debug("ANTLR: Include: " + e);
        }

        log.debug("ANTLR: Output: " + outputDirectory);
        log.debug("ANTLR: Library: " + libDirectory);
    }

    if (!sourceDirectory.isDirectory()) {
        log.info("No ANTLR 4 grammars to compile in " + sourceDirectory.getAbsolutePath());
        return;
    }

    // Ensure that the output directory path is all in tact so that
    // ANTLR can just write into it.
    //
    File outputDir = getOutputDirectory();

    if (!outputDir.exists()) {
        outputDir.mkdirs();
    }

    // Now pick up all the files and process them with the Tool
    //

    List<List<String>> argumentSets;
    try {
        List<String> args = getCommandArguments();
        argumentSets = processGrammarFiles(args, sourceDirectory);
    } catch (InclusionScanException ie) {
        log.error(ie);
        throw new MojoExecutionException(
                "Fatal error occured while evaluating the names of the grammar files to analyze", ie);
    }

    log.debug("Output directory base will be " + outputDirectory.getAbsolutePath());
    log.info("ANTLR 4: Processing source directory " + sourceDirectory.getAbsolutePath());
    for (List<String> args : argumentSets) {
        try {
            // Create an instance of the ANTLR 4 build tool
            tool = new CustomTool(args.toArray(new String[args.size()]));
        } catch (Exception e) {
            log.error("The attempt to create the ANTLR 4 build tool failed, see exception report for details",
                    e);
            throw new MojoFailureException("Error creating an instanceof the ANTLR tool.", e);
        }

        // Set working directory for ANTLR to be the base source directory
        tool.inputDirectory = sourceDirectory;

        tool.processGrammarsOnCommandLine();

        // If any of the grammar files caused errors but did nto throw exceptions
        // then we should have accumulated errors in the counts
        if (tool.getNumErrors() > 0) {
            throw new MojoExecutionException("ANTLR 4 caught " + tool.getNumErrors() + " build errors.");
        }
    }

    if (project != null) {
        // Tell Maven that there are some new source files underneath the output directory.
        addSourceRoot(this.getOutputDirectory());
    }
}

From source file:org.apache.james.mailet.DefaultDescriptorsExtractor.java

License:Apache License

private void addDescriptor(Log log, final URLClassLoader classLoader, final Class<?> mailetClass,
        final Class<?> matcherClass, final JavaClass nextClass) {
    final String nameOfNextClass = nextClass.getFullyQualifiedName();
    if (log.isDebugEnabled()) {
        log.debug("Class: " + nameOfNextClass);
    }/*from  w  w  w .  j  a va 2 s. co m*/

    try {
        final Class<?> klass = classLoader.loadClass(nameOfNextClass);

        logConstructor(log, klass);

        final List<Class<?>> allInterfaces = getAllInterfaces(klass);

        if (allInterfaces.contains(mailetClass)) {
            final MailetMatcherDescriptor descriptor = describeMailet(log, nextClass, nameOfNextClass, klass);
            descriptors.add(descriptor);

        } else if (allInterfaces.contains(matcherClass)) {
            final MailetMatcherDescriptor descriptor = describeMatcher(log, nextClass, nameOfNextClass, klass);
            descriptors.add(descriptor);
        } else {
            logInterfaces(log, klass, allInterfaces);
        }

    } catch (NoClassDefFoundError e) {
        log.error("NotFound: " + e.getMessage());
    } catch (ClassNotFoundException e) {
        log.error("NotFound: " + e.getMessage());
    } catch (SecurityException e) {
        log.error("SE: " + e.getMessage());
    } catch (IllegalArgumentException e) {
        log.error("IAE2: " + e.getMessage());
    }

    logInterfacesImplemented(log, nextClass);
}

From source file:org.apache.tuscany.maven.plugin.TuscanyLaunchMojo.java

License:Apache License

protected void waitForShutdown(DomainNode domainNode, Log log) {
    Runtime.getRuntime().addShutdownHook(new ShutdownThread(domainNode, log));
    synchronized (this) {
        try {/*from w ww.  j  a v  a2  s.  co m*/
            log.info("Ctrl-C to end...");
            this.wait();
        } catch (InterruptedException e) {
            log.error(e);
        }
    }
}

From source file:org.boretti.drools.integration.drools5.DroolsHelper.java

License:Open Source License

private static boolean validationError(Log logger, PackageBuilderErrors errors, File src) {
    if (errors != null) {
        DroolsError err[] = errors.getErrors();
        if (err.length > 0) {
            for (DroolsError e : err) {
                StringBuilder sp = new StringBuilder();
                sp.append("" + src.getAbsolutePath()).append(":");
                if (e.getErrorLines() != null)
                    for (int l : e.getErrorLines())
                        sp.append(l).append(":");
                sp.append(e.getMessage());
                logger.error("Drools Error : " + sp);
            }//from ww w. j  a  v a2  s  .  c o m
            return false;
        }
    }
    return true;
}